KV Digital Design P2 Mult PDF
KV Digital Design P2 Mult PDF
Kuruvilla Varghese
DESE
Indian Institute of Science
Kuruvilla Varghese
Multiplier: Algorithm 2
Multiplicand 1 0 1 1 x
Multiplier 1 1 0 1
------------------
Partial products 1 0 1 1
0 0 0 0
1 0 1 1
1 0 1 1
-----------------------------
1 0 0 0 1 1 1 1
-----------------------------
Kuruvilla Varghese
1
8-bit Multiplier: Issues 3
Resources 4
Kuruvilla Varghese
2
mc7:0
clk Multiplier: Data Path
rst MCND REG
load
md7:0 r15:8
ADD
0 r15:8 su8:0
sel 0 1 ml7:0
s0
s8:1
clk
clk L.PROD / MULT rst
prst H. PROD REG REG load
shift shift
r15:8 r7:0
Counter 6
clk
prst count2:0 Decoder max
Counter
shift
Kuruvilla Varghese
3
Controller 7
clk prst
rst load
start Controller
r(0) shift
max sel
done
Kuruvilla Varghese
Timing Diagram 8
CLK
start
prst
load
sel
shift
max
done
Kuruvilla Varghese
4
Multiplicand Register (MCND) 9
Kuruvilla Varghese
H Product Register 10
Kuruvilla Varghese
10
5
L. PRODUCT / MULT Register 11
11
Counter 12
Kuruvilla Varghese
12
6
Adder and Mux 13
-- Adder
md7:0 r15:8 su <= ('0' & md) + ('0' & r(15 downto 8));
0 1
sel
s8:1 s0
Kuruvilla Varghese
13
Inputs NS Outputs
Next
D PS Output
State
CK Q Logic
Logic AR
Clock
Reset
NS = f (PS, Inputs)
Moore Outputs = f (PS)
Mealy Outputs = f (PS, Inputs)
Kuruvilla Varghese
14
7
FSM / Controller: 2 Blocks view 15
Outputs
Inputs
NS D PS
Logic CK Q
AR
Clock
Reset
Kuruvilla Varghese
15
Controller 16
clk prst
rst load
start Controller
r(0) shift
max sel
done
Kuruvilla Varghese
16
8
Timing Diagram 17
CLK
start
prst
load
sel
shift
max
done
Kuruvilla Varghese
17
Control Algorithm 18
18
9
State Diagram 19
power_on
start/
prst = 1, load = 0,
S0 sel = 0, shift = 0,
start
done = 0
start
start/
prst = 0, load = 0, prst = 1, load = 1,
sel = 0, shift = 0, S3 S1 sel = 0, shift = 0,
done = 1 done = 0
max max/
prst = 0, load = 0,
S2 sel = r(0), shift = 1,
done = 0
Kuruvilla Varghese
19
Kuruvilla Varghese
20
10
Next State Table 21
21
Output Table 22
Equations
prst = f1 (Q1, Q0) load = f2 (Q1, Q0) sel = f3 (Q1, Q0)
shift = f4 (Q1, Q0) done = f5 (Q1, Q0)
Minimization
Kuruvilla Varghese
22
11
Methodology 23
1. Specifications
2. Block schematic (Blocks, Signals)
– Data path, Controller(s)
3. System Timing Diagram
4. Data path design (Various Levels)
5. Controller Algorithm
6. State Diagram
Kuruvilla Varghese
23
Methodology 24
Kuruvilla Varghese
24
12
Methodology 25
Kuruvilla Varghese
25
mc7:0
clk Multiplier: Data Path
rst MCND REG
load
md7:0 r15:8
ADD
0 r15:8 su8:0
sel 0 1 ml7:0
s0
s8:1
clk
clk L.PROD / MULT rst
prst H. PROD REG REG load
shift shift
r15:8 r7:0
26
13
VHDL Code 27
• Signals with red dashed line cutting across are ports of the top-level
entity, and others are internal signals. It is easy to code from block
schematic when you use such conventions.
Kuruvilla Varghese
27
Kuruvilla Varghese
28
14
Multiplier: VHDL Code 29
Kuruvilla Varghese
29
30
15
Multiplier: VHDL Code 31
Kuruvilla Varghese
31
Kuruvilla Varghese
32
16
State Diagram 33
power_on
start/
prst = 1, shift = 0,
S0 load = 0, sel = 0,
start done = 0
start
start/
prst = 0, shift = 0, prst = 1, shift = 0,
load = 0, sel = 0, S3 S1 load = 1, sel = 0,
done = 1 done = 0
max max/
prst = 0, shift = 1,
S2 load = 0, sel = r(0),
done = 0
Kuruvilla Varghese
33
conlog: process (pr_state, start, r(0), max) • While coding next state logic, You
begin should specify all transitions explicitly.
case pr_state is • In the above code you should not think
when s0 => the FSM is in state S0, hence the else
prst <= '1'; load <= '0'; shift <= '0'; part need not be specified
sel <= '0'; done <= '0'; • This will create an implied latch, as this
if (start = '1') then nx_state <= s1; is a combinational circuit with pr_state
else nx_state <= s0; as input and nx_state as output.
end if; • S0 in when S0 refers to input (present
state) and S0 in nx_state <= s0 refers to
output (next state).
Kuruvilla Varghese
34
17
Multiplier: VHDL Code version 2 35
35
36
18
Multiplier: VHDL Code version 2 37
Kuruvilla Varghese
37
38
19
mc7:0 Multiplier
clk
MCND REG
clk count
md7:0 r15:8
Counter =7
ADD
0 su8:0
r15:8
shift
clk sel
rst 0 1 ml7:0
load
start Controller prst s0
s8:1 clk
clk
L.PROD / MULT
r(0) H. PROD REG REG
done
r15:8 r7:0
39
Kuruvilla Varghese
40
20
Multiplier: VHDL Code version 3 41
Kuruvilla Varghese
41
42
21
Power on Reset 43
Inputs NS Outputs
Next D
Sync Output
State PS
Reset CK Q Logic
Logic AR
Clock
Async Reset
Kuruvilla Varghese
43
Kuruvilla Varghese
44
22
FSM: Minimum Clock frequency 45
CLK
IN1
IN2
IN3
CLK’
Kuruvilla Varghese
45
46
23
Timing Pulse Accuracy 47
Timing Pulse
CLK1
CLK2
• To detect a pulse with certain accuracy, min clock period should be less than
the error
Kuruvilla Varghese
47
Pulse detection 48
Kuruvilla Varghese
48
24
Pulse to toggle 49
I
D Q
CK
P AR
Kuruvilla Varghese
49
Level to pulse 50
I
I1 I2 I3
D Q D Q D Q
CK CK CK
clk2
I2
clk2
I3
l2 xor l3
Kuruvilla Varghese
50
25
Pulse Transfer 51
I
I1 I2 l3
D Q D Q D Q D Q
CK CK CK
CK
P
clk2
Kuruvilla Varghese
51
D Q D Q
Comb
CK CK
CLK
52
26
Naive Question often asked? 53
D Q D Q
Comb
CK CK
CLK
If the second register is clocked by CLK/, the frequency of the clock has to be half
that of the previous case. Also, the data still arrives at every clock period of half the
clock frequency
Kuruvilla Varghese
53
Moore Output
rst
start/ Mealy Output
S0 load = 0 rst
start/
start
S0 load = start
S1 load = 1 start
S2 load = 0
S2 load = 0
Kuruvilla Varghese
57
27
Moore / Mealy Output 58
clk
start
S0 S0 S1 S2
Moore states
load
S0 S0 S2
Mealy states
load
Kuruvilla Varghese
58
Mealy Output 59
Kuruvilla Varghese
59
28
FSM: Mealy Output 60
Synchr
onous
O1: Mealy Output Sub-
i1 system
FSM
i2
O1 and O2 can be Mealy output as function of states and i1 and/or i2 or any other combination of
synchronous inputs
Kuruvilla Varghese
60
FSM / Reg /
en (RA_L)
Contr- Counter /
oller Seq Ckt
clk
Kuruvilla Varghese
61
29
Clock Gating 62
D7:0 D Q D7:0
RA_E
RA_L CLK’
CK
CLK
CLK
RA-L
CLK’
1 2
Kuruvilla Varghese
62
Clock Gating 63
Kuruvilla Varghese
63
30
Re-circulating Buffer 64
0
D Q D7:0
1
RA_L RA_E
CLK CK
CLK
RA-L
Kuruvilla Varghese
64
Re-circulating Buffer 65
Kuruvilla Varghese
65
31
Counter with enable 66
+1 1 count
0
d q
q
en
clk clk
SR
rst
Kuruvilla Varghese
66
VHDL Code 67
process (clk)
begin
if (clk'event and clk = '1') then
if (rst = '1') then q <= (others => '0’);
elsif (en = ‘1’) then q <= q + 1;
end if;
end if;
end process;
Kuruvilla Varghese
67
32
Counter with enable and load 68
0
+1 count
1
en d q
q
1
din
load
clk
clk SR
rst
Kuruvilla Varghese
68
VHDL Code 69
process (clk)
Begin
if (clk'event and clk = '1') then
if (rst = '1') then q <= (others => '0’);
elsif (load = '1') then q <= din;
elsif (en = ‘1’) then q <= q + 1;
end if;
end if;
end process;
Kuruvilla Varghese
69
33
Re-circulating Buffer 70
0
D Q D7:0
1
RA_L RA_E
CLK CK
CLK
RA-L
Kuruvilla Varghese
70
Kuruvilla Varghese
71
34
Clock Gating for Low Power 72
D7:0
D Q D7:0
CLK1
RA_L D Q
CK RA_E
CLK2
CK
CLK
CLK
RA-L
CLK1
CLK2
Kuruvilla Varghese
72
Kuruvilla Varghese
73
35