190 likes | 198 Views
This lecture covers topics like false path cycles, multi-operand addition, carry save addition, and multiplication algorithms and hardware design.
E N D
CSE 246: Computer Arithmetic Algorithms and Hardware Design Lecture 5 Instructor: Prof. Chung-Kuan Cheng
Topics: • False Path: Cycles • Multi-Operands Addition • Carry Save Addition • Multiplication • 2’s Complement • Booth Recoding
False Path: Cycles • Cycles of False Paths: Eg. 1’s complement number addition Positive: x Negative: (2n-1)-x • Addition (2n-1)-x + (2n-1)-y = 2n+(2n-1)-(x+y)-1 A3,0 B3,0 Cout Cin Adder S3,0
Example • 0+0=0 11111 0 + 11111 0 111110 111111 0 • -3-5 = -8 11100 -3 + 11010 -5 110110 110111 -8
Multi-Operand Addition • Carry save adder: a (3,2) counter
Example • A (3,2) counter compresses X rows to 2/3X rows each time • Tree structure in implementation
Other Counters • (7,3) counter • (5,3) counter S1 Ca Cb S0 S2 S0 • Design of (5,3) counter using full adders Ca Cb S0 Ca Cb S0
Multiplication • Examples 0101 5 * 0110 6 0000 0101 0101 0000 0011110 30 0101 5 * 1010 -6 0000 0101 0101 1011 1100010 -30 2’s complement of -5
Multiplication • Examples (Cont.) 1011 -5 * 0110 6 0000 111011 11011 0000 11100010 -30 1011 -5 * 1010 -6 0000 111011 00000 0101 10011110 30 2’s complement of 5 Sign bits
Multiplication a3 a2 a1 a0 *b3 b2 b1 b0 -a3b0 a2b0 a1b0 a0b0 -a3b1 a2b1 a1b1 a0b1 -a3b2 a2b2 a1b2 a0b2 a3b3 -a2b3 -a1b3 -a0b3 • Traditional multiplication of negative numbers
Multiplication a3 a2 a1 a0 *b3 b2 b1 b0 a3b0 a2b0 a1b0 a0b0 a3b1 a2b1 a1b1 a0b1 a3b2 a2b2 a1b2 a0b2 a3b3 a2b3 a1b3 a0b3 0 -a3 -a3 -a3 0 -a2 -a1 -a0 • -xy = x(1-y)-x = xy-x
Multiplication a3 a2 a1 a0 *b3 b2 b1 b0 a3b0 a2b0 a1b0 a0b0 a3b1 a2b1 a1b1 a0b1 a3b2 a2b2 a1b2 a0b2 a3b3 a2b3 a1b3 a0b3 0 -a3 -a3 -a3 0 -b3 -b3 -b3 • -xy = xy-x = xy-y
Multiplication a3 a2 a1 a0 *b3 b2 b1 b0 a3b0 a2b0 a1b0 a0b0 a3b1 a2b1 a1b1 a0b1 a3b2 a2b2 a1b2 a0b2 a3b3 a2b3 a1b3 a0b3 a3 0 0 a3 b3 0 0 b3 -1 -1 • Replay 0 -a -a -a by a 0 0 a -1 -1
Multiplication a3 a2 a1 a0 *b3 b2 b1 b0 a3b0 a2b0 a1b0 a0b0 a3b1 a2b1 a1b1 a0b1 a3b2 a2b2 a1b2 a0b2 a3b3 a2b3 a1b3 a0b3 a3 0 0 a3 -1 b3 0 0 b3 • Fast multiplication: we avoid calculating the 2’s complement of multiplicand, which means a potential long carry chain
Booth Recoding • Multiplication: n rows by 2n-1 column matrix for addition • Objective: try to reduce n rows to logn rows • Radix 2 booth recoding • Radix 4 booth recoding
Radix 2 Booth Recoding • Use 1,0,-1 to recode • Recoding table
Example 1 0 1 1 1 0 1 0 1 0 -1 1 0 0 -1 1 -1 1 -1 Assume here is 0 x5 x4 x3 x2 x1 -x5 x4 -x4 x3 -x3 x2 -x2 x1 -x1 x4-x5 x3-x4 x2-x3 x1-x2 0-x1 y5 y4 y3 y2 y1
Radix 4 Booth Recoding • Use 2,1,0,-1,-2 to recode (zi/2=2yi+1+yi)
Examples Bin 0 1 , 1 1 , 1 1 0 31 Radix 4: 2 , 0 , -1 2*42-1 = 31 2x6 2x4 2x2 x5 x3 x1 -2x6+x5+x4 -2x4+x3+x2 -2x2+x1+x0 x6 x5 x4 x3 x2 x1 x0