3.HDL Modeling 2
3.HDL Modeling 2
3.HDL Modeling 2
Mehrdad Nourani
Dept. of EE
Univ. of Texas at Dallas
Session 03
Overview of HDL-for-Synthesis
10
a3 b3
a2 b2
a1 b1
a0 b0
module
module
module
module
module
&
11
module
r
a3 b3
a2 b2
a1 b1
a0 b0
module
module
module
module
std_logic;
&
=>
=>
=>
=>
p);
q);
r);
s);
o
12
Example 6: Synthesis
Schematics design after
Synopsys synthesis,
design optimization and
compilation:
The module in this
design is an XOR gate
Each module would be
optimized alone
Does not necessarily
optimize the whole
design altogether
13
Sequential Modeling
14
Modeling Flip-Flops
D-flip-flop behavior
-Example 7.1: D-flip-flop with reset
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity dff is
port( d:in std_logic;
clk,rst:in std_logic;
q:out std_logic);
end dff;
architecture dff_arch of dff is
begin
process(rst, clk)
begin
if rst = '1' then
q <= '0';
elsif clk'event and clk = '1' then
q <= d; --rising edge triggered
end if;
end process;
end dff_arch;
15
17
20
Example 8 (contd)
For combinational logic or latches you have to
take more care with the sensitivity list.
If d input is not on sensitivity list of the latch,
-> wrong functionality in simulation.
VHDL code of a latch with incorrect behavior:
--Example 8.2: Latch with incorrect behavior
library ieee;
use ieee.std_logic_1164.all;
entity mylatch is
port( d:in std_logic;
en:in std_logic;
o:out std_logic);
end mylatch;
21
22
Example 8: Simulation
Simulation results of Example 8.1:
Correct
Incorrect functionality
23
24
Moore Machine
A Moore machine has output(s) that depend on
state only
The FSM has the output(s) written in the state itself
Mealy Machine
A Mealy machine has output(s) that depend on both
the state and input(s)
The FSM has the output written on edges
25
Moore Machine
State Diagram:
Transition Table:
0
S0/0
0
Present
State
Next State
Output
(Z)
x=0 x=1
1
S1/1
S2/1
1
S3/0
S0
S0
S2
S1
S0
S2
S2
S2
S3
S3
S3
S1
26
27
28
Mealy Machine
State Diagram:
Transition table:
0/0
S0
0/0
Present
State
1/1
Next State
x=1
S1
S2
1/1
1/0
S3
0/1
Output
(Z)
S0
S0
S2
S1
S0
S2
S2
S2
S3
S3
S3
S1
0/0
29
30
31
Asynchronous Modeling
32
Asynchronous Design
An asynchronous circuit is one in which
synchronization is performed without a global
clock
Advantages:
Elimination of clock skew problems.
Average-case performance.
Adaptivity to processing and environmental
variations.
Component modularity and reuse.
Lower system power requirements.
Reduced noise.
33
34
when s2=>
if (p='0') and (r='0') then
currentstate<=s2;
z<='1';
elsif (p='0') and (r='1') then
currentstate<=s3;
z<='0';
elsif (p='1') and (r='1') then
currentstate<=s4;
z<='0';
else
currentstate<=s1;
z<='1';
end if;
when s3=>
if (p='0') and (r='0') then
currentstate<=s0;
z<='0';
elsif (p='0') and (r='1') then
currentstate<=s3;
z<='0';
elsif (p='1') and (r='1') then
currentstate<=s4;
z<='0';
else
currentstate<=s1;
z<='1';
end if;
when s4=>
if (p='0') and (r='0') then
currentstate<=s2;
z<='1';
elsif (p='0') and (r='1') then
currentstate<=s3;
z<='0';
elsif (p='1') and (r='1') then
currentstate<=s4;
z<='0';
else
currentstate<=s5;
z<='0';
end if;
when s5=>
if (p='0') and (r='0') then
currentstate<=s2;
z<='1';
elsif (p='0') and (r='1') then
currentstate<=s3;
z<='0';
elsif (p='1') and (r='1') then
currentstate<=s4;
z<='0';
else
currentstate<=s5;
z<='0';
end if;
end case;
end process state_trans;
end asyn_arch;
35
36
Parallelism and
Interaction Among Units
37
myand
Z
f
myxor
Z
g
38
39
40
42
Write
Use of arrays
Read
43
44