3.3.2Combinational Circuits

Ripple-carry adder

2,039 words9 min readdifficulty · medium6 backlinks

WHAT is it?

The building block is the full adder (FA): a circuit that adds three single bits aa, bb, cinc_{in} and outputs a sum bit ss and a carry-out bit coutc_{out}.


WHY does it work? (Derive the full adder from scratch)

We want to add three bits: aa, bb, and cinc_{in}. Their arithmetic sum ranges from 00 (all zero) to 33 (all one). In binary, values 0..30..3 need two output bits:

a+b+cin=2cout+sa + b + c_{in} = 2\cdot c_{out} + s

Here coutc_{out} is the "twos place" and ss is the "ones place". Let's build the truth table and derive each output.

aa bb cinc_{in} sum(dec) coutc_{out} ss
0 0 0 0 0 0
0 0 1 1 0 1
0 1 0 1 0 1
0 1 1 2 1 0
1 0 0 1 0 1
1 0 1 2 1 0
1 1 0 2 1 0
1 1 1 3 1 1

Deriving ss (WHY XOR?): s=1s=1 exactly when the number of 1s among the three inputs is odd. "Odd parity" is precisely what XOR computes.

s=abcins = a \oplus b \oplus c_{in}

Deriving coutc_{out} (WHY majority?): cout=1c_{out}=1 when the sum is 2\ge 2, i.e. when at least two of the inputs are 1. That is the majority function:

cout=ab+bcin+acinc_{out} = ab + b\,c_{in} + a\,c_{in}

We can simplify using the already-computed p=abp = a\oplus b: the carry is produced if both a,ba,b are 1 (generate), or if exactly one of them is 1 and cin=1c_{in}=1 (propagate):

cout=abgenerate+(ab)propagatecinc_{out} = \underbrace{ab}_{\text{generate}} + \underbrace{(a\oplus b)}_{\text{propagate}}\,c_{in}


HOW to build the n-bit adder

Chain nn full adders. Feed the ii-th bits Ai,BiA_i, B_i and the carry from below CiC_i into FAi_i; take out SiS_i and Ci+1C_{i+1}:

Si=AiBiCi,Ci+1=AiBi+(AiBi)CiS_i = A_i \oplus B_i \oplus C_i, \qquad C_{i+1} = A_i B_i + (A_i\oplus B_i)C_i

with C0C_0 as the overall carry-in, and CnC_n the final carry-out.

Figure — Ripple-carry adder

Timing / cost analysis (the 80/20 that matters)

Let one full adder's carry path take delay tct_c. Since carry ripples through all nn stages:

TRCAntcO(n) delayT_{\text{RCA}} \approx n\cdot t_c \quad\Rightarrow\quad \boxed{O(n)\ \text{delay}}

Hardware cost: nn full adders O(n) gates\Rightarrow \boxed{O(n)\ \text{gates}} — cheap and regular, but slow for large nn. This slowness is exactly why faster schemes (carry-lookahead) exist.



Flashcards

