ivtest: Fix `assign` vs `initial` race condition in some tests

The first evaluation of an `assign` statement is scheduled at the same time as
`initial` statements.

There are some test cases that evaluate the result of an `assign` statement
in an `initial` statement. This is an inherent race condition and might
fail depending on the exact order of evaluation.

To fix this add an additional delay in the `initial` block. This will make
sure that all `assign` statements get fully resolved first.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-12-23 19:55:14 -08:00
parent 192b6aec96
commit 9b1ac6ab50
2 changed files with 2 additions and 0 deletions

View File

@ -25,6 +25,7 @@ assign array6[2:1] = 8'h32;
reg failed = 0;
initial begin
#0
$display("%h", array1);
if (array1 !== 16'h4321) failed = 1;
$display("%h", array2);

View File

@ -33,6 +33,7 @@ mod_test dut(test_string[1:8]);
mod_test2 dut2(test_string[9:16]);
initial begin
#0
if(test_string !== "testTESTabcdefgh") begin
$display("FAILED");
$finish();