diff --git a/ivtest/ivltests/sv_byte_array_string1.v b/ivtest/ivltests/sv_byte_array_string1.v new file mode 100644 index 000000000..bb0e621eb --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string1.v @@ -0,0 +1,45 @@ +// Check that string literals can be assigned to one-dimensional byte arrays. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %02h, got %02h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + byte desc [3:0] = "AB\n"; + byte asc [0:3]; + byte unsized [4]; + + assign asc = "AB\n"; + + initial begin + #1; + + `check(desc[3], 8'h41); + `check(desc[2], 8'h42); + `check(desc[1], 8'h0a); + `check(desc[0], 8'h00); + + `check(asc[0], 8'h41); + `check(asc[1], 8'h42); + `check(asc[2], 8'h0a); + `check(asc[3], 8'h00); + + unsized = "AB\n"; + `check(unsized[0], 8'h41); + `check(unsized[1], 8'h42); + `check(unsized[2], 8'h0a); + `check(unsized[3], 8'h00); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string2.v b/ivtest/ivltests/sv_byte_array_string2.v new file mode 100644 index 000000000..001a38830 --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string2.v @@ -0,0 +1,61 @@ +// Check that string literals can be assigned to nested byte arrays using +// assignment patterns. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %02h, got %02h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + byte desc [0:1][3:0] = '{"AB\n", "CD\t"}; + byte asc [1:0][0:3]; + byte unsized [2][4]; + + assign asc = '{"AB\n", "CD\t"}; + + initial begin + #1; + + `check(desc[0][3], 8'h41); + `check(desc[0][2], 8'h42); + `check(desc[0][1], 8'h0a); + `check(desc[0][0], 8'h00); + + `check(desc[1][3], 8'h43); + `check(desc[1][2], 8'h44); + `check(desc[1][1], 8'h09); + `check(desc[1][0], 8'h00); + + `check(asc[0][0], 8'h43); + `check(asc[0][1], 8'h44); + `check(asc[0][2], 8'h09); + `check(asc[0][3], 8'h00); + + `check(asc[1][0], 8'h41); + `check(asc[1][1], 8'h42); + `check(asc[1][2], 8'h0a); + `check(asc[1][3], 8'h00); + + unsized = '{"AB\n", "CD\t"}; + `check(unsized[0][0], 8'h41); + `check(unsized[0][1], 8'h42); + `check(unsized[0][2], 8'h0a); + `check(unsized[0][3], 8'h00); + + `check(unsized[1][0], 8'h43); + `check(unsized[1][1], 8'h44); + `check(unsized[1][2], 8'h09); + `check(unsized[1][3], 8'h00); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string3.v b/ivtest/ivltests/sv_byte_array_string3.v new file mode 100644 index 000000000..27ba42748 --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string3.v @@ -0,0 +1,46 @@ +// Check that string literals shorter than the target byte array are padded +// with null bytes. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %02h, got %02h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + byte desc [3:0] = "AB"; + byte asc [0:3]; + byte unsized [4]; + + assign asc = "AB"; + + initial begin + #1; + + `check(desc[3], 8'h41); + `check(desc[2], 8'h42); + `check(desc[1], 8'h00); + `check(desc[0], 8'h00); + + `check(asc[0], 8'h41); + `check(asc[1], 8'h42); + `check(asc[2], 8'h00); + `check(asc[3], 8'h00); + + unsized = "AB"; + `check(unsized[0], 8'h41); + `check(unsized[1], 8'h42); + `check(unsized[2], 8'h00); + `check(unsized[3], 8'h00); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string4.v b/ivtest/ivltests/sv_byte_array_string4.v new file mode 100644 index 000000000..0797f2fd3 --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string4.v @@ -0,0 +1,39 @@ +// Check that string literals longer than the target byte array are truncated. + +module test; + + bit failed = 1'b0; + + `define check(val, exp) do \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %02h, got %02h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + while(0) + + byte desc [1:0] = "ABC"; + byte asc [0:1]; + byte unsized [2]; + + assign asc = "ABC"; + + initial begin + #1; + + `check(desc[1], 8'h41); + `check(desc[0], 8'h42); + + `check(asc[0], 8'h41); + `check(asc[1], 8'h42); + + unsized = "ABCD"; + `check(unsized[0], 8'h41); + `check(unsized[1], 8'h42); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string_fail1.v b/ivtest/ivltests/sv_byte_array_string_fail1.v new file mode 100644 index 000000000..6f53c54ed --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string_fail1.v @@ -0,0 +1,8 @@ +// Check that string literals cannot be assigned to unpacked arrays whose +// element type is 4-state. + +module test; + + logic [7:0] value [0:3] = "AB"; // Error: target element type is 4-state + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string_fail2.v b/ivtest/ivltests/sv_byte_array_string_fail2.v new file mode 100644 index 000000000..16a04116e --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string_fail2.v @@ -0,0 +1,8 @@ +// Check that string literals cannot be assigned directly to multi-dimensional +// byte arrays. + +module test; + + byte value [0:1][0:3] = "AB"; // Error: string is not nested + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string_fail3.v b/ivtest/ivltests/sv_byte_array_string_fail3.v new file mode 100644 index 000000000..990fcca7f --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string_fail3.v @@ -0,0 +1,17 @@ +// Check that string literals cannot be connected to output byte array ports. + +module M ( + output byte out [0:1] +); + + initial begin + out = "CD"; + end + +endmodule + +module test; + + M i_m("AB"); // Error: output expression is not assignable + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string_fail4.v b/ivtest/ivltests/sv_byte_array_string_fail4.v new file mode 100644 index 000000000..886a0761b --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string_fail4.v @@ -0,0 +1,8 @@ +// Check that string literals cannot be assigned to unpacked arrays whose +// element type is narrower than 8 bits. + +module test; + + bit [6:0] value [0:3] = "AB"; // Error: target element type is too narrow + +endmodule diff --git a/ivtest/ivltests/sv_byte_array_string_fail5.v b/ivtest/ivltests/sv_byte_array_string_fail5.v new file mode 100644 index 000000000..86ddac25b --- /dev/null +++ b/ivtest/ivltests/sv_byte_array_string_fail5.v @@ -0,0 +1,8 @@ +// Check that string literals cannot be assigned to unpacked arrays whose +// element type is wider than 8 bits. + +module test; + + bit [8:0] value [0:3] = "AB"; // Error: target element type is too wide + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index c4f96dfa7..1dafa1a1f 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -226,6 +226,15 @@ sv_array_cassign6 vvp_tests/sv_array_cassign6.json sv_array_cassign7 vvp_tests/sv_array_cassign7.json sv_array_cassign8 vvp_tests/sv_array_cassign8.json sv_automatic_2state vvp_tests/sv_automatic_2state.json +sv_byte_array_string1 vvp_tests/sv_byte_array_string1.json +sv_byte_array_string2 vvp_tests/sv_byte_array_string2.json +sv_byte_array_string3 vvp_tests/sv_byte_array_string3.json +sv_byte_array_string4 vvp_tests/sv_byte_array_string4.json +sv_byte_array_string_fail1 vvp_tests/sv_byte_array_string_fail1.json +sv_byte_array_string_fail2 vvp_tests/sv_byte_array_string_fail2.json +sv_byte_array_string_fail3 vvp_tests/sv_byte_array_string_fail3.json +sv_byte_array_string_fail4 vvp_tests/sv_byte_array_string_fail4.json +sv_byte_array_string_fail5 vvp_tests/sv_byte_array_string_fail5.json sv_chained_constructor1 vvp_tests/sv_chained_constructor1.json sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json sv_chained_constructor3 vvp_tests/sv_chained_constructor3.json diff --git a/ivtest/vvp_tests/sv_byte_array_string1.json b/ivtest/vvp_tests/sv_byte_array_string1.json new file mode 100644 index 000000000..92f9ead44 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string1.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_byte_array_string1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string2.json b/ivtest/vvp_tests/sv_byte_array_string2.json new file mode 100644 index 000000000..8d1280a4b --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string2.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_byte_array_string2.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string3.json b/ivtest/vvp_tests/sv_byte_array_string3.json new file mode 100644 index 000000000..87dfe0e1e --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string3.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_byte_array_string3.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string4.json b/ivtest/vvp_tests/sv_byte_array_string4.json new file mode 100644 index 000000000..aef296194 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string4.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_byte_array_string4.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string_fail1.json b/ivtest/vvp_tests/sv_byte_array_string_fail1.json new file mode 100644 index 000000000..51aaf0658 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string_fail1.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_byte_array_string_fail1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string_fail2.json b/ivtest/vvp_tests/sv_byte_array_string_fail2.json new file mode 100644 index 000000000..000b19b4c --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string_fail2.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_byte_array_string_fail2.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string_fail3.json b/ivtest/vvp_tests/sv_byte_array_string_fail3.json new file mode 100644 index 000000000..b9c693937 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string_fail3.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_byte_array_string_fail3.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string_fail4.json b/ivtest/vvp_tests/sv_byte_array_string_fail4.json new file mode 100644 index 000000000..a4c171738 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string_fail4.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_byte_array_string_fail4.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_byte_array_string_fail5.json b/ivtest/vvp_tests/sv_byte_array_string_fail5.json new file mode 100644 index 000000000..a6a741748 --- /dev/null +++ b/ivtest/vvp_tests/sv_byte_array_string_fail5.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "sv_byte_array_string_fail5.v", + "iverilog-args" : [ "-g2005-sv" ] +}