What single-bit block is an nn-bit ripple-carry adder built from?
nn cascaded full adders, carry-out of each feeding carry-in of the next.
Full adder sum expression?
s=abcins = a \oplus b \oplus c_{in} (odd-parity / XOR of the three bits).
Full adder carry-out expression?
cout=ab+bcin+acin=ab+(ab)cinc_{out} = ab + bc_{in} + ac_{in} = ab + (a\oplus b)c_{in} (majority function).
Why is coutc_{out} the majority function, not XOR?
Carry appears when the arithmetic sum 2\ge 2, i.e. at least two inputs are 1 — that is majority, not odd-parity.
Worst-case delay of an nn-bit RCA?
O(n)O(n), about ntcn\cdot t_c, because the carry must ripple serially through every stage.
Gate/area cost of an nn-bit RCA?
O(n)O(n) — one full adder per bit; cheap and regular.
How do you turn an RCA into a subtractor for ABA-B?
Invert each bit of BB and set C0=1C_0=1 (adds the two's complement of BB).
Signed overflow condition in two's complement?
CnCn1C_n \oplus C_{n-1} (carry into MSB \ne carry out of MSB).
What is "generate" vs "propagate"?
Generate =ab=ab (stage makes a carry itself); propagate =ab=a\oplus b (stage passes an incoming carry through).
Main drawback of RCA?
Speed — linear carry-propagation delay makes it slow for wide words; motivates carry-lookahead.

Recall Feynman: explain to a 12-year-old

Imagine adding two long numbers on paper. You start from the right, add each column, and whenever a column adds up to 10 or more you carry a 1 into the next column. You can't finish the left columns until the carry from the right has traveled over. A ripple-carry adder is a row of tiny machines, one per digit (bit). Each machine adds its own two bits plus whatever carry arrives from its right neighbor, and hands its own carry to the left neighbor. The "carry" travels left like a wave — that's why it's called ripple. It's simple and cheap, but if the number is very long, you wait a while for the carry to walk all the way across.

Connections

  • Full adder — the repeated building block derived above.
  • Half adder — full adder = two half adders + an OR on the carries.
  • Carry-lookahead adder — fixes RCA's O(n)O(n) delay using generate/propagate signals.
  • Two's complement — enables subtraction reuse of the same adder.
  • Overflow detectionCnCn1C_n\oplus C_{n-1} for signed arithmetic.
  • Combinational circuits — RCA is a canonical example (no memory, output = f(inputs)).
  • Propagation delay — the timing concept that makes RCA slow.

Concept Map

needs

adds

sum equation

ones place

twos place

odd parity

at least two ones

split into

cascade n stages

carry-out to carry-in

carry ripples LSB to MSB

Add multi-bit binaries

Full adder

a b c_in

a+b+c_in = 2 c_out + s

Sum bit s

Carry-out c_out

XOR a XOR b XOR c_in

Majority function

Generate ab + Propagate a XOR b

n-bit ripple-carry adder

C_i to C_i+1

MSB valid last

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Socho tum paper pe do lambe numbers add kar rahe ho. Right side se shuru karte ho, har column add karte ho, aur jab column ka sum 10 ya usse zyada ho jaye to ek "carry" agle column me le jaate ho. Ripple-carry adder bilkul yahi kaam hardware me karta hai — bas binary me. Har bit ke liye ek chhota circuit hota hai jise full adder kehte hain, aur ye saare ek line me jude hote hain. Har full adder apne do bits aur neeche wale ka carry leta hai, apna sum banata hai aur apna carry upar (MSB ki taraf) bhej deta hai.

Full adder ke do formule yaad rakho, dono derive ho jaate hain truth table se. Sum wala part: S=ABCinS = A \oplus B \oplus C_{in} — matlab XOR, kyunki sum tab 1 hota hai jab 1s ki ginti odd ho. Carry wala part: Cout=AB+BCin+ACinC_{out} = AB + BC_{in} + AC_{in} — ye majority function hai, kyunki carry tab banta hai jab kam se kam do inputs 1 hon. Yahan students galti karte hain — carry ko bhi XOR samajh lete hain, jo galat hai. XOR "oddness" dekhta hai, carry "at least two" dekhta hai.

Ab problem kya hai? Carry ko ek-ek stage cross karna padta hai — LSB se MSB tak "ripple" hota hai. Isliye top bit ka answer tab tak ready nahi hota jab tak carry poore chain se guzar na jaye. Iska delay O(n)O(n) hota hai — matlab jitne zyada bits, utna zyada wait. Cost sasta aur design simple, par speed slow. Isi slowness ki wajah se carry-lookahead adder invent hua. Bonus: agar BB ke saare bits invert kar do aur C0=1C_0 = 1 set kar do, to yahi adder ABA - B (two's complement subtraction) bhi kar deta hai — same hardware, double kaam!

Go deeper — visual, from zero

Test yourself — Combinational Circuits

Connections