From fdbcb1ed36a90ea6e7324513b58c01cae07fdd5a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 2 Sep 2024 10:54:45 +0200 Subject: [PATCH] ivtest: Add regression test for assignment with undefined delay Check that assignments with undefined delay get executed with zero delay. The assignment should not be skipped. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/vardly_undefined_vec.v | 53 ++++++++++++++++++++++ ivtest/regress-vvp.list | 1 + ivtest/vvp_tests/vardly_undefined_vec.json | 4 ++ 3 files changed, 58 insertions(+) create mode 100644 ivtest/ivltests/vardly_undefined_vec.v create mode 100644 ivtest/vvp_tests/vardly_undefined_vec.json diff --git a/ivtest/ivltests/vardly_undefined_vec.v b/ivtest/ivltests/vardly_undefined_vec.v new file mode 100644 index 000000000..6ad88f3a2 --- /dev/null +++ b/ivtest/ivltests/vardly_undefined_vec.v @@ -0,0 +1,53 @@ +module test; + // Test that delay values of 'z and 'x get treated as a zero delay. Check this + // for different types of assignments. The assignment should not be skipped. + + reg failed = 1'b0; + + `define check(expr, val) \ + if (expr !== val) begin \ + $display("FAILED(%0d): `%s`, expected %0x, got %0x", `__LINE__, `"expr`", val, expr); \ + failed = 1'b1; \ + end + + + integer delay_x = 32'hx; + wire [31:0] delay_z; + + reg [31:0] x; + reg [31:0] a[0:1]; + integer i = 0, j = 0; + + `define test(var) \ + // Non-blocking \ + var = 0; \ + var <= #delay_x 1; \ + #1 `check(var, 1) \ + var = 0; \ + var <= #delay_z 1; \ + #1 `check(var, 1) \ + // blocking \ + var = 0; \ + var = #delay_x 1; \ + `check(var, 1) \ + var = 0; \ + var = #delay_z 1; \ + `check(var, 1) + + initial begin + `test(x) + `test(x[0]) + `test(x[i]) + `test(a[0]) + `test(a[0][0]) + `test(a[0][j]) + `test(a[i]) + `test(a[i][0]) + `test(a[i][j]) + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 6f3d6da74..53a18766b 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -266,6 +266,7 @@ vams_abs2 vvp_tests/vams_abs2.json vams_abs2-vlog95 vvp_tests/vams_abs2-vlog95.json vams_abs3 vvp_tests/vams_abs3.json vams_abs3-vlog95 vvp_tests/vams_abs3-vlog95.json +vardly_undefined_vec vvp_tests/vardly_undefined_vec.json va_math vvp_tests/va_math.json warn_opt_sys_tf vvp_tests/warn_opt_sys_tf.json wreal vvp_tests/wreal.json diff --git a/ivtest/vvp_tests/vardly_undefined_vec.json b/ivtest/vvp_tests/vardly_undefined_vec.json new file mode 100644 index 000000000..41a134359 --- /dev/null +++ b/ivtest/vvp_tests/vardly_undefined_vec.json @@ -0,0 +1,4 @@ +{ + "type" : "normal", + "source" : "vardly_undefined_vec.v" +}