From 72e86d396c7236db1014987f7e24c00fa2d4504e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 9 Feb 2024 22:38:32 +0000 Subject: [PATCH] Add regression test for issue #703. --- ivtest/ivltests/br_gh703.v | 44 ++++++++++++++++++++++++++++++++++ ivtest/regress-vvp.list | 1 + ivtest/vvp_tests/br_gh703.json | 5 ++++ 3 files changed, 50 insertions(+) create mode 100644 ivtest/ivltests/br_gh703.v create mode 100644 ivtest/vvp_tests/br_gh703.json diff --git a/ivtest/ivltests/br_gh703.v b/ivtest/ivltests/br_gh703.v new file mode 100644 index 000000000..c6f4408af --- /dev/null +++ b/ivtest/ivltests/br_gh703.v @@ -0,0 +1,44 @@ +module test; + +logic [7:0] dout; +logic [7:0] sel; + +for (genvar i = 0; i < 8; i++) begin + if (i == 0) begin + + assign dout[i] = 1'b0; + + end else if (i == 1) begin + + assign dout[i] = 1'b1; + + end else begin + + // using always block reports error + always @(*) begin + if (sel[i]) dout[i] = 1'b1; + else dout[i] = 1'b0; + end + + end +end + +logic [7:0] expected; + +reg failed = 0; + +initial begin + sel = 8'd1; + repeat (8) begin + #1 $display("%b %b", sel, dout); + expected = sel & 8'b11111100 | 8'b00000010; + if (dout !== expected) failed = 1; + sel = sel << 1; + end + if (failed) + $display("FAILED"); + else + $display("PASSED"); +end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 4037559c9..eada3433a 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -27,6 +27,7 @@ br_gh383d vvp_tests/br_gh383d.json br_gh440 vvp_tests/br_gh440.json br_gh552 vvp_tests/br_gh552.json br_gh687 vvp_tests/br_gh687.json +br_gh703 vvp_tests/br_gh703.json br_gh710a vvp_tests/br_gh710a.json br_gh710b vvp_tests/br_gh710b.json br_gh710c vvp_tests/br_gh710c.json diff --git a/ivtest/vvp_tests/br_gh703.json b/ivtest/vvp_tests/br_gh703.json new file mode 100644 index 000000000..f609d49c3 --- /dev/null +++ b/ivtest/vvp_tests/br_gh703.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "br_gh703.v", + "iverilog-args" : [ "-g2009" ] +}