Beruflich Dokumente
Kultur Dokumente
..
n1
X
.
i
a = (a
a
n1 . . . a1 a0 )b =
i b = [ an1 . . . a1 a0 ]
|
{z
}
b1
i=0
An1:0
b0
(7.1)
a=
[|1 0 {z
1 1 0}]
A4:0
2
23
22
21
20
= 24 + 22 + 21 = 10 ;
ai {0, 1}
b=2
Note, that in the twos complement system the most significant digit is
negative (or zero). The bar over the digit is its sign not the logic
complement.
A.P.Paplinski
71
33
2
3
a = [|2 1{z0 1}] 1
3
A3:0 0
3
= 2 33 32 + 1 = 46 ;
ai {2, 1, 0}
b=3
ai {1, 0, 1} ; b = 2
a = (1
1{z0 1})2 = 23 + 22 1 = 5 ;
|
A3:0
7.2
where qi {0, 1} .
A.P.Paplinski
72
Qn1:0
2n1
2n2
= [
q n1
qn2
= [
qn1
2qn2 qn2
= [ qn1 + qn2 qn2 + qn3
n1:0 = [
Q
qn1
21
20
q1
q0
]
2q1 q1 2q0 q0 ]
q1 + q0 q0 + 0 ]
qn2
q1
q0
where
qi qi1 qi
0 0
0
0 1 +1 , and q1 = 0 .
1 0 1
1 1
0
qi = qi + qi1 , or,
(7.2)
Obviously the value of the multiplier has not changed in the re-coding
process and we have:
n1
q = qn1 2
n2
X
i=0
qi 2 =
n1
X
qi 2i
i=0
Example
(1 0 0 1 0 1 1)2 = 26 + 23 + 2 + 1 = 53
(1 0 1 1 1 0 1)2 = 26 + 24 23 + 22 1 = 53
A.P.Paplinski
73
OC
C
Product
KA
Multiplicand
C Multiplier
A.P.Paplinski
74
(7.3)
dm1 dm2
=
...
hDm1:0 in1
d0
...
d0
0
...
dm1 dm2 d0
n+m1
(7.4)
The angle brackets have been used to denote the resultant matrix. The
bold 0s in the resultant of eqn (7.4), represent appropriate triangles of
zeroes.
In general, eqn (7.3) can be thought of as a parallelised description of
the multiplication algorithm of two numerals.
Each row of the resultant represents a shifted numeral Dm1:0 which
is multiplied by the respective digit of the multiplier.
Subsequently, the columns of the resultant are summed up to give the
pseudo-digits of the result.
The carry propagation is neglected at this level of the multiplication
algorithm.
In this sense that the carry is incorporated into the pseudo-digits of
the result.
A.P.Paplinski
75
Example
Consider multiplication of the following decimal numerals
P5:0 = Q2:0 D3:0 = 3| {z
2 1} 1| 2{z3 4}
Q2:0
D3:0
3 2 1
where
1 2 3 4 0 0
0 1 2 3 4 0
0 0 1 2 3 4
cl
3 6 9 12 0 0
0 2 4 6 8 0
0 0 1 2 3 4
3 8 14 20 11 4
cl
P5:0
A.P.Paplinski
3 8 4 0 1 4
0 1 2 1 0 0
= 3 9 6 1 1 4 = 321 1234
76
d1 d0 0 0 ]
.
.
..
.
... ... ...
X
..
..
..
.
dm1
d1 d0 0 ]
cl q1 [ 0
q0 [ 0
0
dm1
d1 d0 ]
Pk1:0
(7.5)
rn1,1 rn1,0 0 0
..
..
.. ..
..
..
X
.
.
.
.
.
.
0
r1,m1
r11 r10 0
cl
0
0
r0,m1
r01 r00
Pk1:0
(7.6)
A.P.Paplinski
77
A.P.Paplinski
78
P =QD
OCC
C
Product
KAA
Multiplicand
C Multiplier
qi qi1 qi
0 0
0
0 1 +1
1 0 1
1 1
0
79
A.P.Paplinski
710
Figure 71: The top level schematic of the word-serial multiplication processor
Two symbols, dpath and cntp, representing the datapath and the
control unit components, respectively, are created and instantiated into
the top level schematic wsm as in Figure 71. The brief description of
the schematic is as follows.
A.P.Paplinski
711
A.P.Paplinski
712
7.6 Datapath
The block diagram of the datapath is presented in Figure 72. It
consists of the registers which store variables used in the pseudo-code
(sec 7.4), and combinatorial blocks like an ALU (adder/subtractor)
which perform required operations on the stored variables.
Multiplicand
Dop
Qop
Multiplier
Aop
F/2 = asr(F)
DD
AA
op
op
D-REGISTER
clk
A-REGISTER
op
sr
clk
fo
clk
Dm-1:0
Q-REGISTER
Qn-1:-1
Am-1:0
clk
n
m
q -1
Qn-1:0
q
0:-1
0
Fop
ALU (Adder/Subtractor)
F m-1:0
Sop
P=(AQ)
clk
COUNTER
Sc
op
zI
713
A.P.Paplinski
714
A <= 0 ,
SI D <= DD ,
rdy <= 0,
Q <= QQ ,
q1 <= 0 ,
Sc <= 0
st
st
A
if
F <= A + D if
A D if
SM
(A Q) <= asr(F Q),
Sc <= Sc + 1,
zI <= (Sc = n 1)
q0 q1
q0 q1
q0 q1
zI
zI
rdy <= 1
SF
st
st
Figure 73: The flow-chart of the word-serial multiplier using the one-bit Booths
method
A.P.Paplinski
715
In the initial state, SI, when st= 0, the multiplicand and the multiplier
are loaded into the registers D and Q respectively, and the signal rdy is
reset.
When the start signal st= 1 the control unit goes into the state SM in
which multiplication steps are repeated n times (signal zI).
In the final state, SF, the correct result is availabe at the port (A Q).
This is indicated by the signal rdy being asserted.
In order to multiply the next numbers, the start signal, st, must go low.
A.P.Paplinski
716
A.P.Paplinski
717
D = (101101)2 = 19 ; QQ = (101001)2 = 23
A[i], D
Q
q1
101001 0 q0 = q0 + q1 = 1
A[0] 000000
010010
D
c0
1
F 010011
- 10100
A[1] 001001 1
D 101101
F 110110 1
- - 1010
A[2] 111011 01
- - -101
A[3] 111101 101
010010
D
c0
1
F 010000 101
- - - - 10
A[4] 001000 0101
D 101101
F 110101 0101
-----1
A[5] 111010 10101
010010
D
c0
1
F 001101 10101
-----A[6] 000110 110101
F =AD
q1 = q0 + q1 = +1
F =A+D
q2 = 0
A[2] = A[1] 21
q3 = q0 + q1 = 1
F =AD
q4 = q0 + q1 = +1
F =A+D
q5 = q0 + q1 = 1
F =AD
1
A = A[6] = Q D = +437
Figure 74: A one-bit, word-serial Booths multiplication algorithm. A numerical
example.
A.P.Paplinski
718
A.P.Paplinski
719
multiplicand register, D
Dop
operation
0
DD
nop
1
D DD load
step counter, Sc
Sop
operation
0
Sc Sc
nop
1
Sc Sc+1 count
2, 3 Sc 0
reset
Fop
0, 3
1
2
ALU, F
operation
FA
pass
F A + B add
F A B subtract
720
The op-codes for the ALU, Fop, are equal to the value of the
current pair of the least significant multiplier digits. Therefore,
we have:
Fop = Q(0:-1).
All other op-code signals can be, for convenience, collected in one
7-bit op-code word:
op(6:0) = (Dop, Aop, Qop, Sop)
A.P.Paplinski
721
A.P.Paplinski
722
C/L
rdy
op(6:0)
nxt_st(1:0)
stt
rst
st
zi
stt(1:0)
clk
Figure 75: The control unit as a finite state machine
A.P.Paplinski
723
7.11.1
by
app
clk, st, zi : IN
STD_LOGIC ;
: OUT
STD_LOGIC_VECTOR(6 DOWNTO 0) ;
: OUT
STD_LOGIC_VECTOR(1 DOWNTO 0) ;
: OUT
STD_LOGIC
DOWNTO 0) ;
:= "00" ;
:= "01" ;
:= "10" ;
A.P.Paplinski
724
BEGIN
-- to synthesize edge-triggered flip-flops
-- with asynchronous reset when rst = 0
clkd: PROCESS ( clk, rst)
BEGIN
IF (rst = 0) THEN
stt <= SI ;
ELSIF ( clkEVENT AND clk = 1
AND clkLAST_VALUE = 0 ) THEN
stt <= nxt_st ;
END IF ;
END PROCESS clkd ;
-- the stm process describes the transitions between states
-- and the output signals
stm: PROCESS ( stt, st, zi )
BEGIN
-- default assignments
nxt_st <= stt ;
Dop <= nopD ;
Aop <= nop ;
Qop <= nop ;
Sop <= nop ;
rdy <= 0 ;
--
END IF ;
WHEN SM =>
Aop <= ldAshr ;
Qop <= shrQ ;
Sop <= count ;
IF ( zi = 1 ) THEN nxt_st <= SF ;
END IF ;
A.P.Paplinski
725
<=
<=
<=
<=
Dop
Aop
Qop
Sop
END IF ;
;
;
;
;
A.P.Paplinski
726
100ns
200ns
300ns
400ns
500ns
600ns
700ns
800ns
SCHEMATIC1
rst
'1'
SCHEMATIC1
clk
'1'
SCHEMATIC1
st
'1'
SCHEMATIC1
rdy
'0'
SCHEMATIC1
zI
'0'
SCHEMATIC1.Bc
nxt_st 1
X
SCHEMATIC1.Bc
stt
1
X
6A
15
00
6A
SCHEMATIC1.Bc
Aop
1
X0
SCHEMATIC1.Bc
Qop
1
X0
SCHEMATIC1.Bc
Sop
1
X0
SCHEMATIC1
op
15
X00
SCHEMATIC1.Bc
Dop
'0'
The signal rst resets the state of the control unit to SI.
If the signal st is low, the control unit remains in the state SI until the
first rising edge of the clock after the signal st goes high when the state
SM is reached.
From the state SM the transition to the state SF is made on the rising
edge when the signal zI from the step counter is asserted.
It is important to verify that the control unit generates correct op-codes
in every state.
A.P.Paplinski
727
/clk +
/st +
/zI +
/rdy +
/op(6:0) +
69
36 +
10 +
69 +
/dd(7:0) +
53
+ 00
/qq(7:0) +
65
+ 00
/aq(15:0) +
0.0
+
0065
200.0
+
D6B2
400.0
+
14D9
+
E0EC
600.0
+
19F6
+
0CFB
800.0
Time(ns)
+
DCFD
+
EE7E
1000.0
+
20BF
1200.0
+
1400.0
A.P.Paplinski
728
+
0000
+
1600.0