Draft preview. Lessons are being written and reviewed.

Digital Design / Module 2: Combinational building blocks

9. Carry look-ahead and prefix adders

Trade area for speed.

Lecture coming soon

See it move

The idea

A ripple adder makes the top bit wait for every carry below it. Faster adders work out the carries in parallel, using two signals from each bit position:

  • Generate G = A·B: this bit makes a carry, whatever comes in.
  • Propagate P = A ^ B: this bit passes an incoming carry along.

Then C(i+1) = G(i) + P(i)·C(i).

Carry look-ahead

Substitute the equation into itself to remove the dependence on earlier carries:

  • C1 = G0 + P0·C0
  • C2 = G1 + P1·G0 + P1·P0·C0
  • C3 = G2 + P2·G1 + P2·P1·G0 + P2·P1·P0·C0

Each carry is now a two-level function of the inputs. The catch is that the terms grow with width, so gates become too wide past about four bits. Designs use small look-ahead blocks instead and combine them.

Prefix adders

A prefix tree merges neighbouring groups of bits: (G,P) pairs for 1 bit combine into 2-bit groups, then 4-bit, then 8-bit. A group's generate is G_hi + P_hi·G_lo, and its propagate is P_hi·P_lo. Each level doubles how far carry information has travelled, so depth grows with log2(N) rather than N.

Kogge-Stone and Brent-Kung are two well-known forms. Kogge-Stone has low fanout and many wires, whereas Brent-Kung uses fewer cells and more levels. In practice, the synthesis tool usually selects an architecture based on your timing constraints.

The trade-off

RipplePrefix
DelayGrows with NGrows with log2(N)
Area and wiringSmallestLarger
Use whenTiming is relaxedTiming is tight

Common mistake

Hand-writing a fast adder in RTL by default. Write a + b, set the timing constraint, and let the tool choose. Hand-built structures are worth the effort only when you have measured a problem they solve.

Key ideas

  • Generate is AB, propagate is A xor B.
  • Look-ahead computes carries in parallel.
  • Prefix trees reach logarithmic depth.

Your exercise

Derive C2 in terms of generate, propagate and C0.

Interview questions

coreExpress C2 with G and P.

basicDefine generate and propagate for one bit of an adder and say what each means.

basicHow many levels of merge cells does a prefix tree need for a 64-bit adder, compared with stages in a ripple adder?

coreFor A = 1011 and B = 0110 with carry in 0, compute G, P and every carry using look-ahead.

coreA low group has G = 1, P = 0 and the high group next to it has G = 0, P = 1. What are the merged group's G and P?

coreWhy doesn't a flat carry look-ahead scale to 32 bits?

coreSome texts define propagate as A OR B instead of A XOR B. Do the carries still come out right? What about the sum?

advancedIn a 16-bit Kogge-Stone tree (carry in 0), how many merge cells are there and how many levels?

advancedA hand-written prefix merge cell computes group generate as shown. Find a case where it gives the wrong carry.

// merge two (g,p) groups; hi is more significant
assign g = g_hi | g_lo;
assign p = p_hi & p_lo;

Practise these 9 questions with animations