100 likes | 118 Views
Lecture 2 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 2 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
Propagate and GenerateCarry-Lookahead ci+1 = xiyi + (xi+yi)ci= gi + pici = gi + pi (gi-1 + pi-1ci-1) = gi + pigi-1 + pipi-1gi-2 + …+ pipi-1 …p2p1g0 + pipi-1…p1p0c0 For instance, c1 = g0 + p0c0 c2 = g1 + p1g0 + p1p0c0
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
A Multiplier Array and adder
Array of Adders for Unsigned Multiplication 4-bit example