Reputation: 1
I have a condition on which certain variable will be set to 1. Here is this condition:
process(key, belt) is
begin
alarm <='0';
if key ='1' then
if Seconds > 4 and belt ='0' then
alarm <='1';
else
alarm <='0';
end if;
end if;
end process;
So, when the driver puts on the KEY, and if within 5 seconds he/she does not fasten the belt, then alarm goes ON. That is the idea. To test it, I have created a testbench file, and hardcoded when KEY is ON and when BELT is ON. Here is the code:
process is
begin
key<='1';
wait for 7000 ms;
key<='0';
wait for 7000 ms;
end process;
--simluate beltOn after 6sec
process is
begin
belt<='0';
wait for 6000 ms;
belt<='1';
wait for 4000 ms;
end process;
Basically, Key is initially on for 7 seconds, but belt is fastened only after 6 seconds, meaning that alarm should be ON within the interval of 5-6 seconds. However, when I simulate it on the software, alarm is OFF, and it does not operate for 14 seconds, but after that it successfully works. So that, if for example, on interval 30-35 belt is Off, alarm goes ON.
I have no idea why is that so. Can you give me a hand?
Upvotes: 0
Views: 155
Reputation: 271
Your process is run once each time one of the signals in the sensitivity list changes. Since seconds is not in the sensitivity list, pure passage of time won't trigger your process.
What it sees is the following:
Change of Key and Belt at time 0. Your process is run, the Key is in the ignition, but no 4 seconds have passed, so no alarm.
Change of Belt at 6 seconds, Belt is put on, so the key is in and the belt is strapped on. No alarm.
Key pulled out of ignition at 7 seconds. No key in the ignition so no alarm.
Change of Belt at 10 seconds. Belt is taken off, but key is not in the ignition, so no alarm.
Change of Key at 14 seconds (!). Belt is still off, key is in ignition and the time is larger than 4 seconds (it's 14 seconds). Alarm is active.
Upvotes: 1