From 34876c88548041361850e2434fad5561921bc727 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 4 Jun 2022 13:00:55 +0200 Subject: [PATCH] Add additional regression test for non-blocking event control on array partsel Check that non-blocking event control assignments works on an array part select if the part select index is not an immediate value. This is a copy of the nb_ec_array_pv test, but using variable indices instead of immediate values. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/nb_ec_array_pv.v | 3 ++ ivtest/ivltests/nb_ec_array_pv2.v | 90 +++++++++++++++++++++++++++++++ ivtest/regress-ivl1.list | 1 + 3 files changed, 94 insertions(+) create mode 100644 ivtest/ivltests/nb_ec_array_pv2.v diff --git a/ivtest/ivltests/nb_ec_array_pv.v b/ivtest/ivltests/nb_ec_array_pv.v index ad0b5ab8c..a23ce06bc 100644 --- a/ivtest/ivltests/nb_ec_array_pv.v +++ b/ivtest/ivltests/nb_ec_array_pv.v @@ -1,3 +1,6 @@ +// Check that non-blocking event control assignment to a part select on a vector +// array works when using an immediate index. + module top; reg pass = 1'b1; diff --git a/ivtest/ivltests/nb_ec_array_pv2.v b/ivtest/ivltests/nb_ec_array_pv2.v new file mode 100644 index 000000000..b8434b5cb --- /dev/null +++ b/ivtest/ivltests/nb_ec_array_pv2.v @@ -0,0 +1,90 @@ +// Check that non-blocking event control assignment to a part select on a vector +// array works when using a variable index. + +module top; + reg pass = 1'b1; + + integer i = 0; + integer j = 1; + integer count; + reg [2:0] icount; + reg clk = 0; + reg [3:0] in = 4'h0; + reg [7:0] result [1:0]; + + always #10 clk = ~clk; + always #20 in = in + 4'h1; + + initial begin + count = 3; + i = 0; + result[j][i+:4] <= repeat(count) @(posedge clk) in; + if ($simtime != 0 || result[j] !== 8'bx) begin + $display("Failed repeat(3) blocked at %0t, expected 8'hxx, got %h", + $simtime, result[j]); + pass = 1'b0; + end + @(result[j]); + if ($simtime != 50 || result[j] !== 8'hx0) begin + $display("Failed repeat(3) at %0t, expected 8'hx0, got %h", + $simtime, result[j]); + pass = 1'b0; + end + + #15; + count = 0; + result[j][i+4+:4] <= repeat(count) @(posedge clk) in; + @(result[j]); // Reals happen faster so they can use an #0, vectors are slower. + if ($simtime != 65 || result[j] !== 8'h30) begin + $display("Failed repeat(0) at %0t, expected 8'h30, got %h", + $simtime, result[j]); + pass = 1'b0; + end + + #20; + count = -1; + result[j][i+5+:4] <= repeat(count) @(posedge clk) in; + @(result[j]); // Reals happen faster so they can use an #0, vectors are slower. + if ($simtime != 85 || result[j] !== 8'h90) begin + $display("Failed repeat(-1) at %0t, expected 8'h80, got %h", + $simtime, result[j]); + pass = 1'b0; + end + + #20; + result[j][i+4+:4] <= @(posedge clk) 4'h0; + result[j][i+4+:4] <= @(posedge clk) in; // This one sets the final value. + @(result[j]); + if ($simtime != 110 || result[j] !== 8'h50) begin + $display("Failed @ at %0t, expected 8'h50, got %h", + $simtime, result[j]); + pass = 1'b0; + end + + icount = 3'd2; + result[j][i+:4] <= @(posedge clk) 4'h1; + result[j][i+4+:4] <= repeat(icount) @(posedge clk) 4'h2; + result[j][i+1-:4] <= repeat(3) @(posedge clk) 4'h3; + @(result[j]); + if ($simtime != 130 || result[j] !== 8'h51) begin + $display("Failed first @ at %0t, expected 8'h51, got %h", + $simtime, result[j]); + pass = 1'b0; + end + @(result[j]); + if ($simtime != 150 || result[j] !== 8'h21) begin + $display("Failed second @ at %0t, expected 8'h21, got %h", + $simtime, result[j]); + pass = 1'b0; + end + @(result[j]); + if ($simtime != 170 || result[j] !== 8'h20) begin + $display("Failed third @ at %0t, expected 8'h20, got %h", + $simtime, result[j]); + pass = 1'b0; + end + + if (pass) $display("PASSED"); + $finish; + end +endmodule diff --git a/ivtest/regress-ivl1.list b/ivtest/regress-ivl1.list index 649d38043..effab3aac 100644 --- a/ivtest/regress-ivl1.list +++ b/ivtest/regress-ivl1.list @@ -185,6 +185,7 @@ ca_time_smtm normal ivltests gold=ca_time_smtm.gold nb_array_pv normal ivltests nb_ec_array normal ivltests nb_ec_array_pv normal ivltests +nb_ec_array_pv2 normal ivltests nb_ec_pv normal ivltests nb_ec_pv2 normal ivltests nb_ec_real normal ivltests