Professional Documents
Culture Documents
Introduction
• Signal assignment statement is the most basic form of behavioral modeling.
Following is an example: a <= b;
This statement is read as a gets the value of b.
This statement is executed whenever signal b changes value.
Signal b is in the sensitivity list of this statement.
Whenever a signal in the sensitivity list of a signal assignment statement
changes value, the signal assignment statement is executed.
If the result of the execution is a new value that is different from the current
value of the signal, then an event is scheduled for the target signal.
If the result of the execution is the same value, then no event is scheduled
but a transaction is still generated.
A transaction is always generated when a model is evaluated, but only
signal value changes cause events to be scheduled.
Introduction
The next example shows how to introduce a nonzero delay value for the
assignment: a <= b after 10 ns;
This statement is read as a gets the value of b after 10 nanoseconds.
Both of the preceding statements are concurrent signal assignment
statements.
Both statements are sensitive to changes in the value of signal b.
Whenever b changes value, these statements execute and new values are
assigned to signal a.
Using concurrent signal assignment statement, simple AND gate can be
modeled as:
ENTITY and2 IS
PORT ( a, b : IN BIT; c : OUT BIT );
END and2;
ARCHITECTURE and2_behav OF and2 IS
BEGIN
c <= a AND b AFTER 5 ns;
END and2_behav;
AND Gate Design
The AND gate has two inputs a, b and one output c, as shown.
Value of signal c may be assigned a new value whenever either a or b changes
value.
With an AND gate, if a is a ‘0’ and b changes from a ‘1’ to a ‘0’, output c does
not change.
If the output does change value, then a transaction occurs which causes an
event to be scheduled on signal c; otherwise, a transaction occurs on signal c.
The entity design unit describes the ports of the and2 gate.
The architecture and2_behav contains one concurrent signal assignment
statement.
Value of the expression a and b is calculated first, and the resulting value from
the calculation is scheduled on output c, 5 nanoseconds from the time the
calculation is completed.
Mux Design
Next example shows signal assignment statements and demonstrates concept of concurrency.
This is the behavioral model for the 4 input mux:
ENTITY mux4 IS
PORT ( i0, i1, i2, i3, a, b : IN std_logic;
i0, i1, i2, i3, a, q : OUT std_logic);
END mux4;
ARCHITECTURE mux4 OF mux4 IS
SIGNAL sel: INTEGER;
BEGIN
WITH sel SELECT
q <= i0 AFTER 10 ns WHEN 0,
q <= i1 AFTER 10 ns WHEN 1,
q <= i2 AFTER 10 ns WHEN 2,
q <= i3 AFTER 10 ns WHEN 3,
q <= ‘X’ AFTER 10 ns WHEN OTHERS;
sel <= 0 WHEN a = ‘0’ AND b = ‘0’ ELSE
1 WHEN a = ‘1’ AND b = ‘0’ ELSE
2 WHEN a = ‘0’ AND b = ‘1’ ELSE
3 WHEN a = ‘1’ AND b = ‘1’ ELSE
4;
END mux4;
Transport Versus Inertial Delay
there are two types of delay that can be used for modeling behaviors.
Inertial delay is the most commonly used, while transport delay is used
where a wire delay model is required.
Inertia Delay
Inertial delay is the default in VHDL.
If no delay type is specified, inertial delay is used.
Inertial delay is the default because it behaves similarly to the actual device.
Transport Delay
Transport delay is not the default in VHDL and must be specified.
It represents a wire delay in which any pulse, no matter how small, is propagated
to the output signal delayed by the delay value specified.
Transport delay is especially useful for modeling delay line devices, wire delays on a
PC board, and path delays on an ASIC.
Inertial Delay Model
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY buf IS
PORT ( a : IN std_logic;
b : OUT std_logic);
END buf;
ARCHITECTURE buf OF buf IS
BEGIN
b <= a AFTER 20 ns;
END buf;
Transport Delay Model
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY delay_line IS
PORT ( a : IN std_logic;
b : OUT std_logic);
END delay_line;
ARCHITECTURE delay_line OF delay_line IS
BEGIN
b <= TRANSPORT a AFTER 20 ns;
END delay_line;
Simulation Deltas
Simulation deltas are used to order some types of events during a simulation.
Specifically, zero delay events must be ordered to produce consistent results.
If zero delay events are not properly ordered, results can be disparate between
different simulation runs.
An example of this is shown using the following circuit.
This circuit could be part of a clocking scheme in a complex device being modeled.
It probably would not be the entire circuit, but only a part of the circuit used to
generate the clock to the D flip-flop.
The circuit consists of an inverter, a NAND gate, and an AND gate driving the
clock input of a flip-flop component.
The NAND gate and AND gate are used to gate the clock input to the flip-flop.
Let’s examine the circuit operation, using a delta delay mechanism and
another mechanism.
Simulation Deltas
To use delta delay, all of the circuit components must have zero delay specified.
The delay for all three gates is specified as zero.
Let’s examine the non delta delay mechanism first.
When a falling edge occurs on signal A, the output of the inverter changes in 0 time.
Let’s assume that such an event occurs at time 10 nanoseconds.
The output of the inverter, signal B, changes to reflect the new input value.
When signal B changes, both the AND gate and the NAND gate are reevaluated.
For this example, the clock input is assumed to be a constant value ‘1’.
If the NAND gate is evaluated first, its new value is ‘0’.
When the AND gate evaluates, signal B is a ‘0’, and signal C is a ‘1’; therefore, the AND gate
predicts a new value of ‘0’.
But what happens if the AND gate evaluates first?
The AND gate sees a ‘1’ value on signal B, and a ‘1’ value on signal C before the NAND gate
has a chance to reevaluate.
The AND gate predicts a new value of ‘1’.
Simulation Deltas
• The NAND gate reevaluates and calculates its new value as ‘0’.
• The change on the output of the NAND gate causes the AND gate to reevaluate again.
• The AND gate now sees the value of B, a ‘1’ value, and the new value of signal C, a ‘0’ value.
• The AND gate now predicts a ‘0’ on its output.
• Both circuits arrive at the same value for signal D.
• However, when the AND gate is evaluated first, a rising edge, one delta delay wide, occurs on
signal D.
• This rising edge can clock the flip-flop, depending on how the flip-flop is modeled.
• The point of this discussion is that without a delta synchronization mechanism, the results of
the simulation can depend on how the simulator data structures are built.
• For instance, compiling the circuit the first time might make the AND gate evaluate first,
while compiling again might make the NAND gate evaluate first; simulation deltas prevent
this behavior from occurring.
• Evaluation of the circuit does not depend on order of evaluation of NAND gate or AND gate.
• The sequence occurs irrespective of the evaluation order of the AND or NAND gate.
• During the first delta time point of time 10 nanoseconds, signal A receives the value ‘0’.
• This causes the inverter to reevaluate with the new value.
Simulation Deltas
• The inverter calculates the new value for signal B, which is the value ‘1’.
• This value is not propagated immediately, but is scheduled for the next delta time point.
• The simulator then begins execution of delta time point 2.
• Signal B is updated to a ‘1’ value, and the AND gate and NAND gate are reevaluated.
• Both the AND gate and NAND gate now schedule their new values for the next delta time
point.
• When delta 3 occurs, signal D receives a ‘1’ value, and signal C receives a ‘0’ value.
• Because signal C also drives the AND gate, the AND gate is reevaluated and schedules its
new output for delta time point 4.
• To summarize, simulation deltas are an infinitesimal amount of time used as a
synchronization mechanism when 0 delay events are present.
• Delta delay is used whenever 0 delay is specified, as shown in the following:
a <= b AFTER 0 ns;
• Another case for using delta delay is when no delay is specified. For example: a <= b;
• In both cases, whenever signal b changes value from an event, signal a has a delta-delayed
signal assignment to it.
• An equivalent VHDL model of the circuit shown in Figure 2-6, except for the flip-flop, is
shown in the following
Simulation Deltas
ENTITY reg IS
PORT( a, clock : in bit
d : out bit);
END reg;
ARCHITECTURE test OF reg IS
SIGNAL b, c : bit;
BEGIN
b <= NOT(a); -- notice no delay
c <= NOT( clock AND b);
d <= c AND b;
END test;
Derivers
• A VHDL driver is one contributor to the overall value of a signal.
• A multiply driven signal has many drivers.
• Multiply driven signals are very useful for modeling a data bus, a
bidirectional bus, and so on.
• Correctly modeling these kinds of circuits requires the concept of signal
drivers.
• Values of all of the drivers are resolved together to create a single value for
the signal.
• The method of resolving all of the contributors into a single value is
through a resolution function.
• A resolution function is a designer written function that is called whenever
a driver of a signal changes value.
Driver Creation
LIBRARY IEEE;
USE WORK.std_logic_1164.ALL;
ENTITY mux IS
PORT (i0, i1, i2, i3, a, b: IN std_logic;
q : OUT std_logic);
END mux;
ARCHITECTURE bad OF mux IS
BEGIN
q <= i0 WHEN a = ‘0’ AND b = ‘0’ ELSE ‘0’;
q <= i1 WHEN a = ‘1’ AND b = ‘0’ ELSE ‘0’;
q <= i2 WHEN a = ‘0’ AND b = ‘1’ ELSE ‘0’;
q <= i3 WHEN a = ‘1’ AND b = ‘1’ ELSE ‘0’;
END BAD;
Better Multiple Derivers
LIBRARY IEEE;
USE WORK.std_logic_1164.ALL;
ENTITY mux IS
PORT (i0, i1, i2, i3, a, b: IN std_logic;
q : OUT std_logic);
END mux;
ARCHITECTURE better OF mux IS
BEGIN
q <= i0 WHEN a = ‘0’ AND b = ‘0’ ELSE
i1 WHEN a = ‘1’ AND b = ‘0’ ELSE
i2 WHEN a = ‘0’ AND b = ‘1’ ELSE
i3 WHEN a = ‘1’ AND b = ‘1’ ELSE
‘X’; --- unknown
END better;
Generics
ENTITY latch IS
PORT( d, clk : IN std_logic;
q, qb : OUT std_logic);
END latch;