CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Lecture 5
CSE 2462 Topics: False Path: Cycles Multi-Operands Addition Carry Save Addition Multiplication 2 ’ s Complement Booth Recoding
CSE 2463 False Path: Cycles Cycles of False Paths: Eg. 1 ’ s complement number addition Positive: x Negative: (2 n -1)-x Addition (2 n -1)-x + (2 n -1)-y = 2 n +(2 n -1)-(x+y)-1 C out A 3,0 B 3,0 S 3,0 Adder C in
CSE 2464 Example -3-5 = 0+0=
CSE 2465 Multi-Operand Addition Carry save adder: a (3,2) counter
CSE 2466 Example A (3,2) counter compresses X rows to 2/3X rows each time Tree structure in implementation
CSE 2467 Other Counters (5,3) counter CaCa CbCb S0S0 (7,3) counter S0S0 S2S2 S1S1 Design of (5,3) counter using full adders CaCa CbCb S0S0 CaCa CbCb S0S0
CSE 2468 Multiplication Examples * * ’ s complement of -5
CSE 2469 Multiplication Examples (Cont.) * * ’ s complement of 5 Sign bits
CSE Multiplication a 3 a 2 a 1 a 0 * b 3 b 2 b 1 b 0 -a 3 b 0 a 2 b 0 a 1 b 0 a 0 b 0 -a 3 b 1 a 2 b 1 a 1 b 1 a 0 b 1 -a 3 b 2 a 2 b 2 a 1 b 2 a 0 b 2 a 3 b 3 -a 2 b 3 -a 1 b 3 -a 0 b 3 Traditional multiplication of negative numbers
CSE Multiplication a 3 a 2 a 1 a 0 * b 3 b 2 b 1 b 0 a 3 b 0 a 2 b 0 a 1 b 0 a 0 b 0 a 3 b 1 a 2 b 1 a 1 b 1 a 0 b 1 a 3 b 2 a 2 b 2 a 1 b 2 a 0 b 2 a 3 b 3 a 2 b 3 a 1 b 3 a 0 b 3 0 -a 3 -a 3 -a 3 0 -a 2 -a 1 -a 0 -xy = x(1-y)-x = xy-x
CSE Multiplication a 3 a 2 a 1 a 0 * b 3 b 2 b 1 b 0 a 3 b 0 a 2 b 0 a 1 b 0 a 0 b 0 a 3 b 1 a 2 b 1 a 1 b 1 a 0 b 1 a 3 b 2 a 2 b 2 a 1 b 2 a 0 b 2 a 3 b 3 a 2 b 3 a 1 b 3 a 0 b 3 0 -a 3 -a 3 -a 3 0 -b 3 -b 3 -b 3 -xy = xy-x = xy-y
CSE Multiplication a 3 a 2 a 1 a 0 * b 3 b 2 b 1 b 0 a 3 b 0 a 2 b 0 a 1 b 0 a 0 b 0 a 3 b 1 a 2 b 1 a 1 b 1 a 0 b 1 a 3 b 2 a 2 b 2 a 1 b 2 a 0 b 2 a 3 b 3 a 2 b 3 a 1 b 3 a 0 b 3 a a 3 b b 3 Replay 0 -a -a -a by a 0 0 a
CSE Multiplication a 3 a 2 a 1 a 0 * b 3 b 2 b 1 b 0 a 3 b 0 a 2 b 0 a 1 b 0 a 0 b 0 a 3 b 1 a 2 b 1 a 1 b 1 a 0 b 1 a 3 b 2 a 2 b 2 a 1 b 2 a 0 b 2 a 3 b 3 a 2 b 3 a 1 b 3 a 0 b 3 a a 3 -1 b b 3 Fast multiplication: we avoid calculating the 2 ’ s complement of multiplicand, which means a potential long carry chain
CSE Booth Recoding Multiplication: n rows by 2n-1 column matrix for addition Objective: try to reduce n rows to log n rows Radix 2 booth recoding Radix 4 booth recoding
CSE Radix 2 Booth Recoding Use 1,0,-1 to recode Recoding table idxixi x i-1 y i =(x i-1 -x i ) 0000No change 1011End of string of 1 ’ s 210Begin of string of 1 ’ s 3110No change
CSE Example Assume here is 0 x 5 x 4 x 3 x 2 x 1 -x 5 x 4 -x 4 x 3 -x 3 x 2 -x 2 x 1 -x 1 x 4 -x 5 x 3 -x 4 x 2 -x 3 x 1 -x 2 0-x 1 y 5 y 4 y 3 y 2 y 1
CSE Radix 4 Booth Recoding Use 2,1,0,-1,-2 to recode (z i/2 =2y i+1 +y i ) idx i+ 1 xixi x i-1 y i+1 yiyi z i/ No string of 1 ’ s End of string of 1 ’ s Isolated End of string of 1 ’ s Begin of string of 1 ’ s End of one string, begin new string Begin of string of 1 ’ s String of all 1 ’ s
CSE Examples Bin 0 1, 1 1, Radix 4: 2, 0, -1 2* = 31 2x 6 2x 4 2x 2 x 5 x 3 x 1 -2x 6 +x 5 +x 4 -2x 4 +x 3 +x 2 -2x 2 +x 1 +x 0 x 6 x 5 x 4 x 3 x 2 x 1 x 0