Introduction

Adders are the core combinational blocks of arithmetic. A half adder adds two bits; a full adder adds three bits (two operands and a carry-in). Chaining full adders yields a ripple-carry adder (RCA); carry-lookahead (CLA) computes the carries in parallel to cut the delay. Two's-complement subtraction is addition of the bitwise complement with carry-in 1, so one circuit with a mode line both adds and subtracts.

GATE asks for gate-level equations, gate and delay counts under a stated gate model, carry-lookahead expressions, and the overflow and carry flags of a result.

Prerequisites

Core concepts

Half adder

Inputs a,ba,b; outputs sum=a⊕b\textit{sum}=a\oplus b, carry=ab\textit{carry}=ab. One XOR and one AND.

Full adder

Inputs a,b,cina,b,c_{\mathrm{in}}; outputs

s=a⊕b⊕cin,cout=ab+bcin+acin.\begin{aligned} s &= a\oplus b\oplus c_{\mathrm{in}},\\ c_{\mathrm{out}} &= ab + bc_{\mathrm{in}} + ac_{\mathrm{in}}. \end{aligned}

Equivalently cout=ab+(a⊕b)cinc_{\mathrm{out}} = ab + (a\oplus b)c_{\mathrm{in}} with generate g=abg=ab and propagate p=a⊕bp=a\oplus b.

aabbcinc_{\mathrm{in}}coutc_{\mathrm{out}}ss
00000
00101
01001
01110
10001
10110
11010
11111

ss is the odd-parity function and coutc_{\mathrm{out}} the majority function of the three inputs; the pair (cout,s)(c_{\mathrm{out}}, s) is the 2-bit binary count of 1s among a,b,cina, b, c_{\mathrm{in}}.

Two half adders and an OR. The first half adder gives p=a⊕bp = a \oplus b and g=abg = ab; the second adds cinc_{\mathrm{in}}: s=p⊕cins = p \oplus c_{\mathrm{in}} and carry p cinp\,c_{\mathrm{in}}. Then cout=g+p cinc_{\mathrm{out}} = g + p\,c_{\mathrm{in}}. The OR never sees two 1s, because g=1g = 1 forces p=0p = 0. Totals: 2 XOR, 2 AND, 1 OR. A full adder can also be built from 9 two-input NAND gates (the 4-NAND XOR used twice, with the shared NANDs reused for the carry).

Half and full subtractor

A full subtractor computes a−b−bina - b - b_{\mathrm{in}}: difference D=a⊕b⊕binD = a \oplus b \oplus b_{\mathrm{in}} (the same as the sum) and borrow out

bout=a′b+a′bin+b bin.b_{\mathrm{out}} = a'b + a'b_{\mathrm{in}} + b\,b_{\mathrm{in}} .

The borrow is the full-adder carry with aa complemented. The half subtractor is D=a⊕bD = a \oplus b, bout=a′bb_{\mathrm{out}} = a'b.

Ripple-carry adder

nn full adders; c0=0c_0=0 for addition; the carry out of stage ii is the carry into stage i+1i + 1. Worst-case delay grows as Θ(n)\Theta(n) because the carry must pass through every stage: adding 0111⋯1+0000⋯10111\cdots1 + 0000\cdots1 propagates a carry from bit 0 to bit n−1n - 1.

Carry-lookahead

Define gi=aibig_i = a_i b_i, pi=ai⊕bip_i = a_i \oplus b_i (XOR form). Then ci+1=gi+picic_{i+1} = g_i + p_i c_i. Unrolling for a 4-bit block:

c1=g0+p0c0,c2=g1+p1g0+p1p0c0,c3=g2+p2g1+p2p1g0+p2p1p0c0,c4=g3+p3g2+p3p2g1+p3p2p1g0+p3p2p1p0c0.\begin{aligned} c_1 &= g_0 + p_0 c_0,\\ c_2 &= g_1 + p_1 g_0 + p_1 p_0 c_0,\\ c_3 &= g_2 + p_2 g_1 + p_2 p_1 g_0 + p_2 p_1 p_0 c_0,\\ c_4 &= g_3 + p_3 g_2 + p_3 p_2 g_1 + p_3 p_2 p_1 g_0 + p_3 p_2 p_1 p_0 c_0 . \end{aligned}

