Escolar Documentos
Profissional Documentos
Cultura Documentos
April 9, 2013
John Wawrzynek
Spring 2013
Page 1
EECS150 - Lec21-mult-shift
Multiplication
a 3b 3
a 3b 2
a2b 3
a3
b3
a2
b2
a1
b1
a0
b0
a 3b 0
a 2b 0
a 1b 0
a 0b 0
a3 b 1
a 2b 2
a 1b 3
a 2b 1
a 1b 2
a 0b 3
a 1b 1
a 0b 2
a 0b 1
...
a1b0+a0b1 a0b0
Multiplicand
Multiplier
Partial
products
Product
EECS150 - Lec21-mult-shift
Page
Control Algorithm:
1. P 0, A multiplicand,
B multiplier
2. If LSB of B==1 then add A to P
else add 0
3. Shift [P][B] right 1
4. Repeat steps 2 and 3 n-1 times.
5. [P][B] has product.
EECS150 - Lec21-mult-shift
Page
+ 2 + 0 + 8
- 16 = -6
EECS150 - Lec21-mult-shift
Page
Bit-serial Multiplier
Control Algorithm:
repeat n cycles {
// outer (i) loop
repeat n cycles{
// inner (j) loop
shiftA, selectSum, shiftHI
Spring 2013
EECS150 - Lec21-mult-shift
Page
Array Multiplier
Single cycle multiply: Generates all n partial products simultaneously.
Each row: n-bit adder with AND gates
EECS150 - Lec21-mult-shift
Page
Carry-Save Addition
Speeding up multiplication is a
matter of speeding up the
summing of the partial products.
Carry-save addition can help.
Carry-save addition passes
(saves) the carries to the output,
rather than propagating them.
310
+ 210
c
s
carry-save add
carry-propagate add
carry-save add
310 0011
c 0010 = 210
s 0110 = 610
1000 = 810
EECS150 - Lec21-mult-shift
Page
Page
Carry-save Circuits
Spring 2013
EECS150 - Lec21-mult-shift
Spring 2013
EECS150 - Lec21-mult-shift
Page
Carry-save Addition
CSA is associative and communitive. For example:
(((X0 + X1) + X2 ) + X3 ) = ((X0 + X1) +( X2 + X3 ))
Spring 2013
EECS150 - Lec21-mult-shift
Page
10
Constant Multiplication
Our discussion so far has assumed both the multiplicand
(A) and the multiplier (B) can vary at runtime.
What if one of the two is a constant?
Y=C*X
Constant Coefficient multiplication comes up often in
signal processing and other hardware. Ex:
yi = yi-1+ xi
x
y
i
EECS150 - Lec21-mult-shift
Page
11
Multiplication by a Constant
Spring 2013
EECS150 - Lec21-mult-shift
Page
12
Multiplication by a Constant
In general, a combination of fixed shifts and addition:
Ex: 6*X = 0110 * X = (22 + 21)*X
Details:
Spring 2013
EECS150 - Lec21-mult-shift
Page
13
Multiplication by a Constant
Another example: C = 2310 = 010111
EECS150 - Lec21-mult-shift
Page
14
We can recode 15
from 01111 = (23 + 22 + 21 + 20 )
to
10001 = (24 - 20 )
where 1 means negative weight.
Spring 2013
EECS150 - Lec21-mult-shift
Page
15
Examples:
011101 = 29
100101 = 32 - 4 + 1
0010111 = 23
0011001
0101001 = 32 - 8 - 1
0110110 = 54
1011010
1001010 = 64 - 8 - 2
EECS150 - Lec21-mult-shift
Page
16
CSD helps, but the multipliers are limited to shifts followed by adds.
CSD multiplier: Y = 231*X = (28 - 25 + 23 - 20)*X
EECS150 - Lec21-mult-shift
Page
17
fixed shifters
hardwire the shift
amount into the circuit.
Logical
Shift
Rotate
Fixed shift/rotator is
nothing but wires!
So what?
Spring 2013
Arithmetic
Shift
EECS150 - Lec21-mult-shift
Page 18
EECS150 - Lec21-mult-shift
Page 19
Shift by 2
Shift by 1
Spring 2013
EECS150 - Lec21-mult-shift
Page 20
Final stage
uses F7 mux
Spring 2013
EECS150 - Lec21-mult-shift
Page 21
Spring 2013
EECS150 - Lec21-mult-shift
Page 22
Barrel Shifter
Cost/delay?
(dont forget
the decoder)
Spring 2013
EECS150 - Lec21-mult-shift
Page 23
Connection Matrix
Generally useful structure:
N2 control points.
What other interesting
functions can it do?
Spring 2013
EECS150 - Lec21-mult-shift
Page 24
Cross-bar Switch
Nlog(N) control
signals.
Supports all
interesting
permutations
All one-to-one and
one-to-many
connections.
Spring 2013
EECS150 - Lec21-mult-shift
Commonly used in
communication
hardware (switches,
routers).
Page 25