3.3.3Combinational Circuits

Carry-lookahead adder

1,903 words9 min readdifficulty · medium4 backlinks

WHY do we need it?

WHAT we exploit: For a single full adder at bit ii with inputs ai,bia_i, b_i and incoming carry cic_i:

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

Look at ci+1c_{i+1}. It becomes 1 in two ways:

  1. The bit generates a carry on its own: aibi=1a_i b_i = 1.
  2. The bit propagates an incoming carry: (aibi)ci=1(a_i \oplus b_i)\,c_i = 1.

Derivation from first principles

Substituting into the carry equation:

Now unroll the recursion to kill the dependence on the previous carry. Start with c0c_0 (the input carry):

c1=g0+p0c0c_1 = g_0 + p_0 c_0

c2=g1+p1c1=g1+p1(g0+p0c0)=g1+p1g0+p1p0c0c_2 = g_1 + p_1 c_1 = g_1 + p_1(g_0 + p_0 c_0) = g_1 + p_1 g_0 + p_1 p_0 c_0

c3=g2+p2c2=g2+p2g1+p2p1g0+p2p1p0c0c_3 = g_2 + p_2 c_2 = g_2 + p_2 g_1 + p_2 p_1 g_0 + p_2 p_1 p_0 c_0

The payoff: every ci+1c_{i+1} is now a 2-level AND-OR expression of the gg's, pp's and c0c_0. Since gi,pig_i, p_i are computed in 1 gate delay, all carries appear in a constant number of gate delays — independent of nn.


Figure — Carry-lookahead adder

Delay comparison


Worked examples


Common mistakes


Block-level (hierarchical) CLA


Flashcards

Why is ripple-carry slow?
Each carry waits serially for the previous one → O(n)O(n) delay (~2n2n gate delays, 2 per carry stage).
Define generate gig_i.
gi=aibig_i = a_i b_i: bit makes a carry regardless of incoming carry.
Define propagate pip_i.
pi=aibip_i = a_i \oplus b_i: bit passes an incoming carry through.
Recursive carry equation?
ci+1=gi+picic_{i+1} = g_i + p_i c_i.
Expanded c2c_2 in terms of inputs?
c2=g1+p1g0+p1p0c0c_2 = g_1 + p_1 g_0 + p_1 p_0 c_0.
Sum bit formula?
si=picis_i = p_i \oplus c_i.
Gate-delay of CLA vs ripple?
CLA ~constant (~4 levels); ripple ~2n2n (2 delays per carry stage).
Group propagate for 4-bit block?
P=p3p2p1p0P = p_3 p_2 p_1 p_0.
Group generate for 4-bit block?
G=g3+p3g2+p3p2g1+p3p2p1g0G = g_3 + p_3 g_2 + p_3 p_2 g_1 + p_3 p_2 p_1 g_0.
Main cost of wide CLA?
Large gate fan-in and gate count → solved by hierarchy.

Recall Feynman: explain to a 12-year-old

Imagine passing a note down a row of kids. Ripple-carry = each kid must receive the note before passing it, so the last kid waits a long time. CLA is smarter: before the game starts, each kid decides two things using only their own cards — "I'll definitely raise my hand (generate)" or "I'll copy whoever's below me (propagate)." Now a teacher looks at everyone's cards at once and instantly announces who raises their hand. No waiting in line!

Connections

  • Full Adder — the CLA reuses the same si=aibicis_i = a_i\oplus b_i\oplus c_i logic.
  • Ripple-Carry Adder — the slow baseline CLA improves on.
  • Boolean Algebra — unrolling the recursion is pure substitution + distributive law.
  • Carry-Save Adder — different speed trick (defer carries).
  • Propagation Delay & Fan-in — why hierarchy is needed in practice.
  • Prefix Adders (Kogge-Stone) — logarithmic-depth generalization of CLA.

Concept Map

serial dependency causes

motivates

defines

defines

combine into

combine into

unrolled by

yields

is implemented as

achieves

but fan-in limits force

Ripple-carry adder

O of n delay

Predict carries from inputs

Generate g_i equals a_i b_i

Propagate p_i equals a_i XOR b_i

Recursive carry c_i+1 equals g_i plus p_i c_i

Unroll recursion

Lookahead carry formula

2-level AND-OR logic

Constant gate delay ~4

4-bit CLA blocks hierarchical

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, normal ripple-carry adder mein har bit ka carry pichle bit ke carry ka wait karta hai — ek line mein bucket pass karne jaisa. Har carry stage do gate delays leta hai (pehle AND, phir OR), toh 64-bit ripple adder mein worst case around 2×64=1282\times64=128 gate delays lag jaate hain. Isliye jitne zyada bits, utni zyada delay (O(n)O(n)). Carry-lookahead adder is problem ko smartly solve karta hai: wo har bit ke liye do signals nikalta hai — generate gi=aibig_i = a_i b_i (bit khud carry banata hai) aur propagate pi=aibip_i = a_i \oplus b_i (bit neeche wale carry ko aage bhej deta hai). Ye dono sirf ai,bia_i, b_i pe depend karte hain, incoming carry pe nahi, toh instantly ready ho jaate hain.

Core formula hai ci+1=gi+picic_{i+1} = g_i + p_i c_i. Ab is recursion ko unroll kar do, toh har carry sirf gg's, pp's aur c0c_0 ke terms mein aa jaata hai — matlab har carry ek 2-level AND-OR expression ban jaata hai. Isliye saare carries ek saath, parallel mein compute ho jaate hain, chahe nn kitna bhi ho. Delay constant (~4 gate levels) ho jaati hai instead of 2n2n.

Iska matlab yeh nahi ki delay zero hai — CLA ka cost hai badi fan-in gates aur zyada hardware. Isliye real chips mein 4-bit CLA blocks banate hain, aur upar ek aur layer mein group generate GG aur group propagate PP use karke blocks ko jodte hain (hierarchical CLA). Ek chhota dhyan: sum bit ke liye hamesha pi=aibip_i = a_i \oplus b_i (XOR) use karo, warna si=picis_i = p_i \oplus c_i galat aayega. Speed chahiye toh CLA, area/simplicity chahiye toh ripple — yehi trade-off exam mein poochha jaata hai.

Go deeper — visual, from zero

Test yourself — Combinational Circuits

Connections