Every carry is a two-level AND-OR of the gig_i, pip_i and c0c_0, so all four are available at the same time. The cost is fan-in: c4c_4 needs a 5-input AND and a 5-input OR. For a 4-bit block the lookahead unit uses 1+2+3+4=101 + 2 + 3 + 4 = 10 AND gates and 4 OR gates.

Group generate and propagate. A 4-bit block also outputs

G=g3+p3g2+p3p2g1+p3p2p1g0,P=p3p2p1p0,G = g_3 + p_3 g_2 + p_3 p_2 g_1 + p_3 p_2 p_1 g_0,\qquad P = p_3 p_2 p_1 p_0,

so that c4=G+Pc0c_4 = G + P c_0. G=1G = 1 means the block creates a carry by itself; P=1P = 1 means it passes an incoming carry through. A second-level lookahead unit combines block (G,P)(G, P) pairs with the same equations, giving O(log⁡n)O(\log n) delay for nn bits.

Adder-subtractor

Two's-complement subtract A−BA-B: feed B‾\overline{B} to the adder and set c0=1c_0=1. With a mode line MM (0 add, 1 subtract), each adder input is bi⊕Mb_i \oplus M and c0=Mc_0 = M. The signed overflow flag is V=cn⊕cn−1V = c_n \oplus c_{n-1}; the carry flag is cnc_n, and in subtraction cn=0c_n = 0 signals an unsigned borrow (A<BA < B).

Half adder and full adder gate-level circuits
Figure 1. Half adder (XOR and AND) and full adder built from two half adders plus an OR, with sum and carry-out labelled.
Ripple-carry versus carry-lookahead structure
Figure 2. Top: 4-bit ripple-carry chain. Bottom: 4-bit lookahead computing c1..c4c_1..c_4 from gi,pi,c0g_i,p_i,c_0 in parallel.

How it works

Delay model

Gate-delay convention used in this note. Every two-input or multi-input AND, OR and XOR gate costs 1 unit; inputs ai,bi,c0a_i, b_i, c_0 arrive at time 0. Other delay models are also used (for example 2 units per carry stage); always rebuild the count from the model in the stem.

Ripple-carry. pip_i and gig_i are ready at 1. Stage ii computes ci+1=gi+picic_{i+1} = g_i + p_i c_i with an AND then an OR, so the carry advances 2 units per stage after the first: c1c_1 at 3, c2c_2 at 5, and in general

ci at 2i+1,si=pi⊕ci at 2i+2 (i≥1),c_i \text{ at } 2i + 1,\qquad s_i = p_i \oplus c_i \text{ at } 2i + 2 \ (i \ge 1),

with s0s_0 at 2. For n=4n = 4: s3s_3 at 8 and c4c_4 at 9. For n=16n = 16: s15s_{15} at 32 and c16c_{16} at 33.

Carry-lookahead, 4 bits. gi,pig_i, p_i at 1, every carry c1c_1 to c4c_4 at 3 (one AND level, one OR level), every sum at 4. The delay does not grow with the bit position inside the block.

16 bits from four 4-bit CLA blocks, carries rippling between blocks. Inside each block GG is ready at 3 and PP at 2. The block carry-outs are c4c_4 at 4, c8c_8 at 6, c12c_{12} at 8 and c16c_{16} at 10 (2 units per block). The last block computes c15c_{15} from c12c_{12} at 10, so s15s_{15} is ready at 11. Compare 32 for the 16-bit ripple adder.

Overflow

For signed two's complement, overflow =cn⊕cn−1= c_n \oplus c_{n-1} (carry into sign XOR carry out of sign), as in Signed Number Representation.

Algorithms and pseudocode

Arrays are 0-indexed from the LSB; <- is assignment.

Text
FULL-ADDER(a, b, cin)
1  s <- a XOR b XOR cin
2  cout <- (a AND b) OR (b AND cin) OR (a AND cin)
3  return (s, cout)

RIPPLE-ADD(A[0..n-1], B[0..n-1], c0)
1  c <- c0
2  for i <- 0 to n-1
3      (S[i], c) <- FULL-ADDER(A[i], B[i], c)
4  return (S, c)

CLA-CARRIES(g[0..n-1], p[0..n-1], c0)
1  c[0] <- c0
2  for i <- 0 to n-1
3      c[i+1] <- g[i] OR (p[i] AND c[i])   // hardware unrolls this
4  return c

