From 4fca564614304cf56a737b0ff53f2f3015329b37 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 4 Feb 2023 08:43:12 -0800 Subject: [PATCH] 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 --- ivtest/ivltests/sv_ap_parray1.v | 19 +++++++++++++++++++ ivtest/ivltests/sv_ap_parray2.v | 16 ++++++++++++++++ ivtest/ivltests/sv_ap_parray_fail1.v | 13 +++++++++++++ ivtest/ivltests/sv_ap_parray_fail2.v | 13 +++++++++++++ ivtest/ivltests/sv_ap_parray_fail3.v | 13 +++++++++++++ ivtest/regress-sv.list | 5 +++++ 6 files changed, 79 insertions(+) create mode 100644 ivtest/ivltests/sv_ap_parray1.v create mode 100644 ivtest/ivltests/sv_ap_parray2.v create mode 100644 ivtest/ivltests/sv_ap_parray_fail1.v create mode 100644 ivtest/ivltests/sv_ap_parray_fail2.v create mode 100644 ivtest/ivltests/sv_ap_parray_fail3.v diff --git a/ivtest/ivltests/sv_ap_parray1.v b/ivtest/ivltests/sv_ap_parray1.v new file mode 100644 index 000000000..cff387408 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray1.v @@ -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 diff --git a/ivtest/ivltests/sv_ap_parray2.v b/ivtest/ivltests/sv_ap_parray2.v new file mode 100644 index 000000000..e8dc5e088 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray2.v @@ -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 diff --git a/ivtest/ivltests/sv_ap_parray_fail1.v b/ivtest/ivltests/sv_ap_parray_fail1.v new file mode 100644 index 000000000..1adc9aafc --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray_fail1.v @@ -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 diff --git a/ivtest/ivltests/sv_ap_parray_fail2.v b/ivtest/ivltests/sv_ap_parray_fail2.v new file mode 100644 index 000000000..56104fd73 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray_fail2.v @@ -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 diff --git a/ivtest/ivltests/sv_ap_parray_fail3.v b/ivtest/ivltests/sv_ap_parray_fail3.v new file mode 100644 index 000000000..7dd681103 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray_fail3.v @@ -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 diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index a888672ba..d55c39ba7 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -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