How a Brent-Kung adder works: an 8-bit parallel prefix adder
A Brent-Kung adder finds every carry with a parallel prefix tree that uses as few cells as possible: an up-sweep combines generate and propagate signals into spans of 2, 4 and 8 bits, and a down-sweep fills in the carries in between. This live 8-bit one uses 12 prefix cells where a Kogge-Stone adder would need 18, at the cost of more levels.
Each bit makes g = A AND B (generate) and p = A XOR B (propagate), and Cin joins bit 0 as G0 = g0 OR (p0 AND Cin). A gray cell combines a high group with the one below it, G = Gh OR (Ph AND Gl); a black cell also passes on P = Ph AND Pl. The up-sweep pairs neighbours into spans 1:0, 3:2, 5:4 and 7:6, then 3:0 and 7:4, then 7:0, which is the carry out. That leaves the carries at bits 2, 4, 5 and 6, and the down-sweep supplies them: G5:0 from G5:4 and G3:0, then G2:0, G4:0 and G6:0, each from its own bit and the span just below it. Richard Brent and H. T. Kung published the scheme in 1982. Compared with the Kogge-Stone adder, which computes every span at every level and finishes in log2(n) levels, Brent-Kung uses about 2n cells instead of n log2(n), with shorter wires, but its longest carry path is about twice as deep (in this 8-bit version it passes through 5 cells, against 4 for a Kogge-Stone adder with the same Cin cell), which is why it suits designs where area and power matter more than the last bit of speed. A ripple-carry adder sits at the other extreme, with no tree at all. 2^17 input rows are too many to sweep on every build, so before the page is built 3,160 additions are checked on every sum bit and Cout: each value of A with B = 0, 1, A, 255 - A and 255 and both carries in, plus 600 seeded random pairs.
Open this circuit in the lab →
What you need
- 8× XOR: propagate p_i = A_i XOR B_i
- 8× AND: generate g_i = A_i AND B_i
- 4× black cell (AND + OR, plus an AND): up-sweep spans 3:2, 5:4, 7:6 and 7:4
- 8× gray cell (AND + OR): G0 with Cin, G1:0, G3:0 and G7:0 (up-sweep), G5:0, G2:0, G4:0 and G6:0 (down-sweep)
- 8× XOR: sums S_i = p_i XOR c_i
Step by step
- Place inputs
A7toA0,B7toB0andCin, and probesS7toS0andCout. - For each bit make
p = A XOR Bandg = A AND B, and fold Cin into bit 0:G0 = g0 + p0 Cin. - Up-sweep:
G1:0, then the pairs3:2,5:4,7:6; thenG3:0 = G3:2 + P3:2 G1:0and the span7:4; thenG7:0, the carry out. - Down-sweep:
G5:0 = G5:4 + P5:4 G3:0,G2:0 = g2 + p2 G1:0,G4:0 = g4 + p4 G3:0,G6:0 = g6 + p6 G5:0. - Sums:
S_i = p_i XOR c_i, where c0 = Cin and c(i+1) = G(i:0). Try 01111111 + 00000001: every carry is set.
Cells and depth, 8 bits
| Adder | Prefix cells | Longest carry path | Depth grows like |
|---|---|---|---|
| Ripple-carry | none (a carry chain) | 8 full-adder carries | n |
| Brent-Kung (this one) | 12 (11 plus the Cin cell) | 5 cells | about 2 log2(n) |
| Kogge-Stone | 18 (17 plus the Cin cell) | 4 cells | log2(n) |
Cell counts include the extra gray cell that folds Cin into bit 0. For n bits, Brent-Kung needs 2n - 2 - log2(n) prefix cells and Kogge-Stone n log2(n) - n + 1, so the gap widens quickly: at 64 bits it is 120 cells against 321.
You can also read the full theory in the lesson on faster adders and carry lookahead. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
Build more parts from gates
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the 8-bit Brent-Kung adder in the lab →Frequently asked
How does a Brent-Kung adder work?
It computes generate and propagate for each bit, combines them in an up-sweep tree into spans of 2, 4, 8 and so on bits, and then fills in the missing carries with a down-sweep. Each sum bit is p XOR the carry into that bit.
What is the difference between Brent-Kung and Kogge-Stone adders?
Kogge-Stone computes every span at every level, so it is the fastest (log2(n) levels) but uses many cells and long wires. Brent-Kung uses about 2n cells and short wires but needs about twice as many levels. Other prefix adders, such as Sklansky, Ladner-Fischer and Han-Carlson, make other trade-offs.
Is a Brent-Kung adder faster than a ripple-carry adder?
For wide words, yes: its delay grows with log2(n) rather than with n. In this 8-bit version the longest carry path passes through 5 prefix cells, against 8 full-adder carries in a ripple adder.
Who invented the Brent-Kung adder?
Richard P. Brent and H. T. Kung, in a 1982 paper on a regular layout for parallel adders.