Altifigence Academy

16 / 63 · Concept

Adders and carry propagation

Derive full-adder equations and analyze ripple carry in terms of function, width and delay.

Express a one-bit addition with two result bits

The sum of ai,bi,cia_i,b_i,c_i ranges from 0 to 3, requiring a sum bit sis_i and a carry ci+1c_{i+1} into the next position. The sum bit is 1 for an odd number of 1 inputs; the carry is 1 for at least two.

si=ai⊕bi⊕cis_i=a_i\oplus b_i\oplus c_i
ci+1=aibi+(ai⊕bi)cic_{i+1}=a_ib_i+(a_i\oplus b_i)c_i

Define generate as gi=aibig_i=a_ib_i and propagate as pi=ai⊕bip_i=a_i\oplus b_i. Then ci+1=gi+picic_{i+1}=g_i+p_ic_i, where ++ means OR. A half adder is the special case without a carry input: its sum is XOR and its carry is AND.

Change the three inputs and confirm that a+b+cin = sum+2×cout always holds. Carry becomes the next position's input; it does not have the same weight as sum.

The sum bit and carry to the next position

a + b + cin = sum + 2 × cout

How far must the carry travel?

Consider four-bit 1111 + 0001. Bit 0 generates a carry that propagates through the other three positions. The stored sum is 0000 and the final carry is 1. In a ripple-carry structure, higher positions may have to wait for carry from lower positions.

c2=g1+p1g0+p1p0c0c_2=g_1+p_1g_0+p_1p_0c_0

Expanding the equations reveals opportunities to compute carry in parallel. Fast adders combine group propagate and generate terms, but trade area against delay through fan-in, wiring and library cells. An RTL + does not necessarily map to a ripple-carry circuit.

Make the sum width explicit in the design

SystemVerilog
logic [3:0] a, b, sum;
logic cin, cout;
logic [4:0] wide_sum;
assign wide_sum = {1'b0, a} + {1'b0, b} + {4'b0000, cin};
assign sum = wide_sum[3:0];
assign cout = wide_sum[4];

Five bits are sufficient because the maximum is 15+15+1=3115+15+1=31. Decide first whether only the low-order sum is needed, whether carry feeds another stage, and whether saturation is required. The interactive exercise checks a single full-adder stage's truth tableTruth table A table listing every possible input combination and its output. Changes over time are checked separately with waveforms. Learn more; it does not measure the delay of an actual synthesized circuit.

Change the inputs

Try it yourself

For four-bit unsigned a=9a=9, b=6b=6 and cin=1c_{in}=1, find the full sum, four-bit sum and carry. If the same circuit is interpreted as signed addition, can carry alone determine overflow?

Read the explanation

The full sum is 16, or 10000, so sum=0000 and carry=1. Under a signed interpretation, 1001 is -7, so −7+6+1=0-7+6+1=0, within range. Carry and signed overflow are different conditions.

Your choice applies to this browser. Change it any time using the footer.