Add regression test for foreach count direction

Check that foreach counts counts from $left to $right. This means it should
count up if $left is less than $right and count down otherwise.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-03-09 05:55:14 -08:00
parent e19d077d44
commit 6fc6826822
6 changed files with 2376 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
// Check that foreach counts from $left to $right for dynamic arrays and queues.
module test;
logic d[];
logic q[$];
initial begin
bit failed;
int exp_idx;
failed = 1'b0;
// Dynamic arrays and queues always count from 0 to $size - 1
d = '{0, 0};
exp_idx = 0;
foreach(d[idx]) begin
if (idx !== exp_idx) begin
$display("FAILED: Expected %0d, got %0d", exp_idx, idx);
failed = 1'b1;
end
exp_idx++;
end
q = '{0, 0, 0};
exp_idx = 0;
foreach(q[idx]) begin
if (idx !== exp_idx) begin
$display("FAILED: Expected %0d, got %0d", exp_idx, idx);
failed = 1'b1;
end
exp_idx++;
end
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -0,0 +1,13 @@
// Check that foreach counts from $left to $right for static arrays.
module test;
logic [0:1][2:0] x[0:6][4:0][11];
initial begin
foreach(x[i,j,k,l,n]) begin
$display(i, j, k, l, n);
end
end
endmodule

View File

@ -33,3 +33,5 @@ pr903 vvp_tests/pr903.json
pr903-vlog95 vvp_tests/pr903-vlog95.json
struct_packed_write_read vvp_tests/struct_packed_write_read.json
struct_packed_write_read2 vvp_tests/struct_packed_write_read2.json
sv_foreach9 vvp_tests/sv_foreach9.json
sv_foreach10 vvp_tests/sv_foreach10.json

View File

@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "sv_foreach10.v",
"iverilog-args" : [ "-g2009" ]
}

View File

@ -0,0 +1,6 @@
{
"type" : "normal",
"source" : "sv_foreach9.v",
"iverilog-args" : [ "-g2009" ],
"gold" : "sv_foreach9"
}