From eb90bcf313589d487bb3464e05c8b1bc5882eeb5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 12 Jan 2025 20:18:20 -0800 Subject: [PATCH] Add regression tests for invalid casts to real Check that invalid casts to real are reported as an error. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/cast_real_invalid1.v | 12 ++++++++++++ ivtest/ivltests/cast_real_invalid2.v | 12 ++++++++++++ ivtest/ivltests/cast_real_invalid3.v | 12 ++++++++++++ ivtest/ivltests/cast_real_invalid4.v | 12 ++++++++++++ ivtest/regress-vvp.list | 4 ++++ ivtest/vvp_tests/cast_real_invalid1.json | 5 +++++ ivtest/vvp_tests/cast_real_invalid2.json | 5 +++++ ivtest/vvp_tests/cast_real_invalid3.json | 5 +++++ ivtest/vvp_tests/cast_real_invalid4.json | 5 +++++ 9 files changed, 72 insertions(+) create mode 100644 ivtest/ivltests/cast_real_invalid1.v create mode 100644 ivtest/ivltests/cast_real_invalid2.v create mode 100644 ivtest/ivltests/cast_real_invalid3.v create mode 100644 ivtest/ivltests/cast_real_invalid4.v create mode 100644 ivtest/vvp_tests/cast_real_invalid1.json create mode 100644 ivtest/vvp_tests/cast_real_invalid2.json create mode 100644 ivtest/vvp_tests/cast_real_invalid3.json create mode 100644 ivtest/vvp_tests/cast_real_invalid4.json diff --git a/ivtest/ivltests/cast_real_invalid1.v b/ivtest/ivltests/cast_real_invalid1.v new file mode 100644 index 000000000..64f5e3638 --- /dev/null +++ b/ivtest/ivltests/cast_real_invalid1.v @@ -0,0 +1,12 @@ +// Check that casting a string to real generates an error. + +module test; + + real r; + string s; + + initial begin + r = real'(s); // Error: Cast from string to real not allowed + end + +endmodule diff --git a/ivtest/ivltests/cast_real_invalid2.v b/ivtest/ivltests/cast_real_invalid2.v new file mode 100644 index 000000000..8e3f10d91 --- /dev/null +++ b/ivtest/ivltests/cast_real_invalid2.v @@ -0,0 +1,12 @@ +// Check that casting a array to real generates an error. + +module test; + + real r; + real a[10]; + + initial begin + r = real'(a); // Error: Cast from array to real not allowed + end + +endmodule diff --git a/ivtest/ivltests/cast_real_invalid3.v b/ivtest/ivltests/cast_real_invalid3.v new file mode 100644 index 000000000..bbcede088 --- /dev/null +++ b/ivtest/ivltests/cast_real_invalid3.v @@ -0,0 +1,12 @@ +// Check that casting a queue to real generates an error. + +module test; + + real r; + real q[$]; + + initial begin + r = real'(q); // Error: Cast from queue to real not allowed + end + +endmodule diff --git a/ivtest/ivltests/cast_real_invalid4.v b/ivtest/ivltests/cast_real_invalid4.v new file mode 100644 index 000000000..d73e14e10 --- /dev/null +++ b/ivtest/ivltests/cast_real_invalid4.v @@ -0,0 +1,12 @@ +// Check that casting a dynamic array to real generates an error. + +module test; + + real r; + real d[]; + + initial begin + r = real'(d); // Error: Cast from dynamic array to real not allowed + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 51fa355f8..ad5bb2317 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -72,6 +72,10 @@ case3 vvp_tests/case3.json casex_synth vvp_tests/casex_synth.json cast_int_ams vvp_tests/cast_int_ams.json cast_int_ams-vlog95 vvp_tests/cast_int_ams-vlog95.json +cast_real_invalid1 vvp_tests/cast_real_invalid1.json +cast_real_invalid2 vvp_tests/cast_real_invalid2.json +cast_real_invalid3 vvp_tests/cast_real_invalid3.json +cast_real_invalid4 vvp_tests/cast_real_invalid4.json comment1 vvp_tests/comment1.json constfunc4_ams vvp_tests/constfunc4_ams.json constfunc4_ams-vlog95 vvp_tests/constfunc4_ams-vlog95.json diff --git a/ivtest/vvp_tests/cast_real_invalid1.json b/ivtest/vvp_tests/cast_real_invalid1.json new file mode 100644 index 000000000..2de12011f --- /dev/null +++ b/ivtest/vvp_tests/cast_real_invalid1.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "cast_real_invalid1.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/cast_real_invalid2.json b/ivtest/vvp_tests/cast_real_invalid2.json new file mode 100644 index 000000000..c745a15a9 --- /dev/null +++ b/ivtest/vvp_tests/cast_real_invalid2.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "cast_real_invalid2.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/cast_real_invalid3.json b/ivtest/vvp_tests/cast_real_invalid3.json new file mode 100644 index 000000000..b86f7cad5 --- /dev/null +++ b/ivtest/vvp_tests/cast_real_invalid3.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "cast_real_invalid3.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/cast_real_invalid4.json b/ivtest/vvp_tests/cast_real_invalid4.json new file mode 100644 index 000000000..ff7b2992a --- /dev/null +++ b/ivtest/vvp_tests/cast_real_invalid4.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "cast_real_invalid4.v", + "iverilog-args" : [ "-g2005-sv" ] +}