Add regression tests for packed array assignment patterns

Check that positional and nested positional assignment patterns are
supported for packed arrays. Also check that invalid assignment patterns
for packed arrays result in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-02-04 08:43:12 -08:00
parent 7f3621d47d
commit 4fca564614
6 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// Check that positional assigment patterns are supported for packed arrays.
module test;
bit [3:0][3:0] x = '{1'b1, 1 + 1, 3.0, "TEST"};
// Check nested assignment pattern
bit [1:0][3:0][3:0] y = '{'{1'b1, 1 + 1, 3.0, "TEST"},
'{5, 6, '{1'b0, 1 * 1, 3, 1.0}, 8}};
initial begin
if (x === 16'h1234 && y == 32'h12345678) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that positional assigment patterns are supported for packed array
// parameters.
module test;
localparam bit [2:0] x = '{1'b1, 2.0, 2 + 1};
initial begin
if (x === 3'b101) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,13 @@
// Check that an error is reported when specifing less elements in a packed
// array assignment pattern than the array size.
module test;
bit [2:0][3:0] x = '{1, 2}; // This should fail. Less elements than array
// size.
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,13 @@
// Check that an error is reported when specifing more elements in a packed
// array assignment pattern than the array size.
module test;
bit [2:0][3:0] x = '{1, 2, 3, 4}; // This should fail. More elements than
// array size.
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,13 @@
// Check that an error is reported when using an assignment pattern on a scalar
// type.
module test;
bit x = '{1'b1}; // This should fail. Can't use assignment pattern with
// scalar types
initial begin
$display("FAILED");
end
endmodule

View File

@ -520,6 +520,11 @@ struct_packed_write_read2 normal,-g2009 ivltests
struct_invalid_member CE,-g2009 ivltests gold=struct_invalid_member.gold
struct_signed normal,-g2009 ivltests
sv-constants normal,-g2005-sv ivltests
sv_ap_parray1 normal,-g2005-sv ivltests
sv_ap_parray2 normal,-g2005-sv ivltests
sv_ap_parray_fail1 CE,-g2005-sv ivltests
sv_ap_parray_fail2 CE,-g2005-sv ivltests
sv_ap_parray_fail3 CE,-g2005-sv ivltests
sv_assign_pattern_cast normal,-g2005-sv ivltests
sv_assign_pattern_const normal,-g2005-sv ivltests
sv_assign_pattern_concat normal,-g2005-sv ivltests