Arithmetic, Logic, and Shift Micro-operations (ALU Design)
What are Micro-operations? (In Simple Words)
No matter how complex a computer program or game is, the CPU breaks every instruction down into tiny, atomic hardware steps called Micro-operations.
- A Micro-operation is an elementary operation performed on data stored inside registers during a single clock cycle.
- The Arithmetic Logic Unit (ALU) executes these micro-operations.
1. Arithmetic Micro-operations
The basic math operations include:
- Add:
R₃ ← R₁ + R₂ - Subtract (via 2’s complement):
R₃ ← R₁ + R₂' + 1 - Increment (Add 1):
R₁ ← R₁ + 1 - Decrement (Minus 1):
R₁ ← R₁ - 1
The 4-Bit Arithmetic Circuit:
Built using 4 Full Adders and 4 Multiplexers.
By changing the two select lines (S₁, S₀) and the carry-in (Cin), this single circuit performs 8 distinct operations:
| Select S₁ | Select S₀ | Cin | Hardware Output Equation | Math Operation |
|---|---|---|---|---|
| 0 | 0 | 0 | D = A + B |
Add |
| 0 | 0 | 1 | D = A + B + 1 |
Add with Carry |
| 0 | 1 | 0 | D = A + B' |
Subtract with Borrow |
| 0 | 1 | 1 | D = A + B' + 1 |
Subtract (A - B) |
| 1 | 0 | 0 | D = A |
Transfer A directly |
| 1 | 0 | 1 | D = A + 1 |
Increment A |
| 1 | 1 | 0 | D = A - 1 |
Decrement A |
| 1 | 1 | 1 | D = A |
Transfer A directly |
2. Logic Micro-operations and Bit Manipulation
Logic micro-operations treat each bit in a register independently (no carry is passed between columns).
💡 Real-Life Indian Student Analogy:
Think of marking attendance on a register page.
You mark each student’s checkbox one-by-one without affecting other rows.
Bit-manipulation does the exact same thing to individual bits!
Four Essential Bit-Manipulation Tricks:
- Selective Set (Uses OR): Turns chosen target bits into
1without changing the other bits.- Example:
1010OR0100=1110(Bit 2 is forced ON).
- Example:
- Selective Clear (Uses AND with Inverted Mask): Forces chosen target bits to
0.- Example:
1111AND1011=1011(Bit 2 is cleared to 0).
- Example:
- Selective Complement (Uses XOR): Inverts only the chosen bits (flips 0 to 1, and 1 to 0).
- Example:
1010XOR0011=1001(Last 2 bits flipped).
- Example:
- Masking (Uses AND): Wipes an entire half of a register to
0while keeping the rest untouched.- Example:
1101 0101AND0000 1111=0000 0101.
- Example:
3. Shift Micro-operations
shl (Shift Left) and shr (Shift Right).Right Shift: Keeps the sign bit (MSB) unchanged.
Left Shift: Multiplies the number by 2.
Detecting Overflow in Arithmetic Shift Left:
When you shift a signed number left, you double its value.
- If the number becomes too large for the register, the sign bit flips incorrectly!
- The CPU detects this Overflow using an XOR gate on the two leftmost bits:
V = Rₙ₋₁ ⊕ Rₙ₋₂ - If V = 1, an overflow error flag is set.
💡 DAVV Exam Preparation Tips
5-Mark Question: “Explain Selective Set, Selective Clear, Selective Complement, and Masking operations with binary examples.”
- Name the required logic gate for each operation:
- Selective Set → OR gate
- Selective Clear → AND gate with inverted mask
- Selective Complement → XOR gate
- Masking → AND gate with
0000 1111mask- Give a short 4-bit binary calculation example for each.
10-Mark Question: “Design an Arithmetic Circuit that performs addition, subtraction, increment, and decrement using Full Adders and Multiplexers. Provide its function table.”
- Draw the block diagram: Multiplexers control whether B, B’, 0, or 1 feed into the Full Adders.
- Present the full 8-row truth table for
S₁, S₀, Cin.- Clearly show how 2’s complement subtraction
A + B' + 1works.