Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

What you need

Step by step

  1. Place inputs A7 to A0, B7 to B0 and Cin, and probes S7 to S0 and Cout.
  2. For each bit make p = A XOR B and g = A AND B, and fold Cin into bit 0: G0 = g0 + p0 Cin.
  3. Up-sweep: G1:0, then the pairs 3:2, 5:4, 7:6; then G3:0 = G3:2 + P3:2 G1:0 and the span 7:4; then G7:0, the carry out.
  4. 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.
  5. 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

AdderPrefix cellsLongest carry pathDepth grows like
Ripple-carrynone (a carry chain)8 full-adder carriesn
Brent-Kung (this one)12 (11 plus the Cin cell)5 cellsabout 2 log2(n)
Kogge-Stone18 (17 plus the Cin cell)4 cellslog2(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

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adder4-bit Kogge-Stone adder4-bit carry-skip adder4x4 Wallace tree multiplier8-bit adderfrequency divider (by 2, 4 and 3)switch debouncer (SR latch)3-bit Gray code counterMealy machine (1011 detector)master-slave JK flip-flop (NAND)half subtractor from NOR gates1-to-8 demultiplexerexcess-3 to BCD code convertervending machine FSM4-bit carry-save adder3-bit synchronous counter (JK)CMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxesXOR gate from NOR gates4-bit LFSR74LS138 decoderBCD subtractor74181 ALUCMOS AOI gate (AOI21)D latch vs D flip-flop74LS47 BCD to 7-segment decoder74HC595 shift register7400 quad NAND gate chip7402 quad NOR gate chip7404 hex inverter chip7408 quad AND gate chip7432 quad OR gate chip7486 quad XOR gate chip7474 dual D flip-flop74HC165 shift registerCD4017 decade counter74LS283 4-bit adder74LS90 decade counter74HC161 4-bit counter74HC151 8-to-1 multiplexer74HC157 quad 2-to-1 multiplexer74HC139 dual 2-to-4 decoderCD4511 BCD to 7-segment decoder7492 divide-by-12 counter7493 4-bit binary counter74HC244 octal bufferRace-around condition (JK latch)74HC373 octal latch74HC374 octal D flip-flopTurnstile state machine1-to-2 demultiplexerhalf adder using 2:1 multiplexersregister file (4 x 4-bit)digital PWM generatorCD4013 dual D flip-flop74LS76 dual JK flip-flop7410 triple 3-input NAND chip7411 triple 3-input AND chip7420 dual 4-input NAND chipCD4011 quad 2-input NAND chipCD4001 quad 2-input NOR chipCD4081 quad 2-input AND chipCD4069 hex inverter chip74HC164 8-bit shift register7485 4-bit magnitude comparator74HC125 quad tri-state bufferCD4040 12-stage binary counterCD4060 14-stage counter and oscillator74LS193 4-bit up/down counterelectronic dice circuitmemory address register (MAR) and MDRhardware stack with a stack pointerdirect-mapped cache4x4 Dadda multiplierbinary clock circuit

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.