From d4c35340e0a9e4e7df94ba6336bfb38fc52a201a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 5 Mar 2023 00:17:07 -0800 Subject: [PATCH] Add regression tests for continuous assignment of assignment patterns Check that packed array assignment patterns and struct assignment patterns are supported for continuous assignments. Check for both assignment to variables as well as array elements. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_ap_parray3.v | 21 +++++++++++++++++++++ ivtest/ivltests/sv_ap_parray4.v | 21 +++++++++++++++++++++ ivtest/ivltests/sv_ap_struct3.v | 32 ++++++++++++++++++++++++++++++++ ivtest/ivltests/sv_ap_struct4.v | 32 ++++++++++++++++++++++++++++++++ ivtest/regress-sv.list | 4 ++++ ivtest/regress-vlog95.list | 2 ++ 6 files changed, 112 insertions(+) create mode 100644 ivtest/ivltests/sv_ap_parray3.v create mode 100644 ivtest/ivltests/sv_ap_parray4.v create mode 100644 ivtest/ivltests/sv_ap_struct3.v create mode 100644 ivtest/ivltests/sv_ap_struct4.v diff --git a/ivtest/ivltests/sv_ap_parray3.v b/ivtest/ivltests/sv_ap_parray3.v new file mode 100644 index 000000000..e1ec2bca8 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray3.v @@ -0,0 +1,21 @@ +// Check that positional assignment patterns are supported for packed arrays +// when doing continuous assignments. + +module test; + + wire [3:0][3:0] x; + wire [1:0][3:0][3:0] y; + + assign x = '{1'b1, 32'h2, 3.0, "TEST"}; + assign y = '{'{1'b1, 1 + 1, 3.0, "TEST"}, + '{5, 6, '{1'b0, 1 * 1, 3, 1.0}, 8}}; + + final 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_parray4.v b/ivtest/ivltests/sv_ap_parray4.v new file mode 100644 index 000000000..722b03bb2 --- /dev/null +++ b/ivtest/ivltests/sv_ap_parray4.v @@ -0,0 +1,21 @@ +// Check that positional assignment patterns are supported for packed arrays +// when doing continuous assignments to array elements. + +module test; + + wire [3:0][3:0] x[2]; + wire [1:0][3:0][3:0] y[2]; + + assign x[0] = '{1'b1, 32'h2, 3.0, "TEST"}; + assign y[1] = '{'{1'b1, 1 + 1, 3.0, "TEST"}, + '{5, 6, '{1'b0, 1 * 1, 3, 1.0}, 8}}; + + final begin + if (x[0] === 16'h1234 && y[1] == 32'h12345678) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_struct3.v b/ivtest/ivltests/sv_ap_struct3.v new file mode 100644 index 000000000..64f9cf17a --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct3.v @@ -0,0 +1,32 @@ +// Check that positional assigment patterns are supported for structs when using +// continuous assignments. + +module test; + + typedef struct packed { + logic [31:0] x; + logic [15:0] y; + logic [7:0] z; + } T; + + T x; + + // Check nested assignment patterns + struct packed { + T x; + logic [2:0][3:0] y; + } y; + + assign x = '{1'b1, 2.0, 2 + 1}; + assign y = '{'{1'b1, 2.0, 2 + 1}, '{4, 5, 6}}; + + final begin + if (x === 56'h00000001000203 && + y === 68'h00000001000203456) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_struct4.v b/ivtest/ivltests/sv_ap_struct4.v new file mode 100644 index 000000000..0bc8a5630 --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct4.v @@ -0,0 +1,32 @@ +// Check that positional assigment patterns are supported for structs when using +// continuous assignments to array elements. + +module test; + + typedef struct packed { + logic [31:0] x; + logic [15:0] y; + logic [7:0] z; + } T; + + T x[2]; + + // Check nested assignment patterns + struct packed { + T x; + logic [2:0][3:0] y; + } y[2]; + + assign x[0] = '{1'b1, 2.0, 2 + 1}; + assign y[1] = '{'{1'b1, 2.0, 2 + 1}, '{4, 5, 6}}; + + final begin + if (x[0] === 56'h00000001000203 && + y[1] === 68'h00000001000203456) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index a3480f7a3..8048ad45d 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -521,11 +521,15 @@ 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_parray3 normal,-g2005-sv ivltests +sv_ap_parray4 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_ap_struct1 normal,-g2005-sv ivltests sv_ap_struct2 normal,-g2005-sv ivltests +sv_ap_struct3 normal,-g2005-sv ivltests +sv_ap_struct4 normal,-g2005-sv ivltests sv_ap_struct_fail1 CE,-g2005-sv ivltests sv_ap_struct_fail2 CE,-g2005-sv ivltests sv_assign_pattern_cast normal,-g2005-sv ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 8334da0eb..e901d8115 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -260,6 +260,8 @@ scan-invalid CE ivltests sel_rval_bit_ob CE ivltests sel_rval_part_ob CE ivltests signed_net_display CE,-pallowsigned=1 ivltests +sv_ap_parray4 CE,-g2005-sv ivltests +sv_ap_struct4 CE,-g2005-sv ivltests sv_array_cassign1 CE,-g2005-sv ivltests sv_array_cassign2 CE,-g2005-sv ivltests sv_array_cassign3 CE,-g2005-sv ivltests