Arithmetic and logic unit design
An ALU combines arithmetic, bitwise logic and comparison under control signals. Treat operands as fixed-width bit strings, then interpret the result as unsigned or signed as required. Number-format conversion is covered in the Digital Logic and Electronics handbook.
2.1 Addition, subtraction and flags
Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark
2.2 Carry generation and adder timing
Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark
The ripple design passes each carry to the next bit. Carry lookahead expands this recurrence, trading extra logic and wiring for shorter carry paths.
Long carry propagation occurs when low bits generate a carry and intervening bits propagate it. There is no technology-independent “two-gate delay” for an arbitrary-width lookahead adder: fan-in limits and hierarchical grouping matter. Some references define propagate as ; that still works in the carry recurrence, but cannot replace XOR in the sum expression.
2.3 Selecting ALU operations
Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark
A bit-sliced ALU can compute arithmetic and logic candidates concurrently and select one output per bit. Operand multiplexers choose registers, immediates or constants. The available connections determine whether register–register, register–immediate or immediate–immediate operations are possible; inspect both ALU inputs.
A practical design sequence is: list operations; identify shared hardware; specify selectors and write enables; define flags; then check every control combination. Signed comparison uses subtractor overflow correction. Flags may be enabled only for certain instructions. A wide bus selector needs one multiplexer per data bit, with common select lines.
2.4 Shift and rotate paths
Logical shifts insert zeros. Arithmetic right shift replicates the sign bit. A rotate wraps discarded bits back to the other end; rotate-through-carry includes the carry flag as an extra bit and is a different operation.
An -bit barrel shifter for power-of-two can use multiplexer layers, selecting shifts by positions. Each layer has two-input bit multiplexers in the straightforward design.
2.5 Multiplication and Booth recoding
Past papers · CS 2014–2026 (23 papers): 1 question, 1 mark
Unsigned shift-and-add forms one shifted partial product for each 1 in the multiplier. Two -bit operands can require product bits. Booth recoding handles signed two's-complement multiplication by recoding transitions between adjacent multiplier bits.
| Current pair | Recoded digit | Partial-product action |
|---|---|---|
| 00 | 0 | None |
| 01 | +1 | Add shifted multiplicand |
| 10 | −1 | Subtract shifted multiplicand |
| 11 | 0 | None |
The iterative implementation starts with accumulator zero, the multiplier in a shift register, and a trailing zero. Inspect its low pair, add/subtract the multiplicand in the accumulator if required, then arithmetic-right-shift the combined accumulator, multiplier and trailing-bit register. Repeat times. Preserve sufficient sign width: using an extra accumulator bit handles negation of the most negative -bit multiplicand safely. The final product is the signed low bits.
2.6 Division datapath
Binary restoring division keeps a partial remainder. Bring down the next dividend bit, subtract the divisor, retain the subtraction if it is nonnegative, and otherwise restore the old trial value. Each trial produces one quotient bit.
Non-restoring division avoids immediate restoration after a negative trial: shift the signed partial remainder and add the divisor when the old remainder was negative, or subtract it otherwise; set the quotient bit from the new remainder's sign. Add the divisor once at the end if the final remainder is negative. For signed division, divide magnitudes, apply the quotient sign, then follow the ISA's remainder convention. Division by zero and most-negative divided by need separate handling.
Last-minute recall
- Subtraction complements the second operand and sets the initial carry to one.
- Raw subtractor carry means no borrow under this handbook's convention.
- Signed overflow is carry into the sign bit XOR carry out.
- Lookahead removes serial carry dependence by expanding generate/propagate terms.
- Sign-filled right shift of a negative integer rounds down, not toward zero.
- Booth counts transitions, including the appended low zero, across exactly the stored multiplier width.
- A division answer must satisfy dividend = divisor × quotient + remainder.