diff --git a/ivtest/ivltests/sv_ap_struct1.v b/ivtest/ivltests/sv_ap_struct1.v new file mode 100644 index 000000000..728332e40 --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct1.v @@ -0,0 +1,28 @@ +// Check that positional assigment patterns are supported for structs. + +module test; + + typedef struct packed { + int x; + shortint y; + byte z; + } T; + + T x = '{1'b1, 2.0, 2 + 1}; + + // Check nested assignment patterns + struct packed { + T x; + bit [2:0][3:0] y; + } y = '{'{1'b1, 2.0, 2 + 1}, '{4, 5, 6}}; + + initial 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_struct2.v b/ivtest/ivltests/sv_ap_struct2.v new file mode 100644 index 000000000..424fb4c22 --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct2.v @@ -0,0 +1,22 @@ +// Check that positional assigment patterns are supported for structs are +// supported for parameters. + +module test; + + typedef struct packed { + int x; + shortint y; + byte z; + } T; + + localparam T x = '{1'b1, 2.0, 2 + 1}; + + initial begin + if (x === 56'h00000001000203) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_struct_fail1.v b/ivtest/ivltests/sv_ap_struct_fail1.v new file mode 100644 index 000000000..a744343d7 --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct_fail1.v @@ -0,0 +1,16 @@ +// Check that it is an error to provide less elements in a struct assignment +// pattern than there are members in the struct. + +module test; + + struct packed { + int x; + shortint y; + byte z; + } x = '{1, 2}; // This should fail. Less elements than required. + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_struct_fail2.v b/ivtest/ivltests/sv_ap_struct_fail2.v new file mode 100644 index 000000000..036b7ec2c --- /dev/null +++ b/ivtest/ivltests/sv_ap_struct_fail2.v @@ -0,0 +1,16 @@ +// Check that it is an error to provide more elements in a struct assignment +// pattern than there are members in the struct. + +module test; + + struct packed { + int x; + shortint y; + byte z; + } x = '{1, 2, 3, 4}; // This should fail. More elements than required. + + initial begin + $display("FAILED"); + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index d55c39ba7..df3af90a2 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -525,6 +525,10 @@ 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_ap_struct1 normal,-g2005-sv ivltests +sv_ap_struct2 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 sv_assign_pattern_const normal,-g2005-sv ivltests sv_assign_pattern_concat normal,-g2005-sv ivltests