Wait until <signal>=1 never true in VHDL simulation
Homework? Exam?
You need to study the details as to how wait works. Wait always suspends for at least a delta cycle. The wait until only resumes when a signal in the condition changes and the expression is true. So how many transitions to '1' do you need here to get to your second report statement?
How many transitions to '1' do you have with:
signal r_CLK_TB : std_logic := '0';
...
r_CLK_TB <= '1' after 20 ns, '0' after 40 ns, '1' after 60 ns;
You need to study the details as to how wait works. Wait always suspends for at least a delta cycle. Wait until only resumes when a signal in the condition changes and the expression is true. So how many transitions to '1' do you need here?
What happens if you change r_CLK_TB to the following?
r_CLK_TB <= not r_CLK_TB after 20 ns ;
The behaviour is in the details of the wait statement (the details of wait that
Jim Lewis refers to). The reason is that the wait
statements has three
parts:
wait
[on sensitivity_list]
[until condition]
[for time_expression]; -- Only for timeout, and not relevant here
The wait
in the relevant code only has an until
part, so the
sensitivity_list is created according to VHDL standard: "If no sensitivity
clause appears, the sensitivity set is constructed according to the following
(recursive) rule: ...". The generated sensitivity_list will in this case
contain r_CLK_TB
.
The VHDL standard has an example that matches the code precisely, and this states that:
wait until r_CLK_TB = '1';
is identical to:
loop
wait on r_CLK_TB;
exit when r_CLK_TB = '1';
end loop;
So even though the wait
does not explicitly contain a wait until
r_CLK_TB'event
(as written in comment), the execution results in waiting until
an event on r_CLK_TB
in order to pass the first wait
in wait on r_CLK_TB
.
Is that intuitive... judge for yourself ;-)
So maybe the original code should be changes so:
wait until r_CLK_TB = '1';
is replaced with:
if r_CLK_TB /= '1' then
wait until r_CLK_TB = '1';
end if;
In this case both "GOT HERE" and "GOT HERE 2" are shown at 20 ns, since the condition of all three constructions will be TRUE here.