Professional Documents
Culture Documents
VHDL
A Compact
p
Overview
John F. Wakerlyy
Digital design (3rd edition)
Prentice Hall, 2001
Peter J. Ashenden
Th designers
The
d i
guide
id to VHDL (2nd
(2 d edition)
di i )
The student
studentss guide to VHDL
Paolo.Ienne@epfl.ch
EPFL I&C LAP
VHDL: Du langage
g g au circuit,, du circuit au langage
g g
Masson, 1997
Roland Airiau, Jean-Michel Berg, Vincent Olive et Jacques Rouillard
VHDL: Langage, modlisation, synthse (2me dition)
PPUR 1998
PPUR,
2
button
Int od ction
Introduction
%
RO
button
O
R
Finite-State
Machine
3
Control Box
Classic Approach
Button
Red Light
B
u
t
t
o
n
00b
State
(memory)
G=00b
O=01b
R=10b
RO=11b
Update
Process
(
(combinatorial
bi t i l
logic)
Output
Process
(combinatorial
logic)
Button
11b
Orange Light
01b
10b
Green Light
INPUTS
FSM
S0
Green Light
00
00
00
01
01
10
10
11
11
Red Light
Orange Light
Next state
00
7
0
1
11
0
01
Green
light
Orange
light
Red
light
00b
0b
00b
1b
0b
0b
00b
1b
01b
1b
0b
0b
01b
10b
0b
1b
0b
10b
11b
0b
0b
1b
11b
00b
0b
1b
1b
1
0
00
1
11
Button
S0
S0
Output
process
Signal Flow
S1
Next
State
Update
process
State
OUTPUTS
B
u
t
t
o
n
State
S1
S0
0
S0
1
0
1
S1
S1
1
0
0
1
Button
S1
S1
1
0
0
0
0
1
0
1
B
u
t
t
o
n
Red Light
S1
Orange Light
S0
Green Light
Clock
Button
State
Next state
00
00
01
01
10
10
11
11
00
00
Red light
Orange light
Green light
Flip flop delay Undefined state
due to cascaded
logic gates
8
time
Gate delay
Design Flow
Hardware flow
Software flow
C++ or Java
Synthesizer
Compiler
Gate level
Assembly
10
?=VHDL
History
Main characteristics:
Hierarchical
Event-driven simulation
Modular
Extensible
General language, strongly typed, similar to Ada
11
1980:
Beginning of the project, financed by DoD (400M $US)
1982:
Contracts for Intermetrics, IBM et Texas
1985:
Version 7.2 released public domain
1987:
Standard IEEE 1076 (VHDL-87)
1993:
New version of the standard (VHDL-93)
2001:
N
New
version
i off th
the standard
t d d (VHDL
(VHDL-2001)
2001)
12
In This Course
Course
Simulation vs.
vs Synthesis
Synthesis:
y
It is the p
process of translating
g the
VHDL description of a system into simple gates
(similar
(s
a to
o co
compiling
p
g a program
p og a in C++
C
or
o
Java)
systems
13
14
The outputs are a function of only the current state (Moore FSM)
Button
update_process : PROCESS(state,button)
BEGIN
IF (state = green) THEN
IF (button = 1) THEN next_state <= orange;
ELSE next_state <= green;
END IF;
ELSIF (state = orange) THEN next_state <= red;
ELSIF (state = red) THEN next_state
next state <= red_orange;
red orange;
ELSE next_state <= green;
END IF;
END PROCESS update_process;
Update
Process
(combinatorial
logic)
15
State
(memory)
G
RO
Button
O
BEGIN
IF (state = green) THEN Green_Light <= 1;
ELSE Green_Light <= 0;
END IF;
IF (state = orange OR
state = red_orange) THEN Orange_Light <= 1;
ELSE Orange_Light <= 0;
END IF;
IF (state = red OR
state = red_orange) THEN Red_Light <= 1;
ELSE Red_Light <= 0;
END IF;
END PROCESS output_process;
Update
Process
(combinatorial
logic)
Output
Process
(combinatorial
logic)
Sanchez, Ienne, Kluter 2007
16
State
(memory)
Button
G
RO
Button
O
Output
Process
(combinatorial
logic)
Sanchez, Ienne, Kluter 2007
B tt
Button
G
RO
Button
O
State
(memory)
Update
Process
(combinatorial
logic)
17
Output
Process
(combinatorial
logic)
Sanchez, Ienne, Kluter 2007
Entity
18
FSM
OUTPUTS
B
u
t
t
o
n
Red Light
O
Orange
Light
Li h
Green Light
The black box is
called ENTITY in
VHDL
19
INPUTS
ENTITY fsm IS
PORT ( B :
RL :
OL :
GL :
END fsm;
IN
OUT
OUT
OUT
LIBRARY ieee;
USE ieee
ieee.std_logic_1164.all;
std logic 1164 all;
USE ieee.std_logic_arith.all;
std_logic;
std_logic;
std_logic;
std_logic);
-----
Button input
Red light output
Orange light output
Green light output
ENTITY <entity_name> IS
PORT ( );
END <entity_name>;
PORT ( <port
<port_name>
name> : <port_type>
<port type>
<port_name> : <port_type>
.
.
<port name> : <port_type>
<port_name>
<port type>
<port_name> : <port_type>
);
Each
<signal_type>;
<signal
type>;
<signal_type>;
<signal type>;
<signal_type>;
<signal_type>
IMPORTANT NOTE:
The last port in the PORT section
is not terminated by a ;
Each
Real
Integer
Time
i
In this course we are only going to use the following VHDL types:
STD_LOGIC This is the type holds a one bit quantity (see it as being
one wire)
STD_LOGIC_VECTOR
STD LOGIC VECTOR ((n-1) DOWNTO 0) This type holds a set of
n-bits (see it as being a collection of n wires)
22
Our Entity
The STD_LOGIC
STD LOGIC and each element (bit)
( bit ) of the
STD_LOGIC_VECTOR can hold nine values:
U = uninitialized
X = forcing unknown
0 = forcing 0
1
1 = forcing 1
Z = high impedance
W = weak unknown
L = weakk 0 (pull-down)
( ll d
)
H = weak 1 (pull-up)
- = dont care
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY fsm IS
PORT ( CLK
Button
Red_Light
Orange_Light
Green_Light
END fsm;
23
:
:
:
:
:
IN
IN
OUT
OUT
OUT
24
Functionality
Architecture
END functional_level;
Update
Process
(combinatorial
logic)
Output
Process
(combinatorial
logic)
OL
GL
25
RL
State
(memory)
G=00b
O 01b
O=01
R=10b
RO=11b
Update
Process
(combinatorial
logic)
State
(memory)
ARCHITECTURE
Output
Process
P
(combinatorial
logic)
ARCHITECTURE implementation_1
implementation 1 OF fsm IS
BEGIN
END implementation_1;
implementation 1;
26
ENTITY
Each ENTITY has at least one
functional description
(ARCHITECTURE)
ARCHITECTURE definition
ARCHITECTURE <implementation
p
_name> OF <entity
y_name> IS
[Declaration Section]
ARCHITECTURE
ARCHITECTURE
ARCHITECTURE
implementation_2
implementation_1
implementation_3
BEGIN
[Body]
END <implementation_name>;
28
Declaration Section
Body of an Architecture
Implicit processes
Explicit processes
Component
C
instantiations
i
i i
31
State
(memory)
30
State
(memory)
Output
Process
(combinatorial
logic)
Summary
ENTITY
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY <entity_name> IS
PORT ( <port_name> : <port_type> <signal_type>;
<port_name> : <port_type> <signal_type>;
.
.
<port_name> : <port_type> <signal_type>;
<port_name> : <port_type> <signal_type>
);
END <entity
y_name>;
ARCHITECTURE
2
ARCHITECTURE
1
ARCHITECTURE
3
Output
Process
(combinatorial
l i )
logic)
Update
Process
(combinatorial
logic)
g )
32
Remember RTL
We will divide each system (ARCHITECTURE) into:
Combinatorial elements
Elementary sequential elements (memory, flip-flop and/or latches)
Interconnects ((wires)
i )
Signals as wires
Operators
Statements
Events
Implicit processes
INPUTS
OUTPUTS
SYSTEM
State
(memory,
(memory
flip-flops
or
latches)
combinatorial
logic
State
(memory,
flip-flops
or
latches)
combinatorial
logic
State
(memory,
(memory
flip-flops
or
latches)
combinatorial
logic
34
Cin
SUM
Each connection (wire)
corresponds to
a SIGNAL
Signal Syntax
Cout
Cout = A.B+Cin.(A XOR B)
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee
ieee.std_logic_arith.all;
std logic arith all;
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cout : OUT
END full_adder;
35
std_logic;
std_logic;
std_logic;
std_logic;
std_logic);
[Declaration Section]
------
A input
B input
Carry input
Sum output
Carry output
BEGIN
[Body]
END <implementation_name>;
36
Signal Properties
We can assign
g a constant value to a signal
g
of type
yp std_logic
g byy using
g
<signal_name> <= <value>;
Examples
s_a
s_a
s_a
s_a
<=
<=
<=
<=
0;
1
1;
X;
Z;
It is good practice
practice, but not required
required,
to prefix all constant names with c_
37
38
SUM
Cpropagate
Cin
Cout
The SIGNALS
SUM
Cpropagate
Cin
Cout
SUM
<= A XOR B XOR Cin;
Cout
<= (A AND B) OR (Cin AND (A XOR B));
Cpropagate <= Cin AND Cout;
NO
The PORTS
39
40
Different Implementations
Extensive signal
g
usage:
g
Merging
g g of signals:
g
Operators
To model the functionality of the system, VHDL provides several
operators:
s_x1
s_x2
s_x3
s_x4
s_x5
SUM
<=
<=
<=
<=
<=
<=
A;
B;
Cin;
s_x1 XOR s_x2;
s_x4 XOR s_x3;
s_x5;
s_x6
s_x7
s_x8
Cout
<=
<=
<=
<=
Concatenation:
Arithmetic:
Logical:
and or nand nor xor xnor not
Comparison:
+ - * / mod rem
A
B
s_x4
s_x1
s x2
s_x2
Cin
s_x7
s_x3
s_x8
s_x6
41
Shifting:
SUM
s_x5
Cpropagate
Cout
s x8 must stay
s_x8
stay,
as it has the output
PORT cannot be
read!
Sign:
+ -
Diverse:
abs **
42
SIGNAL
SIGNAL
SIGNAL
SIGNAL
SIGNAL
SIGNAL
s_x1
s_x2
s_x3
s_x4
s
s_x5
x5
s_x6
:
:
:
:
:
:
std_logic_vector(3
std_logic_vector(3
std_logic_vector(3
std_logic_vector(3
std
std_logic_vector(1
logic vector(1
std_logic;
DOWNTO
DOWNTO
DOWNTO
DOWNTO
DOWNTO
0);
0);
0);
0);
0);
s_x3 <= s_x1 XOR s_x2; --This is correct as s_x1,s_x2 and s_x3 all contain 4 bits (wires)
s_x4 <= s_x1 OR s_x5; --This is incorrect as s_x5 only contains 2 bits, whilst s_x1 and s_x4 contain 4
s_x6 <= s_x3 OR s_x4; --This is incorrect as the result of s_x3 OR s_x4 is 4 bits, each operator does
--a bitwise operation (similar to | in C++; || does not exist in VHDL)
s_x1
s_x2
s_x3
s_x4
s_x5
s_x6
:
:
:
:
:
:
std_logic_vector(3
std_logic_vector(3
std_logic_vector(3
std_logic
g _vector(3
(
std_logic_vector(1
std_logic;
43
DOWNTO
DOWNTO
DOWNTO
DOWNTO
DOWNTO
0);
0);
0);
0);
)
0);
--This is correct as s_x1, s_x2 and s_x3 all contain 4 bits (wires)
--This is correct as (00 & s_x5), s_x1 and s_x4 all contain 4 bits
--This
This is correct as s
s_x6,
x6 s
s_x3(0)
x3(0) and s
s_x4(2)
x4(2) all contain 1 bit
Examples
Correct:
s_signed_add
_
_
s_unsigned_add
s_signed_multiply
s_unsigned_multiply
<=
<=
<=
<=
NOT TO BE USED:
s_mixed_add
s_mixed_multiply
44
signed( s_in1
_
)
+ signed( s_in2);
_
unsigned( s_in3 ) + unsigned( s_in4 );
signed( s_in1 )
* signed( s_in2);
unsigned( s_in3 ) * unsigned( s_in4 );
Special Operations
LIBRARY ieee;
;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
-- s
s_x1
x1 is s
s_x2
x2 << 1; hence s
s_x1
x1 = s
s_x2*2
x2*2
-- s_x3 is signed(s_x2) >> 1; hence s_x3 = s_x2/2
s
s_a
a
:
s_b
:
s_add :
s_sum :
s_cout:
std
std_logic;
logic;
std_logic;
std_logic_vector( 1 DOWNTO 0 );
std_logic;
std_logic;
A input
B input
Carry input
Sum output
Carry propagate
Carry output
?
=
46
A input
B input
Carry input
Sum output
Carry propagate
Carry output
-------
LIBRARY ieee;
;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
-------
A input
B input
Carry input
Sum output
Carry propagate
Carry output
Process
4
B
Cin
SUM
Process 1
Process 2
s_x8
P.
3
P1
A
B
Cprop
P5
Cout
P2
Cin
Intuition:
All elements in hardware will execute
in parallel, hence the processes must
also
l execute
t in
i parallel
ll l
s_x9
s_x8
BEGIN
SUM
<= A XOR B XOR Cin;
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
Cout <= s_x8;
Cprop <= s_x8 AND Cin;
END implementation_1;
47
std_logic;
std
std_logic;
logic;
std_logic;
std_logic;
std_logic;
std_logic);
BEGIN
Cprop <= s_x8 AND Cin;
SUM
<= A XOR B XOR Cin;
Cout <= s_x8;
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
END implementation_1;
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
BEGIN
SUM
<= A XOR B XOR Cin;
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
Cout <= s_x8;
Cprop <= s_x8 AND Cin;
END implementation_1;
Important
p
note:
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
-------
45
std_logic;
std
std_logic;
logic;
std_logic;
std_logic;
std_logic;
std_logic);
LIBRARY ieee;
;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
P3
P4
OSC
SUM
Cout
Process 3 is
sensitive to s_x8
Cp op
Cprop
Delta
Delta
A
B
P1
P2
s_x8
Cin
The change on A triggers
process 1 and process 2
OSC
SUM
P5
P3
3
Cout
P4
Cprop
Note:
does not
include the gate
delays, as we are
working with a
zero delay model!
A
B
Cin
OSC
SUM
s_x8
Cout
Cprop
PROCESS 1 and
d 2 produce
d
a stable
t bl output
t t after
ft D
Delta
lt = 1
PROCESS 3 and 4 produce a stable output after Delta = 2
produce a stable output,
p , as it is triggered
gg
over
PROCESS 5 does not p
and over again
2.
t1
49
50
Implicit Processes
We
e have
a e see
seen PROCESSes
OC SS es in tthe
e form:
o
BEGIN
[Process description]
END PROCESS <process_name>;
Implicit form
Or a component:
<component_reference>
<component
reference> : <component_name>
<component name>
GENERIC MAP ( [generic mappings] )
PORT MAP ( [Port connections] );
51
Explicit form
[Declaration Section]
Implicit Constructs
Summary
Syntax:
<sourcen>;
Question:
What is the hardware representing this construct?
Example:
Answer:
next_state <= green
53
The SIGNAL
SIGNALss in the body of an ARCHITECTURE
represent the wires of the system connecting the PORTs
p
and the operators
<source1>
<source2>
<signal_name>
<condition>
PROCESS
PROCESSes
es and COMPONENT
COMPONENTss execute in parallel
Sanchez, Ienne, Kluter 2007
54
Reminder
Processes and Components
Each element or box in our ARCHITECTURE BODY is a process:
p
<process_name> : PROCESS ([Sensitivity List])
Sequential Logic
Explicit form
[Declaration Section]
BEGIN
[Process description]
END PROCESS <process_name>;
Explicit processes
Latches
Flip flops and Registers
Flip-flops
Components
Implicit form
Or a component:
<component_reference>
<component
reference> : <component_name>
<component name>
GENERIC MAP ( [generic mappings] )
PORT MAP ( [Port connections] );
55
56
Explicit Process
Each
PROCESS has a
Each
unique name
a sensitivity list
Each
PROCESS has
a body
Note:
We can also just write END PROCESS;
57
58
Sensitivity List
Declaration Section
Explicit
p
PROCESSs are not inherentlyy sensitive to their inputs,
p , to make the
PROCESS sensitive to (and thus trigger on a change of) a SIGNAL, the
name of this SIGNAL can be put in the sensitivity list:
?
=
60
Variables
VARIABLE
VARIABLEss have a similar syntax as SIGNAL
SIGNALss
VARIABLE <variable_name>[, <variable_name>,] : <signal_type>;
It is good practice, but not required,
to prefix all variable names with v_
U i implicit
Using
i li it PROCESSes:
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
std_logic;
std_logic;
std_logic;
std_logic;
g ;
std_logic;
std_logic);
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee
ieee.std_logic_arith.all;
std logic arith all;
-------
<variable_name> := <source>;
BEGIN
SUM
<= A XOR B XOR Cin;
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
Cout <= s_x8;
Cprop <= s_x8 AND Cin;
END implementation_1;
Note:
We need := and not <=
61
BEGIN
Cprop <= s_x8 AND Cin;
SUM
<= A XOR B XOR Cin;
Cout <= s_x8;
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
END implementation_1;
?
=
BEGIN
adder : PROCESS( A , B , Cin )
VARIABLE v_x8 : std_logic;
BEGIN
Cprop <= v_x8 AND Cin;
SUM
<= A XOR B XOR Cin;
Cout <= v_x8;
v_x8 := (A AND B) OR (Cin AND (A XOR B));
END PROCESS adder;
END implementation_2;
Due to the fact that these are now inside the body of the process, they are
not any longer separate processes,
processes but statements.
statements And statements
execute in program order inside the body of an explicit process, and not
in parallel! We will go into more detail
VHDL A Compact Overview
-------
A input
B input
Carry input
S
Sum
output
t t
Carry propagate
Carry output
ARCHITECTURE implementation
p
_2 OF full_adder IS
BEGIN
adder : PROCESS( A , B , Cin )
VARIABLE v_x8 : std_logic;
BEGIN
SUM
<= A XOR B XOR Cin;
v_x8 := (A AND B) OR (Cin AND (A XOR B));
Cout <= v_x8;
Cprop <= v_x8 AND Cin;
END PROCESS adder;
END implementation_2;
example : PROCESS( A , B , C )
BEGIN
C <= A OR B;
IF (A AND B) = 1 THEN
C <= 0;
END IF;
X2 <= C;
END PROCESS example;
Th
These
two
t
implementations
i l
t ti
are nott equal!
l!
63
std_logic;
std_logic;
std_logic;
std_logic;
td l i
std_logic;
std_logic);
62
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
A input
B input
Carry input
Sum output
p
Carry propagate
Carry output
U i one explicit
Using
li it PROCESS:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
64
Explicit Constructs
It
Itss getting even more strange
strange , as VARIABLEss are
assigned immediately in explicit PROCESSes, hence :=
g immediately
y
means assign
IMPORTANT:
Thus
:= can ONLY be used with variables!
example : PROCESS( A , B , C )
VARIABLE v_x : std_logic;
BEGIN
v_x := A OR B;
IF (A AND B) = 1
1 THEN
v_x := 0;
END IF;
X2 <= v_x;
c <= v_x;
;
END PROCESS example;
65
66
Size Macros
WHEN OTHERS
=> [Statement(s)];
END CASE;
Explicit Constructs
67
s_bitwise_and(0)
s_bitwise_and(1)
s_bitwise_and(2)
s_bitwise_and(3)
bit i
d(3)
<=
<=
<=
<=
<
s_input_vector(0)
s_input_vector(1)
s_input_vector(2)
s_input_vector(3)
i
t
t (3)
AND
AND
AND
AND
s_bit;
s_bit;
s_bit;
s_bit;
bit
Note:
These macros do not equal
to a for loop as used in
For explicit process usage
C++, they merely
FOR n IN 3 DOWNTO 0 LOOP
help us to compact our
s_bitwise_and(n) <= s_input_vector(n) AND s_bit;
code
END LOOP;
Syntax
FOR <variable> IN <value1> DOWNTO <value2> LOOP
[Statement(s)]
END LOOP;
68
Summary
Summary
SUM
Cprop
Cin
s_x8
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY full_adder
full adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cprop: OUT
Cout : OUT
END full_adder;
-------
A input
B input
Carry input
Sum output
Carry propagate
Carry output
We have three
implicit processes
SIGNAL s
s_x8
x8 : std
std_logic;
logic;
BEGIN
SUM
<= A XOR B XOR Cin;
Cout <= s_x8;
C
Cprop
<
<= s_x8
8 AND Ci
Cin;
make_s8 : PROCESS( A , B , Cin )
BEGIN
s_x8 <= (A AND B) OR (Cin AND (A XOR B));
END PROCESS make_s8;
_
std_logic;
std_logic;
std_logic;
std_logic;
std_logic;
std_logic);
69
We have one
explicit process
END implementation_1;
Latches
70
Latches
Let
Letss look at the simulation behavior
d
clock
clock
clock
d
q
WX
W
X
Y
Z
XY Z
ZW X
Cout
Latches vs
vs. Muxes
Combinatorial or Sequential?
in0
start
start
clock ?
S ?
out
assign q
in1
clock
assign out
assign out
IF (<signal
(<signal_name>EVENT
name>EVENT AND <signal_name>
<signal name> = 1) THEN
END IF;
q is the output of a
sequential element
74
END IF;
;
75
end
All paths between start and end of the process
contain at least one assignment to out
A signal
g
with an EVENT modifier evaluates to true if there has
been a high to low or low to high transition
IF <signal
g
_name>EVENT THEN
END IF;
end
At least one path between start and end of the
process contains no assignment to q
?
Sanchez, Ienne, Kluter 2007
Let
Letss look at the simulation behavior
clock
d
q
WX
XY Z
ZWX
W clock triggers the PROCESS and there is a raising edge q takes the value of d
X an event on d triggers the PROCESS but there is no event on clock q keeps its previous value
Y an event on clock triggers the PROCESS but it is not a raising edge q keeps its previous value
Z an event on d triggers the PROCESS but there is no event on clock q keeps its previous value
77
Reset
NO
clock
Simulators
understand
this
but most
synthesizers
ignore
sensitivity
lists and
understand
this!
Registers Signals,
Registers,
Signals and Ordering
A register does not have an initial state, and therefore needs a reset
Two types of reset
Note: We will always use registers with a reset, either
synchronous or asynchronous
Synchronous reset
flipflop : PROCESS ( clock , reset , d )
BEGIN
IF (clockEVENT and clock = 1) THEN
IF (reset = 1) THEN q <= 0;
ELSE q <= d;
END IF;
END IF;
END PROCESS flipflop;
reset
0
?
=
YES!
The two processes are identical
Asynchronous reset
reset
0
d
s_q1
0
D
s_q2
q3
reset
clock
79
80
Registers Variables,
Registers,
Variables and Ordering
Delay_line : PROCESS ( clock , reset , d ,
s_q
q1 )
VARIABLE v_q2 : std_logic;
BEGIN
IF (clockEVENT AND clock = 1) THEN
IF (reset = 1) THEN s_q1 <= 0;
v q2 := 0;
v_q2
0 ;
q3
<= 0;
ELSE q3
<= v_q2;
v_q2 := s_q1;
s_q1 <= d;
END IF;
END IF;
END PROCESS Delay_line;
?
=
Components
NO!
The two processes are different!
Q s_q1
v_q2
q3
d
Q s_q1
clock
clock
81
ENTITY full_adder IS
PORT ( A
: IN
B
: IN
Cin : IN
SUM : OUT
Cout : OUT
END full_adder;
std_logic;
std
std_logic;
logic;
std_logic;
std_logic;
std_logic);
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
------
A input
B input
Carry input
Sum output
Carry output
ARCHITECTURE implementation
i l
t ti
OF full_adder
f ll dd
IS
BEGIN
SUM
Cout
END implementation;
ENTITY adder IS
PORT ( A
:
B
:
Cin :
SUM :
Cout :
END adder;
IN
IN
IN
OUT
OUT
q3
Summary
Signals Variables,
Signals,
Variables and Parallelism
Usage of Components
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
COMPONENT <entity_name>
PORT ( );
END COMPONENT;
reset
reset
Implicit and explicit PROCESSes are defined inside the body of the
ARCHITECTURE, and execute in parallel
Statements are defined inside the body of an explicit PROCESS, and
execute in program order
84
Summary
Sequential Components
Sequential elements can only be made by using an explicit PROCESS
Memory elements can only be introduced in case the PROCESS
contains a non-assigned
non assigned path
path, otherwise a multiplexer is described
There are two kinds of memory elements:
Latches:
latch : PROCESS ( clock , d )
BEGIN
IF (clock = 1) THEN
q <= d;
END IF;
END PROCESS latch;
clock
Flip-flops:
p p
flipflop : PROCESS ( clock , d )
BEGIN
IF (clockEVENT and clock = 1) THEN
q <= d;
END IF;
;
END PROCESS flipflop;
85