Chapter 2

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 Ai∨BiA_i\lor B_i; 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 nn-bit barrel shifter for power-of-two nn can use log⁡2n\log_2 n multiplexer layers, selecting shifts by 1,2,4,…,n/21,2,4,\ldots,n/2 positions. Each layer has nn 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 nn-bit operands can require 2n2n product bits. Booth recoding handles signed two's-complement multiplication by recoding transitions between adjacent multiplier bits.

Current pair (qi,qi−1)(q_i,q_{i-1})Recoded digitPartial-product action
000None
01+1Add shifted multiplicand
10−1Subtract shifted multiplicand
110None

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 nn times. Preserve sufficient sign width: using an extra accumulator bit handles negation of the most negative nn-bit multiplicand safely. The final product is the signed low 2n2n 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 −1-1 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.

Revise offline: the whole Computer Organization and Architecture handbook as one PDF

36 pages · 2.5 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections