Design Testing - VHDL test benches
VHDL Test Benches
entity test_bench_example is
end test_bench_example;
-- notice there are no inputs or output ports
architecture example of test_bench_example is
component vhdl_model
port(..... R : in std_logic;
ack
: out std_logic;
........)
end component;
signal R_test, ack_test : std_logic;
signal ......
begin
tester: process
wait until ack_test = '0';
R_test <= '1';
....
-- perhaps provide other data
wait until ack_test = '1';
R_test <= '0';
.....
end process tester;
C1: vhdl_model port map (..... R_test, ack_test, ....); -- the model
end example;
assert boolean-expression
report string-expression
severity severity-level;
If the boolean-expression is false, then the string-expression is displayed on the monitor along with the severity level. Severity-level can be
note,
warning,
error,
failure.
Action taken depends on the simulator.
Example - suppose VHDL model is supposed to generate data with even parity with ack_test:
wait until ack_test = '1';
parity := test_data(3) XOR test_data(2) XOR test_data(1) XOR test_data(0);
assert parity = '0'
report "Parity Error"
severity error;
R_test <= '0';
Also used in modeling flip-flops to check for timing problems:
check: process
begin
wait until clk'event and clk='1';
assert D'stable(setup_time)
report "Setup
Time Violation"
severity error;
wait for hold_time;
assert D'stable(hold_time)
report "Hold
Time Violation"
severity error;
end process check;