100 likes | 244 Views
CS 140 Lecture 14. Professor CK Cheng 11/14/02. Part II. Standard Modules. Interconnect Operators. Adders Multiplier Adders 1. Representation of numbers 2. Full Adder 3. Half Adder 4. Carry Look Ahead Adder. 1. Representation. id 0 1 2 3 4 5 6 7 8. Sign magnitude 1000
E N D
CS 140 Lecture 14 Professor CK Cheng 11/14/02
Part II. Standard Modules • Interconnect • Operators. Adders Multiplier • Adders 1. Representation of numbers • 2. Full Adder • 3. Half Adder • 4. Carry Look Ahead Adder
1. Representation id 0 1 2 3 4 5 6 7 8 Sign magnitude 1000 1001 1010 1011 1100 1101 1110 1111 2s Compliment 0000 1111 1110 1101 1100 1011 1010 1001 1000 4 bit 0000 0001 0010 0011 0100 0101 0110 0111 1s Compliment 1111 1110 1101 1100 1011 1010 1001 1000
Examples 2 + 3 = 5 0 0 1 0 + 0 0 1 1 0 1 0 1 2 - 3 = -1 (1’s) 0 0 1 0 + 1 1 0 0 1 1 1 0 -2 - 3 = -5 (2’s) 1 1 1 0 + 1 1 0 1 1 0 1 1 -2 - 3 = -5 (1’s) 1 1 1 0 + 1 1 0 0 1 0 0 1 2 - 3 = -1 (2’s) 0 0 1 0 + 1 1 0 1 1 1 1 1 Checking for overflow -3 + -5 = -8 1 1 0 1 + 1 0 1 1 1 0 0 0 1 1 1 1 C5C4 3 + 5 = 8 0 0 1 1 + 0 1 0 1 1 0 0 0 1 1 1 C5C4
b b’ a C4 MUX overflow minus C3 Adder Cout Sum
2. Full Adder a b cin sum = a + b + cin cout = ab + a cin + b cin = ab + (a + b)cin FA Sum cout a + b = a + b if ab = 0 a + b + ab = a + b + ab c 0 0 0 0 a 0 0 1 1 b
Id a b cin carry sum 0 0 0 0 0 0 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 1 0 4 1 0 0 0 1 5 1 0 1 1 0 6 1 1 0 1 0 7 1 1 1 1 1 Sum = a + b + Cin Cout = ab + aCin + bCin
3. Half Adder a b Sum = ab’ + a’b = a + b Cout = ab HA Sum cout a b Cout a b Cout sum 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 Sum
x cout carryout HA a OR sum a + b b HA sum cin
4. Carry Look Ahead Adder C1 = a0b0 + (a0+b0)c0 = q0 + p0c0 C2 = a1b1 + (a1+b1)c1 = q1 + p1c1 = q1 + p1q0 + p1p0c0 C3 = a2b2 + (a2+b2)c2 = q2 + p2c2 = q2 + p2q1 + p2p1q0 + p2p1p0c0 C4 = a3b3 + (a3+b3)c3 = q3 + p3c3 = q3 + p3q2 + p3p2q1 + p3p2p1q0 + p3p2p1p0c0 qi = aibi pi = ai + bi a3 b3 a2 b2 a1 b1 a0 b0 q3 p3 q2 p2 q1 p1 q0 p0 c0 c4 c3 c2 c1