From 90a1168086a45b319f1aa75e7655982e93d69d5f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 4 Jun 2023 16:02:31 -0700 Subject: [PATCH] Add regression tests for unpacked array assignment patterns Check that basic assignment patterns are supported for unpacked arrays. Check that all of packed types, reals and string arrays are supported. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_ap_uarray1.v | 44 +++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray2.v | 45 ++++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray3.v | 44 +++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray4.v | 45 ++++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray5.v | 45 ++++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray6.v | 45 ++++++++++++++++++++++++ ivtest/ivltests/sv_ap_uarray_fail1.v | 13 +++++++ ivtest/ivltests/sv_ap_uarray_fail2.v | 13 +++++++ ivtest/regress-vvp.list | 8 +++++ ivtest/vvp_tests/sv_ap_uarray1.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray2.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray3.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray4.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray5.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray6.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray_fail1.json | 5 +++ ivtest/vvp_tests/sv_ap_uarray_fail2.json | 5 +++ 17 files changed, 342 insertions(+) create mode 100644 ivtest/ivltests/sv_ap_uarray1.v create mode 100644 ivtest/ivltests/sv_ap_uarray2.v create mode 100644 ivtest/ivltests/sv_ap_uarray3.v create mode 100644 ivtest/ivltests/sv_ap_uarray4.v create mode 100644 ivtest/ivltests/sv_ap_uarray5.v create mode 100644 ivtest/ivltests/sv_ap_uarray6.v create mode 100644 ivtest/ivltests/sv_ap_uarray_fail1.v create mode 100644 ivtest/ivltests/sv_ap_uarray_fail2.v create mode 100644 ivtest/vvp_tests/sv_ap_uarray1.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray2.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray3.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray4.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray5.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray6.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray_fail1.json create mode 100644 ivtest/vvp_tests/sv_ap_uarray_fail2.json diff --git a/ivtest/ivltests/sv_ap_uarray1.v b/ivtest/ivltests/sv_ap_uarray1.v new file mode 100644 index 000000000..b8279dd6a --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray1.v @@ -0,0 +1,44 @@ +// Check that procedural assignment of unpacked array assignment patterns is +// supported and a entries are assigned in the right order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + int x[3:0]; + int y[0:3]; + int z[4]; + + initial begin + x = '{1'b1, 1 + 1, 3.3, "TEST"}; + y = '{1'b1, 1 + 1, 3.3, "TEST"}; + z = '{1'b1, 1 + 1, 3.3, "TEST"}; + + `check(x[0], 1413829460); + `check(x[1], 3); + `check(x[2], 2); + `check(x[3], 1); + + `check(y[0], 1); + `check(y[1], 2); + `check(y[2], 3); + `check(y[3], 1413829460); + + `check(z[0], 1); + `check(z[1], 2); + `check(z[2], 3); + `check(z[3], 1413829460); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray2.v b/ivtest/ivltests/sv_ap_uarray2.v new file mode 100644 index 000000000..96d6befed --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray2.v @@ -0,0 +1,45 @@ +// Check that procedural assignment of unpacked array assignment patterns to +// multi-dimensional arrays is supported and entries are assigned in the right +// order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + int x[1:0][1:0]; + int y[1:0][0:1]; + int z[2][2]; + + initial begin + x = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + y = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + z = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + + `check(x[0][0], 1413829460); + `check(x[0][1], 3); + `check(x[1][0], 2); + `check(x[1][1], 1); + + `check(y[0][0], 3); + `check(y[0][1], 1413829460); + `check(y[1][0], 1); + `check(y[1][1], 2); + + `check(z[0][0], 1); + `check(z[0][1], 2); + `check(z[1][0], 3); + `check(z[1][1], 1413829460); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray3.v b/ivtest/ivltests/sv_ap_uarray3.v new file mode 100644 index 000000000..e225cbd53 --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray3.v @@ -0,0 +1,44 @@ +// Check that continuous assignment of unpacked array assignment patterns is +// supported and entries are assigned in the right order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + int x[3:0]; + int y[0:3]; + int z[4]; + + assign x = '{1'b1, 1 + 1, 3.3, "TEST"}; + assign y = '{1'b1, 1 + 1, 3.3, "TEST"}; + assign z = '{1'b1, 1 + 1, 3.3, "TEST"}; + + initial begin + `check(x[0], 1413829460); + `check(x[1], 3); + `check(x[2], 2); + `check(x[3], 1); + + `check(y[0], 1); + `check(y[1], 2); + `check(y[2], 3); + `check(y[3], 1413829460); + + `check(z[0], 1); + `check(z[1], 2); + `check(z[2], 3); + `check(z[3], 1413829460); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray4.v b/ivtest/ivltests/sv_ap_uarray4.v new file mode 100644 index 000000000..14de755f8 --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray4.v @@ -0,0 +1,45 @@ +// Check that continuous assignment of unpacked array assignment patterns to +// multi-dimensional arrays is supported and entries are assigned in the right +// order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + int x[1:0][1:0]; + int y[1:0][0:1]; + int z[2][2]; + + assign x = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + assign y = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + assign z = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + + initial begin + `check(x[0][0], 1413829460); + `check(x[0][1], 3); + `check(x[1][0], 2); + `check(x[1][1], 1); + + `check(y[0][0], 3); + `check(y[0][1], 1413829460); + `check(y[1][0], 1); + `check(y[1][1], 2); + + `check(z[0][0], 1); + `check(z[0][1], 2); + `check(z[1][0], 3); + `check(z[1][1], 1413829460); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray5.v b/ivtest/ivltests/sv_ap_uarray5.v new file mode 100644 index 000000000..5c29b94d8 --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray5.v @@ -0,0 +1,45 @@ +// Check that procedural assignment of unpacked real array assignment patterns +// to multi-dimensional arrays is supported and entries are assigned in the +// right order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val != exp) begin \ + $display("FAILED(%0d). '%s' expected %0f, got %0f", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + real x[1:0][1:0]; + real y[1:0][0:1]; + real z[2][2]; + + initial begin + x = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + y = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + z = '{'{1'b1, 1 + 1}, '{3.3, "TEST"}}; + + `check(x[0][0], 1413829460.0); + `check(x[0][1], 3.3); + `check(x[1][0], 2.0); + `check(x[1][1], 1.0); + + `check(y[0][1], 1413829460.0); + `check(y[0][0], 3.3); + `check(y[1][1], 2.0); + `check(y[1][0], 1.0); + + `check(z[0][0], 1.0); + `check(z[0][1], 2.0); + `check(z[1][0], 3.3); + `check(z[1][1], 1413829460.0); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray6.v b/ivtest/ivltests/sv_ap_uarray6.v new file mode 100644 index 000000000..870cfe8ee --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray6.v @@ -0,0 +1,45 @@ +// Check that procedural assignment of unpacked string array assignment patterns +// to multi-dimensional arrays is supported and entries are assigned in the +// right order. + +module test; + + bit failed; + + `define check(val, exp) do \ + if (val != exp) begin \ + $display("FAILED(%0d). '%s' expected %s, got %s", `__LINE__, `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + string x[1:0][1:0]; + string y[1:0][0:1]; + string z[2][2]; + + initial begin + x = '{'{"Hello", "World"}, '{"Array", "Pattern"}}; + y = '{'{"Hello", "World"}, '{"Array", "Pattern"}}; + z = '{'{"Hello", "World"}, '{"Array", "Pattern"}}; + + `check(x[0][0], "Pattern"); + `check(x[0][1], "Array"); + `check(x[1][0], "World"); + `check(x[1][1], "Hello"); + + `check(y[0][0], "Array"); + `check(y[0][1], "Pattern"); + `check(y[1][0], "Hello"); + `check(y[1][1], "World"); + + `check(z[0][0], "Hello"); + `check(z[0][1], "World"); + `check(z[1][0], "Array"); + `check(z[1][1], "Pattern"); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray_fail1.v b/ivtest/ivltests/sv_ap_uarray_fail1.v new file mode 100644 index 000000000..5229337fe --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray_fail1.v @@ -0,0 +1,13 @@ +// Check that an unpacked array assignment pattern with too many elements +// results in an error. + +module test; + + int x[1:0]; + + initial begin + x = '{1, 2, 3}; // Should fail, more elements in assignment pattern than + // array size. + end + +endmodule diff --git a/ivtest/ivltests/sv_ap_uarray_fail2.v b/ivtest/ivltests/sv_ap_uarray_fail2.v new file mode 100644 index 000000000..c950357f0 --- /dev/null +++ b/ivtest/ivltests/sv_ap_uarray_fail2.v @@ -0,0 +1,13 @@ +// Check that an unpacked array assignment pattern with not enough elements +// results in an error. + +module test; + + int x[1:0]; + + initial begin + x = '{1}; // Should fail, less elements in assignment pattern than array + // size. + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 9ed96d87b..e4bca4a36 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -45,6 +45,14 @@ pv_wr_fn_vec2 vvp_tests/pv_wr_fn_vec2.json pv_wr_fn_vec4 vvp_tests/pv_wr_fn_vec4.json struct_packed_write_read vvp_tests/struct_packed_write_read.json struct_packed_write_read2 vvp_tests/struct_packed_write_read2.json +sv_ap_uarray1 vvp_tests/sv_ap_uarray1.json +sv_ap_uarray2 vvp_tests/sv_ap_uarray2.json +sv_ap_uarray3 vvp_tests/sv_ap_uarray3.json +sv_ap_uarray4 vvp_tests/sv_ap_uarray4.json +sv_ap_uarray5 vvp_tests/sv_ap_uarray5.json +sv_ap_uarray6 vvp_tests/sv_ap_uarray6.json +sv_ap_uarray_fail1 vvp_tests/sv_ap_uarray_fail1.json +sv_ap_uarray_fail2 vvp_tests/sv_ap_uarray_fail2.json sv_array_cassign6 vvp_tests/sv_array_cassign6.json sv_array_cassign7 vvp_tests/sv_array_cassign7.json sv_foreach9 vvp_tests/sv_foreach9.json diff --git a/ivtest/vvp_tests/sv_ap_uarray1.json b/ivtest/vvp_tests/sv_ap_uarray1.json new file mode 100644 index 000000000..d16e847dc --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray1.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray2.json b/ivtest/vvp_tests/sv_ap_uarray2.json new file mode 100644 index 000000000..2ff7359ff --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray2.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray2.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray3.json b/ivtest/vvp_tests/sv_ap_uarray3.json new file mode 100644 index 000000000..3305072e6 --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray3.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray3.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray4.json b/ivtest/vvp_tests/sv_ap_uarray4.json new file mode 100644 index 000000000..91c883de0 --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray4.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray4.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray5.json b/ivtest/vvp_tests/sv_ap_uarray5.json new file mode 100644 index 000000000..a48c75dea --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray5.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray5.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray6.json b/ivtest/vvp_tests/sv_ap_uarray6.json new file mode 100644 index 000000000..118e64dea --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray6.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_ap_uarray6.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray_fail1.json b/ivtest/vvp_tests/sv_ap_uarray_fail1.json new file mode 100644 index 000000000..594e06961 --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray_fail1.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_ap_uarray_fail1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_ap_uarray_fail2.json b/ivtest/vvp_tests/sv_ap_uarray_fail2.json new file mode 100644 index 000000000..4b8648f6f --- /dev/null +++ b/ivtest/vvp_tests/sv_ap_uarray_fail2.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_ap_uarray_fail2.v", + "iverilog-args" : [ "-g2005-sv" ] +}