carry · · · 0 0 1 1 0 6 + 0 1 1 1 + 7 = · · · ·carry out ·carry · · 0 0 0 1 1 0 6 + 0 1 1 1 + 7 = · · · 1carry out ·carry · 1 0 0 0 1 1 0 6 + 0 1 1 1 + 7 = · · 0 1carry out ·carry 1 1 0 0 0 1 1 0 6 + 0 1 1 1 + 7 = · 1 0 1carry out ·carry 1 1 0 0 0 1 1 0 6 + 0 1 1 1 + 7 = 1 1 0 1 13carry out 0carry · · · 0 1 0 0 1 9 + 1 0 0 1 + 9 = · · · ·carry out ·carry · · 1 0 1 0 0 1 9 + 1 0 0 1 + 9 = · · · 0carry out ·carry · 0 1 0 1 0 0 1 9 + 1 0 0 1 + 9 = · · 1 0carry out ·carry 0 0 1 0 1 0 0 1 9 + 1 0 0 1 + 9 = · 0 1 0carry out ·carry 0 0 1 0 1 0 0 1 9 + 1 0 0 1 + 9 = 0 0 1 0 2carry out 1 (lost)A0B0S0A1B1S1A2B2S2A3B3S3CinCout010101010101010101?FA3FA2FA1FA00101?01?01?01?0101010101
Lit wire with moving dashes: it carries a 1Lamps and carry tokens: glowing = 1, dark = 0, ? = not worked out yetFA block: one full adder (A + B + carry-in → sum, carry-out)Paper card: the same sum done by handFour full adders in a row add two 4-bit numbers. Each adder's carry-out is wired to the next adder's carry-in, so the carry token travels right to left, one adder at a time. An N-bit ripple-carry adder is N full adders in a chain, each carry-out feeding the next carry-in. Its delay grows with N: t = N × t_FA, where t_FA is the delay of one full adder (Harris and Harris, section 5.2.1). Carry-lookahead and prefix adders are the faster designs Harris and Harris describe for wide adders: they compute carries from generate (A and B) and propagate (A or B) signals for groups of bits instead of waiting for each stage. Even the 4-bit SN74HC283 chip uses look-ahead carry logic inside. With 4 bits the largest unsigned number is 1111 = 15. 9 + 9 = 18 = 10010 needs five bits; keeping the low four leaves 0010 = 2, and the carry-out of 1 (worth 16) is the sign that the result overflowed (Harris and Harris, section 1.4).

Column addition

  1. Each lamp is one bit: lit is 1, dark is 0. From the right, the columns are worth one, two, four and eight. So A = 0110 is 4 + 2 = 6 and B = 0111 is 4 + 2 + 1 = 7.

The carry ripples

Speed and limits

Column by column

;; step 1/10 · six-plus-seven
;; about: On paper, Eights column, Fours column, Twos column, Ones column
A = 0110 = 0·8 + 1·4 + 1·2 + 0·1 = 6
B = 0111 = 0·8 + 1·4 + 1·2 + 1·1 = 7

On paper we add binary numbers like
decimal ones: column by column from
the right, carrying when a column
has more than one 1 to write down.

In a real chip each bit is a high or low voltage on a wire; here a glowing lamp or token shows a 1. A lit wire with moving dashes carries a 1. In Python, (a >> i) & 1 reads bit i of a, and ^, & and | on the numbers 0 and 1 work as XOR, AND and OR. Python's own integers never overflow: the 4-bit limit here is the size of the circuit, not of Python.