From ca6b8d376ab60758d1affce3188ec4dcaf485d16 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 6 Sep 2026 18:20:13 -0700 Subject: [PATCH] Add regression tests for module instances without port parentheses Verilog and SystemVerilog require parentheses on every module instance, even when the module has no ports (IEEE 1364-2005 12.1.2 and IEEE 1800-2023 23.3.2). Omitting them is not valid in any standard version. Icarus accepts arrayed instances such as `M m[1:0];` as an extension added by commit 2d498363d7f3 ("Handle instance array of port-less modules."). Check that other parentheses-less forms, such as `M m;` and `M a[1:0], b, c();`, remain rejected to avoid further deviations from the standard. Accepting scalar instances without parentheses would also conflict with SystemVerilog variable declarations such as `M m;`, where `M` names a type. Also check that the existing array extension and mixed instance lists such as `M a[1:0], b(), c[1:0];` remain accepted. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/module_instance_no_ports_fail.v | 8 ++++++++ .../module_instance_no_ports_mixed_fail.v | 8 ++++++++ .../ivltests/module_no_port_mixed_instances.v | 17 +++++++++++++++++ ivtest/regress-vvp.list | 3 +++ .../module_instance_no_ports_fail.json | 4 ++++ .../module_instance_no_ports_mixed_fail.json | 4 ++++ .../module_no_port_mixed_instances.json | 4 ++++ 7 files changed, 48 insertions(+) create mode 100644 ivtest/ivltests/module_instance_no_ports_fail.v create mode 100644 ivtest/ivltests/module_instance_no_ports_mixed_fail.v create mode 100644 ivtest/ivltests/module_no_port_mixed_instances.v create mode 100644 ivtest/vvp_tests/module_instance_no_ports_fail.json create mode 100644 ivtest/vvp_tests/module_instance_no_ports_mixed_fail.json create mode 100644 ivtest/vvp_tests/module_no_port_mixed_instances.json diff --git a/ivtest/ivltests/module_instance_no_ports_fail.v b/ivtest/ivltests/module_instance_no_ports_fail.v new file mode 100644 index 000000000..da2b5f639 --- /dev/null +++ b/ivtest/ivltests/module_instance_no_ports_fail.v @@ -0,0 +1,8 @@ +// Check that a scalar module instance requires port parentheses. + +module M; +endmodule + +module test; + M m; +endmodule diff --git a/ivtest/ivltests/module_instance_no_ports_mixed_fail.v b/ivtest/ivltests/module_instance_no_ports_mixed_fail.v new file mode 100644 index 000000000..c4c548856 --- /dev/null +++ b/ivtest/ivltests/module_instance_no_ports_mixed_fail.v @@ -0,0 +1,8 @@ +// Check that a mixed instance list cannot omit scalar port parentheses. + +module M; +endmodule + +module test; + M first [1:0], middle, last(); +endmodule diff --git a/ivtest/ivltests/module_no_port_mixed_instances.v b/ivtest/ivltests/module_no_port_mixed_instances.v new file mode 100644 index 000000000..77173f70e --- /dev/null +++ b/ivtest/ivltests/module_no_port_mixed_instances.v @@ -0,0 +1,17 @@ +// Check that an instance list can mix omitted and empty port lists. + +module M; + localparam VALUE = 1; +endmodule + +module test; + M first [1:0], middle(), last [1:0]; + + initial begin + if (first[0].VALUE !== 1 || first[1].VALUE !== 1 || + middle.VALUE !== 1 || last[0].VALUE !== 1 || last[1].VALUE !== 1) + $display("FAILED"); + else + $display("PASSED"); + end +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 00de5ee70..8ceea6ff5 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -174,6 +174,9 @@ memsynth9 vvp_tests/memsynth9.json memsynth9-synth vvp_tests/memsynth9-synth.json mix_reset vvp_tests/mix_reset.json mix_reset-synth vvp_tests/mix_reset-synth.json +module_instance_no_ports_fail vvp_tests/module_instance_no_ports_fail.json +module_instance_no_ports_mixed_fail vvp_tests/module_instance_no_ports_mixed_fail.json +module_no_port_mixed_instances vvp_tests/module_no_port_mixed_instances.json module_ordered_list1 vvp_tests/module_ordered_list1.json module_ordered_list2 vvp_tests/module_ordered_list2.json module_port_array1 vvp_tests/module_port_array1.json diff --git a/ivtest/vvp_tests/module_instance_no_ports_fail.json b/ivtest/vvp_tests/module_instance_no_ports_fail.json new file mode 100644 index 000000000..418bed903 --- /dev/null +++ b/ivtest/vvp_tests/module_instance_no_ports_fail.json @@ -0,0 +1,4 @@ +{ + "type" : "CE", + "source" : "module_instance_no_ports_fail.v" +} diff --git a/ivtest/vvp_tests/module_instance_no_ports_mixed_fail.json b/ivtest/vvp_tests/module_instance_no_ports_mixed_fail.json new file mode 100644 index 000000000..48720e9a4 --- /dev/null +++ b/ivtest/vvp_tests/module_instance_no_ports_mixed_fail.json @@ -0,0 +1,4 @@ +{ + "type" : "CE", + "source" : "module_instance_no_ports_mixed_fail.v" +} diff --git a/ivtest/vvp_tests/module_no_port_mixed_instances.json b/ivtest/vvp_tests/module_no_port_mixed_instances.json new file mode 100644 index 000000000..6851d60be --- /dev/null +++ b/ivtest/vvp_tests/module_no_port_mixed_instances.json @@ -0,0 +1,4 @@ +{ + "type" : "normal", + "source" : "module_no_port_mixed_instances.v" +}