Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
VHDL
Behavioral Modeling
3
Anatomy of a Process
The process statement is a concurrent statement , which
delineates a part of an architecture where sequential statements
are executed.
Syntax
[label:] process [(sensitivity list )]
declarations
begin
sequential statements
end process [label];
PROCESS with a SENSITIVITY LIST
List of signals to which the
process is sensitive.
Whenever there is an event on
any of the signals in the
sensitivity list, the process fires.
Every time the process fires, it label: process (sensitivity list
will run in its entirety. declaration part
WAIT statements are NOT begin
ALLOWED in a processes
with SENSITIVITY LIST. statement part
end process;
Concurrent VS sequential
Every statement inside the architecture body is
executed concurrently, except statements
enclosed by a process.
Process
Statements within a process are executed sequentially.
Result is known when the whole process is complete.
You may treat a process as one concurrent statement in
the architecture body.
Process(sensitivity list): when one or more signals in the
sensitivity list change state, the process executes once.
Process should either have sensitivity list or an explicit
wait statement. Both should not be present in the same
process statement.
6
Process contd..
The order of execution of statements is
the order in which the statements appear
in the process
All the statements in the process are
executed continuously in a loop .
The simulator runs a process when any
one of the signals in the sensitivity list
changes.
For a wait statement, the simulator
executes the process after the wait is over.
Example of Process with/without wait
process (clk,reset)
begin
if (reset = 1) then
A <= 0;
elsif (clkevent and clk = 1) then
A <= B;
end if;
end process;
process
begin
if (reset = 1) then
A <= 0 ;
elsif (clkevent and clk = 1) then
A <= B;
end if;
wait on reset, clk;
end process;
Lets Write a VHDL Model of Full Adder
using Behavioral Modeling
A ENTITY full_adder IS
PORT ( A, B, Cin : IN BIT;
Sum Sum, Cout : OUT BIT
);
B END full_adder;
Cout
Cin
Full Adder Architecture
A B Cin Sum Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1 for Cout (I.e. Carry Out):
Cin (I.e. Carry In)
AB 0 1
00 0 0
01 0 1
11 1 1
10 0 1
for Sum:
Cin (I.e. Carry In):
AB 0 1
00 0 1
01 1 0
11 0 1
10 1 0
Two Full Adder Processes
Summation:
PROCESS( A, B, Cin)
BEGIN
Sum <= A XOR B XOR Cin;
END PROCESS Summation;
A
Sum
B
Cout
Cin
Carry:
PROCESS( A, B, Cin)
BEGIN
Cout <= (A AND B) OR
(A AND Cin) OR
(B AND Cin);
END PROCESS Carry;
Complete Architecture
ARCHITECTURE example OF full_adder IS
-- Nothing needed in declarative block...
BEGIN
END example;
VHDL Sequential Statements
Assignments executed sequentially in processes
Sequential statements
{Signal, variable} assignments
Flow control
IF <condition> THEN <statements> [ELSIF <statements] [ELSE
<statements>] END IF;
FOR <range> LOOP <statements> END LOOP;
WHILE <condition> LOOP <statements> END LOOP;
CASE <condition> IS WHEN <value> => <statements>
{WHEN <value> => <statements>}
[WHEN others => <statements>]
END CASE;
WAIT [ON <signal>] [UNTIL <expression>] [FOR <time>] ;
ASSERT <condition> [REPORT <string>] [SEVERITY <level>] ;
The if statement
Syntax
if condition1 then
statements
[elsif condition2 then Priority
statements]
[else
statements]
end if;
An if statement selects one or none of a sequence of
events to execute . The choice depends on one or more
conditions.
The if statement contd.
if (sel = 00) then
if sel = 1 then o <= a;
c <= a; elsif sel = 01 then
else x <= b;
c <= b; elsif (color = red) then
end if; y <= c;
else
o <= d;
end if;
clk y
priority: PROCESS (clk) w
a priorit
BEGIN z
y
IF w(3) = '1' THEN b
y <= "11" ; c
ELSIF w(2) = '1' THEN
y <= "10" ;
All signals which appear on the left of
ELSIF w(1) = c THEN signal assignment statement (<=) are
y <= a and b; outputs e.g. y, z
ELSE
z <= "00" ; All signals which appear on the right of
END IF ;
signal assignment statement (<=) or in
logic expressions are inputs e.g. w, a,
END PROCESS ; b, c
All signals which appear in the
sensitivity list are inputs e.g. clk
Note that not all inputs need to be
included in the sensitivity list
BEHAVIORAL ( Processes using signals)
Sig1 = 2 + 3 = 5
Sig2 = 1
Sig3 = 2
Sum = 1 + 2 + 3 = 6
BEHAVIORAL ( Processes using Variables)
var1 = 2 + 3 = 5
var2 = 5
var3 = 5
Sum = 5 + 5 + 5 = 15
Loop, While & For Statement
Syntax
[label:] loop
{sequential_statement}
end loop [label];
Syntax
[label:] while condition loop
{sequential_statement}
end loop [label];
Syntax
[label:] for identifier in discrete_range
loop
{sequential_statement}
end loop [label];
For Loops
Add Function
WHILE LOOP :
Syntax :
loop_label: while condition loop
<sequence of statements>
end loop loop_label
null_statement::=
[ label : ] null ;
The null - statement explicitly prevents any action from being carried out.
This statement means do nothing.
This command can, for example, be used if default signal assignments have
been used in a process and an alternative in the case statement must not change
that value.
Null statement - example
architecture rtl of ex is
begin
p1: process (a)
begin
q1<=0;
q2<=0;
q3<=0;
case a is
when 00 => q1<=1;
when 10 => q2<=1;
q3<=1;
when others => null;
end case;
end process;
end;
Wait statement
wait_statement::=
[ label : ] wait [ sensitivity_clause ]
[ condition_clause ]
[ timeout_clause ] ;
Examples:
wait ;
The process is permanently interrupted.
wait for 5 ns ;
The process is interrupted for 5 ns.
wait on sig_1, sig_2 ;
The process is interrupted until the value of one of the
two signals changes.
wait until clock = '1' ;
The process is interrupted until the value of clock is 1.
Wait statement in a process
There are three ways of describing a wait statement in a process:
process (a,b)
wait until a=1
wait on a,b;
wait for 10 ns;
The first and the third are identical, if wait on a,b; is placed at the end of the
process:
p1: process
p0: process (a, b) begin
begin if a>b then
if a>b then q<=1;
q<=1; else
else q<=0;
q<=0; end if;
end if; wait on a,b;
end process; end process;
Features of the wait statement
In the first example the process will be triggered each time that signal a or b
changes value (aevent or bevent)
Wait on a,b; has to be placed at the end of the second example to be identical
with the first example because all processes are executed at stat-up until they
reach their first wait statement.
That process also executed at least once, which has sensitivity list and there
is no changes in the values of the list members
If a wait on is placed anywhere else, the output signals value will be different
when simulation is started.
If a sensitivity list is used in a process, it is not permissible to use a wait
command in the process.
It is permissible, however, to have several wait commands in the same process.
Details of the waits types
Wait until a=1; means that, for the wait condition to be satisfied and
execution of the code to continue, it is necessary for signal a to have an event,
i.e. change value, and the new value to be 1, i.e. a rising edge for signal a.
Wait on a,b; is satisfied when either signal a or b has an event (changes value).
Wait for 10 ns; means that the simulator will wait for 10 ns before continuing
execution of the process.
The starting time point of the waiting is important and not the actual changes of any
signal value.
It is also permissible to use the wait for command as follows:
constant period:time:=10 ns;
wait for 2*period;
The wait alternatives can be combined into: wait on a until b=1 for 10 ns;,
but the process sensitivity list must never be combined with the wait
alternatives
Example: wait until a=1 for 10 ns;
The wait condition is satisfied when a changes value or after a wait of 10 ns
(regarded as an or condition).
Examples of wait statement
type a: in bit; c1, c2, c3, c4, c5, c6, c7: out bit;
10 20 30 40 50 60 time [ns]
C1
C2
C3
C4
C5
C6
C7
10 ns 20 ns
Wait statement in synthesis tools
Start Simulation
Delay
End Simulation
Delay Types
Input Output
delay
Transport Delay
Transport delay must be explicitly specified
I.e. keyword TRANSPORT must be used
Signal will assume its new value
after specified delay
Input Output
Input
Output
0 5 10 15 20 25 30 35
Inertial Delay
Provides for specification propagation delay and input
pulse width, i.e. inertia of output:
Input
Input Output
Output
0 5 10 15 20 25 30 35
Inertial Delay (cont.)
Example of gate with inertia smaller than propagation
delay
e.g. Inverter with propagation delay of 10ns which suppresses
pulses shorter than 5ns
Input
Output
0 5 10 15 20 25 30 35
Note: the REJECT feature is new
to VHDL 1076-1993
Delta Delay
Default signal assignment propagation delay if no delay
is explicitly prescribed
VHDL signal assignments do not take place immediately
Delta is an infinitesimal VHDL time unit so that all signal
assignments can result in signals assuming their values at a
future time
E.g. Output <= NOT Input;
-- Output assumes new value in one delta cycle