Faster Carries: Carry-Lookahead
A column produces a carry for one of two reasons: it makes one itself (both bits 1), or it passes along the one coming in (exactly one bit 1). Writing that down and unrolling it gives every carry straight from the inputs, and organizing the work as a tree cuts the delay from about to about .
What the symbols mean
- Generate
1 when column i makes a carry by itself (both bits are 1).
- Propagate
1 when column i passes an incoming carry along (exactly one bit is 1).
What the symbols mean
- Block generate
1 when a carry comes out of the block whatever comes in.
- Block propagate
1 when a carry coming into the block makes it all the way through.
Explanation
Carry-lookahead is simply a way to work out every carry at once by looking straight at the input bits, instead of waiting for the carry to walk over column by column. The name says it: each column looks ahead at the columns below it to see whether a carry is on its way. Two small words do all the work. (generate) is 1 when column makes a carry by itself, because both its bits are 1. (propagate) is 1 when column passes a carry along, because exactly one of its bits is 1, so an incoming carry makes the column's total 2. The long unrolled formula looks scary, but read it out loud and it's a sentence: "there's a carry into column if column generated one, or column propagates and column generated one, or both propagate and column generated one, and so on down." Bear with it.
The carry recurrence. The carry rule from ripple-carry adders was . In the new words that's . Notice what and depend on: only and , which are all there the moment the inputs arrive. So every and is ready after one gate delay, all at once. Only the 's form a chain. It's a recurrence relation, and the ripple adder just evaluates it one step at a time.
Unroll it. Substitute each carry into the next one:
Each carry is now written straight from the 's, 's and : a layer of ANDs feeding one OR, two gate levels, no waiting. So why not do that for all 64 carries? Look at : it has 65 terms, and the last one is an AND of 65 inputs. Gates with dozens of inputs are slow and huge, and across all the carries the number of terms grows like . The formula is the right idea; it just needs organizing.
Blocks, and blocks of blocks. Group four columns into a block. The block generates a carry if one comes out of its top no matter what comes in: . It propagates if a carry coming in makes it all the way through, which needs all four columns to propagate: . Then the block's carry out is : exactly the same shape as one column's . That's the key. A block of blocks works the same way again, so a 16-bit adder is four 4-bit blocks with one lookahead unit over them, and a 64-bit adder is four of those.
In general, two neighboring spans of columns combine by
and this rule is associative. So you can combine spans in any grouping, in particular as a balanced tree, the way you'd add up a long list of numbers in pairs, then pairs of pairs.
The delay is about . A balanced tree over columns has levels, and each level costs about 2 gate delays (an AND then an OR). Add one gate delay to make the 's and 's and one for the final sum bit , and a simple model is gate delays, against for ripple-carry:
| ripple-carry, | lookahead, | speedup | |
|---|---|---|---|
| 8 | 16 | 8 | 2× |
| 32 | 64 | 12 | 5.3× |
| 64 | 128 | 14 | 9.1× |
Doubling the width adds two gate delays instead of doubling the time; that's the difference between and from big-O. The price is area: a fast lookahead tree uses on the order of gates instead of , plus a lot of wiring. There's an animation further down that plots both curves against a real clock budget.
One small design detail: for the carries alone, (OR) would work just as well as XOR, because when both bits are 1 the term already covers it. But the XOR gets reused for the sum bit, , so it comes for free.
A common mistake. It's tempting to think lookahead makes the delay constant, since every carry has a two-level formula. On paper it does, but only with gates that take inputs, and real gates get slower and bigger as you add inputs, while the total number of terms grows like . The honest win is from down to , by building the lookahead as a tree of small gates.
See it
Worked examples
Find every carry of () with generate and propagate, starting from . Then find the sum.
- 1
Line up the bits by column, from bit 3 on the left to bit 0 on the right: gives , and gives .
Using the models ripple and lookahead gate delays with 15 ps gates, compare 32-bit and 64-bit adders.
- 1
Ripple-carry, 32 bits: gate delays.
Practice
Type your answer and check it. Solve them all to complete the lesson.
In a carry-lookahead adder, column has and . What are its generate bit and propagate bit ? Enter , then .
A 4-bit block adds and . What are its block propagate and block generate ? Enter , then .
For and with , find and using generate and propagate. Enter both.
With 15 ps gates, a 64-bit ripple-carry adder takes gate delays and a lookahead adder . How many picoseconds does lookahead save?
A design has a budget of 16 gate delays for the adder. An -bit ripple-carry adder takes gate delays and a lookahead adder . What is the widest power-of-2 width each adder can have? Enter ripple-carry, then lookahead.
Why can block generate/propagate pairs be combined in a balanced tree, in any grouping you like?
If every carry of a 32-bit adder is written out fully flattened, (for ) has terms: , , …, and the last one ending in . How many terms are there across all 32 carries?
The hardest one here. Get it, and you've got this lesson.
A 16-bit adder is built from four 4-bit blocks with a lookahead unit over them. It adds 0x0F3A and 0x00C9 with . Find each block's and , then the carries into bits 4, 8 and 12 and out of bit 15. Enter , , , .
Where it's used
Every high-speed adder in a CPU or GPU is a parallel-prefix design built on exactly this generate/propagate algebra; the different named variants trade gate count against wiring and depth. The same prefix idea, combining neighbors in a tree with an associative rule, is also how GPUs compute running totals (a "scan") over millions of numbers in parallel.