Download Multiplication

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSE 246: Computer Arithmetic
Algorithms and Hardware Design
Winter 2004
Lecture 5
Instructor:
Prof. Chung-Kuan Cheng
Topics:
 False Path: Cycles
 Multi-Operands Addition
 Carry Save Addition
 Multiplication
 2’s Complement
 Booth Recoding
CSE 246
2
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
Adder
S3,0
CSE 246
3
Cin
Example
 -3-5 = -8
11100
-3
+ 11010
-5
110110
110111
CSE 246
 0+0=0
11111
+ 11111
111110
0
0
111111
0
-8
4
Multi-Operand Addition
 Carry save adder: a (3,2) counter
CSE 246
5
Example
 A (3,2) counter compresses X rows
to 2/3X rows each time
 Tree structure in implementation
A
B
E
C
F
G
A
F
B
G
C
H
H
D
D
E
CSE 246
6
Other Counters
 (7,3) counter
 (5,3) counter
7
Ca Cb
S2 S1 S0
S0
 Design of (5,3) counter using full adders
FA
FA
Ca
CSE 246
Cb
S0
7
Multiplication
 Examples
0101
5
0110
0000
0101
0101
0000
0011110
6
*
CSE 246
30
0101
*
5
1010
-6
0000
0101
2’s complement of -5
0101
1011
1100010
-30
8
Multiplication
 Examples (Cont.)
1011
*
-5
0110
6
0000
111011
11011
Sign bits
0000
11100010
-30
CSE 246
1011
*
9
-5
1010
-6
0000
111011
00000 2’s complement of 5
0101
10011110
30
Multiplication
 Traditional multiplication of negative numbers
-a3b2
a3b3 -a2b3
CSE 246
a3
* b3
-a3b0
-a3b1 a2b1
a2b2 a1b2
-a1b3 -a0b3
a2
b2
a2b0
a1b1
a0b2
10
a1
b1
a1b0
a0b1
a0
b0
a0b0
Multiplication
 -xy = x(1-y)-x = xy-x
a3 b 3
0
0
CSE 246
a3b2
a2b3
-a3
-a2
a3
* b3
a3b0
a3b1 a2b1
a2b2 a1b2
a1b3 a0b3
-a3
-a3
-a1
-a0
a2
b2
a2b0
a1b1
a0b2
11
a1
b1
a1b0
a0b1
a0
b0
a0 b 0
Multiplication
 -xy = xy-x = xy-y
a3 b 3
0
0
CSE 246
a3b2
a2b3
-a3
-b3
a3
* b3
a3b0
a3b1 a2b1
a2b2 a1b2
a1b3 a0b3
-a3
-a3
-b3
-b3
a2
b2
a2b0
a1b1
a0b2
12
a1
b1
a1b0
a0b1
a0
b0
a0 b 0
Multiplication
 Replay 0 -a -a -a by a 0 0 a
-1
-1
a3 b 3
a3
b3
-1
-1
CSE 246
a3b2
a2b3
0
0
a3
* b3
a3b0
a3b1 a2b1
a2b2 a1b2
a1b3 a0b3
0
a3
0
b3
a2
b2
a2b0
a1b1
a0b2
13
a1
b1
a1b0
a0b1
a0
b0
a0 b 0
Multiplication
 Fast multiplication: we avoid calculating the 2’s
complement of multiplicand, which means a
potential long carry chain
a3b2
a3b3 a2b3
a3 0
-1 b3 0
CSE 246
a3
* b3
a3b0
a3b1 a2b1
a2b2 a1b2
a1b3 a0b3
0
a3
0
b3
a2
b2
a2b0
a1b1
a0b2
14
a1
b1
a1b0
a0b1
a0
b0
a0b0
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
CSE 246
15
Radix 2 Booth Recoding
 Use 1,0,-1 to recode
 Recoding table
id
xi xi-1 yi=(xi-1-xi)
0
0
0
0
No change
1
0
1
1
End of string of 1’s
2
1
0
-1
Begin of string of 1’s
3
1
1
0
No change
CSE 246
16
Example
1 0 1 1 1 0 1 0 1
-1 1 0 0 -1 1 -1 1 -1
x5
x4
x3
x2
x1
-x5
x4
-x4
x3
-x3
x2
x4-x5 x3-x4
y5
CSE 246
y4
-x2
x1
-x1
x2-x3
x1-x2
0-x1
y3
y2
y1
17
0
Assume here is 0
Radix 4 Booth Recoding
 Use 2,1,0,-1,-2 to recode (zi/2=2yi+1+yi)
id xi+
xi
xi-1 yi+1
yi
zi/2
1
0
1
2
3
4
5
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
1
1
-1
-1
0
1
-1
0
0
1
0
1
1
2
-2
-1
6 1
CSE 246
7 1
1
1
0
1
0
0
-1
18
0
-1
0
No string of 1’s
End of string of 1’s
Isolated 1
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
Examples
Bin
0
1,1 1,1 1
Radix 4: 2 ,
0
,
0
-1
31
2*42-1 = 31
2x6
2x4
2x2
x5
x3
x1
-2x6+x5+x4 -2x4+x3+x2 -2x2+x1+x0
x0
CSE 246
x6
x5
x4
x3
19
x2
x1
Related documents