A
Allan Herriman
Hi,
I occasionally come across a situation in which I have an architecture
with many if-generate constructs to select different options for some
design. Exactly one of the if-generates must evaluate to true and be
"generated".
In a big design I like to test this by having an unresolved signal
(initialised to false) that is set to true inside each of the if-
generates. I then need to use an assertion to check that the signal is
indeed true, indicating that exactly one of the if-generates is active.
I know I could do this in VHDL-2008 using if-else generate, but I'm using
tools from Xilinx
so I am restricted to using 20th century versions
of VHDL.
This has been working fine for me for years, but I just realised today
that my assertions hadn't actually been checking anything. (Which is
fine, 'cause my code never has bugs...)
I'm looking for pointers on the best way to express my assertion in VHDL
'93 or '01.
Alternatively, I'm looking for any other ways to test this aspect of my
design without using a signal.
E.g.
-- The remainder of this post is in VHDL
-- and can be compiled and simulated.
entity foo is
end entity foo;
architecture bar of foo is
signal sig : boolean := FALSE;
begin
sig <= TRUE; -- (inside an if-generate)
-- comment out previous line to test assertions
-- need to assert that sig is TRUE here
attempt_1 : assert sig
report "sig is false #1"
severity note;
-- attempt_1 fails
-- it indicates that sig is always FALSE,
-- regardless of its actual value, due to the
-- attempt_1 equivalent process running before
-- the delta in which sig gets its value
attempt_2 : assert sig or now = 0 ns
report "sig is false #2"
severity note;
-- attempt_2 fails
-- it indicates that sig is always TRUE,
-- regardless of its actual value
-- because the equivalent process runs when now = 0 ns
-- then does a wait on sig, which never has an event.
attempt_3 : postponed assert sig
report "sig is false #3"
severity note;
-- attempt_3 fails as well.
-- Postponed is meant to fix the delta race
-- we had with attempt_1, but it doesn't,
-- indicating that sig is always FALSE
-- regardless of its actual value.
-- (In which case, what is the point of having
-- postponed assert as part of the language? I must
-- be missing something here.)
attempt_5 : process
begin
wait for 0 ns;
assert sig
report "sig is false #5"
severity note;
wait;
end process attempt_5;
-- attempt_5 works correctly, but is really ugly
end architecture bar;
-- Regards,
-- Allan
I occasionally come across a situation in which I have an architecture
with many if-generate constructs to select different options for some
design. Exactly one of the if-generates must evaluate to true and be
"generated".
In a big design I like to test this by having an unresolved signal
(initialised to false) that is set to true inside each of the if-
generates. I then need to use an assertion to check that the signal is
indeed true, indicating that exactly one of the if-generates is active.
I know I could do this in VHDL-2008 using if-else generate, but I'm using
tools from Xilinx
of VHDL.
This has been working fine for me for years, but I just realised today
that my assertions hadn't actually been checking anything. (Which is
fine, 'cause my code never has bugs...)
I'm looking for pointers on the best way to express my assertion in VHDL
'93 or '01.
Alternatively, I'm looking for any other ways to test this aspect of my
design without using a signal.
E.g.
-- The remainder of this post is in VHDL
-- and can be compiled and simulated.
entity foo is
end entity foo;
architecture bar of foo is
signal sig : boolean := FALSE;
begin
sig <= TRUE; -- (inside an if-generate)
-- comment out previous line to test assertions
-- need to assert that sig is TRUE here
attempt_1 : assert sig
report "sig is false #1"
severity note;
-- attempt_1 fails
-- it indicates that sig is always FALSE,
-- regardless of its actual value, due to the
-- attempt_1 equivalent process running before
-- the delta in which sig gets its value
attempt_2 : assert sig or now = 0 ns
report "sig is false #2"
severity note;
-- attempt_2 fails
-- it indicates that sig is always TRUE,
-- regardless of its actual value
-- because the equivalent process runs when now = 0 ns
-- then does a wait on sig, which never has an event.
attempt_3 : postponed assert sig
report "sig is false #3"
severity note;
-- attempt_3 fails as well.
-- Postponed is meant to fix the delta race
-- we had with attempt_1, but it doesn't,
-- indicating that sig is always FALSE
-- regardless of its actual value.
-- (In which case, what is the point of having
-- postponed assert as part of the language? I must
-- be missing something here.)
attempt_5 : process
begin
wait for 0 ns;
assert sig
report "sig is false #5"
severity note;
wait;
end process attempt_5;
-- attempt_5 works correctly, but is really ugly
end architecture bar;
-- Regards,
-- Allan