Section 3 · 9 min read
ALU and control unit design
Adder delays, carry lookahead, overflow, Booth multiplication, and how hardwired and microprogrammed control units are built and sized.
On this page
The datapath and the control unit
A processor is split into two parts. The datapath holds the registers, the ALU, the buses and the multiplexers that move data. The control unit decides, cycle by cycle, which control signals are active: which register drives the bus, which register loads, which ALU operation runs, whether memory reads or writes. GATE asks about both halves: adder timing and arithmetic algorithms on the ALU side, and control word sizes and the hardwired versus microprogrammed trade-off on the control side.
ALU design
An ALU combines an adder with logic units (AND, OR, XOR, NOT) and a multiplexer that selects the result. Subtraction reuses the adder: , done by inverting and setting the carry-in to 1. Status flags are produced alongside the result: zero (all result bits 0), sign (top bit), carry (carry out of the top bit) and overflow.
Ripple-carry adder
An -bit ripple-carry adder chains full adders. A full adder computes
The carry has to pass through every stage, so delay grows linearly. If each stage produces its carry after its carry-in is ready and its sum after the carry-in is ready, and all operand bits are ready at time 0:
- carry into stage is ready at ,
- the last sum bit is ready at ,
- the final carry out is ready at .
The worst-case add time is the larger of the last two. Read the question carefully for whether it asks for the carry, the sum, or both.
Carry-lookahead adder
Define for each bit
Then . Expanding removes the chain:
Every carry is now a two-level AND-OR expression. With one gate delay for and , every carry of a 4-bit block is ready after 3 gate delays, and every sum (one more XOR) after 4, independent of bit position. The cost is fan-in: needs a 5-input OR and a 5-input AND. That is why wide adders are built from 4-bit lookahead blocks, either rippled between blocks or with a second lookahead level using block generate and propagate signals.
Overflow in two's complement
Adding two -bit two's complement numbers overflows when the true sum does not fit in bits. Equivalent tests:
- the operands have the same sign and the result has the other sign,
- , where is the carry into the sign bit and the carry out.
A carry out of the sign bit alone is not overflow. Adding and produces a carry out and the correct result 0.
Booth's multiplication
Booth's algorithm multiplies two's complement numbers. Append to the right of the multiplier and scan pairs from upward:
| Action before the arithmetic shift right | |
|---|---|
| 00 | none |
| 11 | none |
| 10 | subtract multiplicand |
| 01 | add multiplicand |
A run of 1s in the multiplier becomes one subtraction at its low end and one addition just past its high end, because . Long runs of 1s save work. The worst case is an alternating pattern like 0101..., where every pair triggers an operation.
Control unit design
The control unit produces a sequence of control words. Each instruction is broken into micro-operations such as , , , . Each step (T-state) activates a set of control signals.
Hardwired control
The control signals are produced by combinational logic whose inputs are the decoded opcode, a step counter (often a ring counter or a counter plus decoder giving ) and the status flags. Each signal is a logic expression such as .
- Fast: signals appear after a few gate delays.
- Hard to change: adding an instruction means redesigning logic.
- Preferred in RISC processors with simple, regular instructions.
Microprogrammed control
Each control word is stored in a control memory (control store, usually ROM). A control address register (CAR, also called micro-PC) points to the current microinstruction. Executing a machine instruction means running a short microprogram: the opcode is mapped to the starting address of its routine, and the sequencer steps through it, branching on conditions.
A microinstruction typically has:
- control field(s): which signals to assert,
- condition select field: which status bit to test for branching (one code is usually "always true"),
- next address field: where to go if the condition holds (otherwise CAR increments).
Width formula:
Control memory size .
Horizontal versus vertical microinstructions
| Horizontal | Vertical | |
|---|---|---|
| Encoding | one bit per control signal | signals grouped and binary encoded |
| Width | wide | narrow |
| Parallelism | any combination of signals at once | only one signal per group at once |
| Decoders needed | no | yes, one per field |
| Speed | faster (no decode) | slightly slower |
For a group of mutually exclusive signals, an encoded field needs bits if one code must mean "none of these", or if the group always asserts exactly one signal. GATE questions state which; when they say "mutually exclusive" without more, the safe assumption is the for a no-operation code, but read the wording.
Comparison
| Hardwired | Microprogrammed | |
|---|---|---|
| Speed | faster | slower (control memory read per step) |
| Flexibility | low | high, change the microprogram |
| Design effort for complex ISA | high | moderate |
| Typical use | RISC | CISC, many addressing modes |
Worked examples
Worked example 1: ripple versus lookahead timing
A 32-bit adder. Option R: ripple-carry, where each full adder makes its carry 2 gate delays after its inputs. Option L: eight 4-bit carry-lookahead blocks with the block carries rippling from block to block. In each block, and take 1 gate delay and the block carry out is ready 2 gate delays after both its , signals and its carry-in are ready. When is the final carry out ready?
- R: gate delays.
- L: block 1 carry out at . Block carry out at , so each further block adds 2. Block 8: gate delays.
The lookahead version is almost 4 times faster for the carry chain, at the cost of more gates.
Worked example 2: detecting overflow
4-bit two's complement.
- : . Carry into bit 3 is 1, carry out is 0. They differ, so overflow. Indeed .
- : . Carry into bit 3 is 0, carry out is 1. Overflow, since . The 4-bit result is wrong.
- : . Carry in and out are both 0. No overflow.
Worked example 3: Booth worst case
How many add or subtract operations does Booth's algorithm perform for the 8-bit multiplier 01010101?
Append . Pairs from the right: subtract, add, subtract, add, subtract, add, subtract, add. Eight operations, 4 additions and 4 subtractions. Plain shift-and-add would need only 4 additions (one per 1 bit), so Booth is worse here. Booth helps for long runs of 1s, such as 01111110, which needs only 2 operations.
Worked example 4: sizing a microprogrammed control unit
A control unit generates 52 control signals. 20 of them are independent and get one bit each. The other 32 fall into three mutually exclusive groups of 12, 6 and 14 signals, each encoded with a "none" code. The sequencer can test 6 status flags plus an always-true condition, encoded. The control memory has 512 words. Find the microinstruction width and control memory size.
- Independent signals: 20 bits.
- Group of 12: . Group of 6: . Group of 14: . Total 11 bits.
- Condition select: 7 options, bits.
- Next address: bits.
bits. Control memory bits. A fully horizontal design would use bits per word.
Common traps
- Sum versus carry delay. In ripple adders the last sum bit can be later than the final carry. Compute both.
- Carry out is not overflow for signed addition. Use .
- Booth pairs start at with . Starting from the left end gives wrong counts.
- The "none" code. A group of 8 signals fits in 3 bits only if one of the 8 is active in every microinstruction. If the field also needs an idle code, there are 9 codes and it needs 4 bits.
- Control memory words. If a microprogram has 230 microinstructions, the address field is bits, not 7.
- Horizontal is wider, vertical is narrower. Vertical needs decoders; horizontal allows more parallel signals.
Quick revision
- , .
- Ripple carry: carry into bit at ; last sum at .
- CLA: , , , every carry in two levels.
- Overflow (signed): , or same-sign operands giving an opposite-sign result.
- Booth: 10 subtract, 01 add, 00 and 11 nothing; best for runs of 1s, worst for alternating bits.
- Hardwired: fast, rigid, RISC. Microprogrammed: flexible, slower, CISC.
- Microinstruction width control bits condition select bits next address bits.
- Encoded group of signals with idle code: bits.