130 likes | 355 Views
Lecture Adders. Half adder. Full Adder. si is the modulo-2 sum of ci, xi, yi. An n-bit Ripple Adder. Yn-1. Xn-1. Y0. X0. ………. Cn. FA. Cn-1. C1. FA. C0. Sn-1. S0. MSB. LSB. y. y. y. Adder/subtractor. n. –. 1. 1. 0. ¤. Add. Sub. control. x. x. x. n. –. 1. 1.
E N D
Lecture Adders • Half adder
Full Adder si is the modulo-2 sum of ci, xi, yi.
An n-bit Ripple Adder Yn-1 Xn-1 Y0 X0 ……… Cn FA Cn-1 C1 FA C0 Sn-1 S0 MSB LSB
y y y Adder/subtractor n – 1 1 0 ¤ Add Sub control x x x n – 1 1 0 • - = add 2’s complement of the subtrahend • y xor 0 = y; y xor 1 = ~y c c n -bit adder 0 n s s s n – 1 1 0
Overflow v.s. Carry-out • n-bit signed number: -2n-1 to 2n-1 -1 Detect overflow for signed number: Overflow = Cn-1⊕ Cn Overflow = Xn-1 Yn-1 ~Sn-1 (110) + ~Xn-1 ~Yn-1 Sn-1 (001) where X and Y represent the 2’s complement numbers, S = X+Y. (sign bits 0, 0 ≠ 1 ) 0111 0111 1111 Carry-out: for unsigned number
x y x y 1 1 0 0 Propagate and Generateripple carry g p g p 1 1 0 0 c 1 c c • ci+1 = xiyi + (xi+yi)ci= gi + pici • A ripple-carry adder: critical path = 2n + 1 0 2 Stage 1 Stage 0 s s 1 0
Carry-lookahead adder • Motivation: • If we didn't know the value of carry-in, what could we do? • When would we always generate a carry? gi is true. gi = ai bi • When would we propagate the carry? pi is true. pi = ai + bi ci+1 = (bi.ci)+(ai.ci) +(ai.bi) = (ai.bi) + (ai+ bi) .ci c2 = g1 + p1 . c1 c3 = g2 + p2 . c2 c4 is computed once inputs (a0-a3, b0 to b3, and c0) are valid.
x y x y 1 1 0 0 Propagate and GenerateCarry-Lookahead x y 0 0 g p g p 1 1 0 0 c1 = g0 + p0c0 c2 = g1 + p1g0 + p1p0c0 3 gate delays c 0 c 2 c 1 D1 s s 1 0 D2 D3
Hierarchical CLA: Build a 16-bit adder using a block of 4-bit CLA. x y x y x y – – 7 – 4 7 – 4 3 – 0 3 – 0 15 12 15 12 • Instead of producing the a carry-out from the most significant bit of the block, each block produces the generate and propagate signal for the entire block. • For block 0, looking into c4, if all the 4 propagate functions are 1, then the carry-in c0 is propagated through the entire block, hence P0 = p3.p2.p1.p0, the rest in c4 represents the cases when this block produces a carry-out with generates, thus G0 = g3 + p3.g2 + p3.p2.g1 + p3.p2.p1.g0 So, c4 = G0 + P0.c0 Block Block Block c 0 3 1 0 c 12 G P G P G P 3 3 1 1 0 0 s s s 15 – 12 7 – 4 3 – 0 c c c 16 8 4 Second-level lookahead
Second Level Equation • The same principle as in the first level is used in the second level. • The result of the second level is computed as soon as its inputs are valid. c4 = G0 + (P0.c0) c8 = G1 + (P1.G0) + (P1.P0.c0) c12 = G2 + (P2.G1) + (P2.P1.G0) +(P2.P1.P0.c0) c16 = G3 + (P3.G2) +(P3.P2.G1) + (P3.P2.P1.G0) +(P3.P2.P1.P0.c0) In block 0
A Multiplier Array and adder
Array of Adders for Unsigned Multiplication 4-bit example