ADD-SUB(A, B, M, n)                       // M = 0 add, M = 1 subtract
1  for i <- 0 to n-1: B'[i] <- B[i] XOR M
2  (S, cn) <- RIPPLE-ADD(A, B', M)
3  V <- (NOT (A[n-1] XOR B'[n-1])) AND (A[n-1] XOR S[n-1])
4  return (S, cn, V)

RIPPLE-ADD uses nn full adders and Θ(n)\Theta(n) delay. A one-level CLA over nn bits uses Θ(n2)\Theta(n^2) AND gates of fan-in up to n+1n + 1 for constant delay; a tree of 4-bit lookahead units uses Θ(n)\Theta(n) gates and Θ(log⁡n)\Theta(\log n) delay.

Mathematical explanation

Unrolling ci+1=gi+picic_{i+1}=g_i + p_i c_i gives

ck=gk−1+pk−1gk−2+⋯+(pk−1⋯p0)c0=∑j=−1k−1(∏i=j+1k−1pi)gj,c_{k}=g_{k-1}+p_{k-1}g_{k-2}+\cdots+(p_{k-1}\cdots p_0)c_0 = \sum_{j=-1}^{k-1}\Big(\prod_{i=j+1}^{k-1} p_i\Big) g_j,

with the convention g−1=c0g_{-1} = c_0. In words: there is a carry into position kk exactly when some position j<kj < k generates one and every position between jj and kk propagates it.

Propagate variants. Some texts use pi=ai+bip_i = a_i + b_i (OR) for the carry chain. The carry equation still holds, because the two definitions differ only when ai=bi=1a_i = b_i = 1, and then gi=1g_i = 1 already. The sum, however, needs the XOR form: si=(ai⊕bi)⊕cis_i = (a_i \oplus b_i) \oplus c_i, not (ai+bi)⊕ci(a_i + b_i) \oplus c_i.

Subtraction correctness. A+B‾+1=A+(2n−1−B)+1=A−B+2nA + \overline{B} + 1 = A + (2^n - 1 - B) + 1 = A - B + 2^n, which is A−BA - B modulo 2n2^n. The extra 2n2^n is the carry out: it is 1 exactly when A≥BA \ge B as unsigned numbers.

Array multiplier sizing. A combinational multiplier for a JJ-bit multiplier and KK-bit multiplicand forms J⋅KJ \cdot K partial-product bits with AND gates and adds them with J−1J - 1 adders of KK bits each, producing a J+KJ + K-bit product. For K=4K=4 multiplicand bits and J=3J=3 multiplier bits: 12 AND gates, two 4-bit adders, a 7-bit product (15⋅7=105<12815 \cdot 7 = 105 < 128).

Worked examples

Example 1: full-adder truth

For a=1,b=1,cin=1a=1,b=1,c_{\mathrm{in}}=1: s=1s=1, cout=1c_{\mathrm{out}}=1 (total 3).

Example 2: 4-bit RCA 0101+01100101+0110

From the LSB: bit 0 gives s0=1s_0 = 1, carry 0; bit 1 gives s1=1s_1 = 1, carry 0; bit 2 gives s2=0s_2 = 0, carry 1; bit 3 gives s3=1s_3 = 1, carry 0. The pattern is 10111011, which is 11 unsigned and correct; as signed 4-bit it is −5-5, and V=c4⊕c3=0⊕1=1V = c_4 \oplus c_3 = 0 \oplus 1 = 1 flags the overflow of 5+65+6.

Example 3: subtract 7−37-3 and 3−73 - 7 as additions

  • A=0111A=0111, B=0011B=0011, B‾=1100\overline{B}=1100, c0=1c_0=1: 0111+1100+1=1 01000111+1100+1 = 1\,0100. The result is 0100=40100 = 4 with carry out 1 (no borrow).
  • A=0011A = 0011, B=0111B = 0111, B‾=1000\overline{B} = 1000: 0011+1000+1=0 11000011 + 1000 + 1 = 0\,1100. The result is 1100=−41100 = -4 with carry out 0, the unsigned borrow; V=0V = 0 because −4-4 is in range.

Example 4: lookahead values

For A=1011A = 1011, B=0110B = 0110, c0=0c_0 = 0: g=A∧B=0010g = A \wedge B = 0010 and p=A⊕B=1101p = A \oplus B = 1101 (bit 3 on the left). Then c1=g0=0c_1 = g_0 = 0; c2=g1+p1g0=1c_2 = g_1 + p_1 g_0 = 1; c3=g2+p2g1+⋯=0+1⋅1=1c_3 = g_2 + p_2 g_1 + \cdots = 0 + 1\cdot 1 = 1; c4=g3+p3g2+p3p2g1+⋯=0+0+1⋅1⋅1=1c_4 = g_3 + p_3 g_2 + p_3 p_2 g_1 + \cdots = 0 + 0 + 1\cdot 1\cdot 1 = 1. Sums si=pi⊕cis_i = p_i \oplus c_i give 00010001 with c4=1c_4 = 1: 11+6=17=1 0001211 + 6 = 17 = 1\,0001_2. Group signals: P=p3p2p1p0=0P = p_3p_2p_1p_0 = 0 and G=1G = 1.

Example 5: delay comparison

With the 1-unit gate model above, a 16-bit RCA needs 33 units for c16c_{16} and 32 for s15s_{15}. Four 4-bit CLA blocks with rippling block carries give s15s_{15} at 11. A single 16-bit two-level lookahead would be faster still (all carries at 3) but needs a 17-input AND and OR for c16c_{16}, which is why hierarchical lookahead is used. Answers claiming "CLA is always two gate delays for any nn" ignore fan-in.

Example 6: BCD digit add

Add 4-bit BCD digits as binary. If the sum exceeds 9 or the 4-bit addition carries out, add 01100110 and produce a decimal carry. Example: 0110+0101=10110110+0101=1011 (11); adding 01100110 gives 1 00011\,0001: digit 1 with a decimal carry, that is 0001 0001BCD=110001\,0001_{\text{BCD}} = 11. Details are in the Binary Codes note.

Important properties and observations

  • The full-adder carry is the majority function and its sum is three-input parity; in the two-half-adder build, the final OR can be an XOR.
  • Propagate definition variants: p=a+bp = a + b serves the carry chain; only p=a⊕bp = a \oplus b also gives the sum.
  • Serial adder: one full adder plus a carry flip-flop, one bit per clock, nn cycles for nn bits; sequential, see the Registers and Counters note.
  • BCD adder: binary add then +6+6 correction when the digit sum exceeds 9.
  • Incrementer: an adder with B=0B = 0 and c0=1c_0 = 1 reduces to a chain of half adders.

Common misconceptions.

  • "Carry-lookahead eliminates all delay dependence on nn." Only inside limited fan-in; asymptotically O(log⁡n)O(\log n) with trees.
  • "Overflow bit is cnc_n." That is unsigned carry; signed overflow needs cn⊕cn−1c_n\oplus c_{n-1}.
  • "In subtraction a carry out means something went wrong." With A+B‾+1A + \overline{B} + 1, carry out 1 means no borrow (A≥BA \ge B unsigned).
  • "The full subtractor borrow equals the full adder carry." It is the carry with aa complemented.
  • "Delay is the same in every model." Stage delays of 2 per bit, or XOR counted as 2 levels, change every number; follow the stem.

GATE examination perspective

  • WRITE ss AND coutc_{\mathrm{out}}. Memorise XOR and majority forms, and the borrow form for subtractors.
  • RCA VS CLA DELAY. Linear versus lookahead; rebuild arrival times from the stated gate delays and fan-in.
  • UNROLL A CARRY. Expand c3c_3 or c4c_4 in gi,pi,c0g_i, p_i, c_0; count its AND gates and their fan-in.
  • BLOCK CLA. Group GG and PP; rippling between blocks costs 2 levels per block in the 1-unit model.
  • SUBTRACT CONTROL. XOR with Add/Sub\textit{Add}/\textit{Sub} on BB and tie to c0c_0.
  • FLAGS. V=cn⊕cn−1V = c_n \oplus c_{n-1}; C=cnC = c_n; in subtraction C=0C = 0 means borrow.
  • MULTIPLIER SIZE. J⋅KJ \cdot K ANDs, J−1J - 1 adders of KK bits, J+KJ + K product bits.

Summary

Sources

  1. M. Morris Mano, M. D. Ciletti, Digital Design, 5th ed., Pearson, 2013: Chapter 4, Sections 4.5 (binary adder-subtractor, including carry propagation and lookahead), 4.6 (decimal adder) and 4.7 (binary multiplier).

Next steps