From ebd574474c838d054defea691a5fbc8589a14beb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 4 Jun 2022 10:26:38 +0200 Subject: [PATCH] Add regression test for non-blocking event control to concatenation Check that a non-blocking event control assignment works as expected to a lvalue concatenation. All values that are part of the concatenation should only be assigned after the event triggers. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/nb_ec_concat.v | 104 +++++++++++++++++++++++++++++++++ ivtest/regress-vlg.list | 1 + 2 files changed, 105 insertions(+) create mode 100644 ivtest/ivltests/nb_ec_concat.v diff --git a/ivtest/ivltests/nb_ec_concat.v b/ivtest/ivltests/nb_ec_concat.v new file mode 100644 index 000000000..a27ae3a99 --- /dev/null +++ b/ivtest/ivltests/nb_ec_concat.v @@ -0,0 +1,104 @@ +// Check that non-blocking event control assignments to concatanations work as +// expected. + +module test; + reg failed = 1'b0; + + `define check(val, exp) \ + if (val !== exp) begin \ + $display("FAILED. %s: expected %b, got %b.", `"val`", exp, val); \ + failed = 1'b1; \ + end + + reg [3:0] x; + reg [3:0] y; + reg [3:0] z[1:0]; + + integer i = 0; + event e; + + initial begin + // Test all of + // * vector + // * vector part select + // * array element + // * array element part + + // Immediate index + {z[1][1:0],z[0],y[1:0],x} <= @e 12'h5a5; + #1 + // Assignment must not occur until the event is triggered + `check(z[1], 4'bxxxx) + `check(z[0], 4'bxxxx) + `check(y, 4'bxxxx) + `check(x, 4'bxxxx) + + ->e; + `check(z[1], 4'bxx01); + `check(z[0], 4'b0110); + `check(y, 4'bxx10); + `check(x, 4'b0101); + + x = 4'hx; + y = 4'hx; + z[0] = 4'hx; + z[1] = 4'hx; + + // Immediate index reverse order + {x,y[1:0],z[0],z[1][1:0]} <= @e 12'ha5a; + #1 + `check(z[1], 4'bxxxx) + `check(z[0], 4'bxxxx) + `check(y, 4'bxxxx) + `check(x, 4'bxxxx) + + ->e; + `check(z[1], 4'bxx10); + `check(z[0], 4'b0110); + `check(y, 4'bxx01); + `check(x, 4'b1010); + + x = 4'hx; + y = 4'hx; + z[0] = 4'hx; + z[1] = 4'hx; + + // Variable index + {z[i+1][i+:2],z[i],y[i+:2],x} <= @e 12'h5a5; + #1 + `check(z[1], 4'bxxxx) + `check(z[0], 4'bxxxx) + `check(y, 4'bxxxx) + `check(x, 4'bxxxx) + + ->e; + `check(z[1], 4'bxx01); + `check(z[0], 4'b0110); + `check(y, 4'bxx10); + `check(x, 4'b0101); + + x = 4'hx; + y = 4'hx; + z[0] = 4'hx; + z[1] = 4'hx; + + // Variable index reverse order + {x,y[i+:2],z[i],z[i+1][i+:2]} <= @e 12'ha5a; + #1 + `check(z[1], 4'bxxxx) + `check(z[0], 4'bxxxx) + `check(y, 4'bxxxx) + `check(x, 4'bxxxx) + + ->e; + `check(z[1], 4'bxx10); + `check(z[0], 4'b0110); + `check(y, 4'bxx01); + `check(x, 4'b1010); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index 9a15545ac..74b1c5ed1 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -676,6 +676,7 @@ muxtest normal ivltests # Validates that X sel and inputs same, output not X named_event_no_edges CE ivltests nb_assign normal ivltests nb_delay normal ivltests +nb_ec_concat normal ivltests nblkorder normal ivltests # Validates Non-blocking order determinism negative_genvar normal ivltests negvalue normal ivltests gold=negvalue.gold