From 1d623a67d104737cb5743808dea7253ef8fbff1b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 10 Jul 2026 07:50:06 -0700 Subject: [PATCH 1/2] Support discipline and nature names shadowing type identifiers Verilog-AMS nature and discipline declarations can use names that are also visible as type identifiers. The `potential` and `flow` discipline items can likewise reference a nature whose name is returned as `TYPE_IDENTIFIER` by the lexer. These grammar positions currently only accept `IDENTIFIER`. Use `identifier_name` for nature and discipline declaration names and for the `potential` and `flow` nature references. Signed-off-by: Lars-Peter Clausen --- parse.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parse.y b/parse.y index 4329c7c3f..dffeb9104 100644 --- a/parse.y +++ b/parse.y @@ -3614,7 +3614,7 @@ delay_value_simple optional_semicolon : ';' | ; discipline_declaration - : K_discipline IDENTIFIER optional_semicolon + : K_discipline identifier_name optional_semicolon { pform_start_discipline($2); } discipline_items K_enddiscipline { pform_end_discipline(@1); delete[] $2; } @@ -3630,14 +3630,14 @@ discipline_item { pform_discipline_domain(@1, IVL_DIS_DISCRETE); } | K_domain K_continuous ';' { pform_discipline_domain(@1, IVL_DIS_CONTINUOUS); } - | K_potential IDENTIFIER ';' + | K_potential identifier_name ';' { pform_discipline_potential(@1, $2); delete[] $2; } - | K_flow IDENTIFIER ';' + | K_flow identifier_name ';' { pform_discipline_flow(@1, $2); delete[] $2; } ; nature_declaration - : K_nature IDENTIFIER optional_semicolon + : K_nature identifier_name optional_semicolon { pform_start_nature($2); } nature_items K_endnature From 0e3ac8685cdad49b43f8c63937bc9da64f711437 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 10 Jul 2026 07:50:26 -0700 Subject: [PATCH 2/2] Add regression tests for discipline and nature type identifier names Check that nature and discipline declaration names can match visible type identifiers. Also check `potential` and `flow` references to nature names that are visible as type identifiers. Signed-off-by: Lars-Peter Clausen --- .../sv_type_identifier_discipline_name.v | 25 ++++++++++++++++++ ...sv_type_identifier_discipline_nature_ref.v | 26 +++++++++++++++++++ .../ivltests/sv_type_identifier_nature_name.v | 14 ++++++++++ ivtest/regress-vvp.list | 3 +++ .../sv_type_identifier_discipline_name.json | 5 ++++ ...type_identifier_discipline_nature_ref.json | 5 ++++ .../sv_type_identifier_nature_name.json | 5 ++++ 7 files changed, 83 insertions(+) create mode 100644 ivtest/ivltests/sv_type_identifier_discipline_name.v create mode 100644 ivtest/ivltests/sv_type_identifier_discipline_nature_ref.v create mode 100644 ivtest/ivltests/sv_type_identifier_nature_name.v create mode 100644 ivtest/vvp_tests/sv_type_identifier_discipline_name.json create mode 100644 ivtest/vvp_tests/sv_type_identifier_discipline_nature_ref.json create mode 100644 ivtest/vvp_tests/sv_type_identifier_nature_name.json diff --git a/ivtest/ivltests/sv_type_identifier_discipline_name.v b/ivtest/ivltests/sv_type_identifier_discipline_name.v new file mode 100644 index 000000000..a0615de42 --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_discipline_name.v @@ -0,0 +1,25 @@ +// Check that discipline names can match visible type identifiers. + +nature potential_nature; + units = "V"; + access = POTENTIAL_ACCESS; +endnature + +nature flow_nature; + units = "A"; + access = FLOW_ACCESS; +endnature + +typedef int DISCIPLINE_NAME; + +discipline DISCIPLINE_NAME; + potential potential_nature; + flow flow_nature; + domain continuous; +enddiscipline + +module test; + initial begin + $display("PASSED"); + end +endmodule diff --git a/ivtest/ivltests/sv_type_identifier_discipline_nature_ref.v b/ivtest/ivltests/sv_type_identifier_discipline_nature_ref.v new file mode 100644 index 000000000..24c9a6cba --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_discipline_nature_ref.v @@ -0,0 +1,26 @@ +// Check that discipline nature references can match visible type identifiers. + +nature potential_nature; + units = "V"; + access = POTENTIAL_ACCESS; +endnature + +nature flow_nature; + units = "A"; + access = FLOW_ACCESS; +endnature + +typedef int potential_nature; +typedef int flow_nature; + +discipline electrical; + potential potential_nature; + flow flow_nature; + domain continuous; +enddiscipline + +module test; + initial begin + $display("PASSED"); + end +endmodule diff --git a/ivtest/ivltests/sv_type_identifier_nature_name.v b/ivtest/ivltests/sv_type_identifier_nature_name.v new file mode 100644 index 000000000..1d2a9e174 --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_nature_name.v @@ -0,0 +1,14 @@ +// Check that nature names can match visible type identifiers. + +typedef int NATURE_NAME; + +nature NATURE_NAME; + units = "V"; + access = NATURE_ACCESS; +endnature + +module test; + initial begin + $display("PASSED"); + end +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 54997d6c5..50a325091 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -396,6 +396,8 @@ sv_type_identifier_attribute_name vvp_tests/sv_type_identifier_attribute_name.js sv_type_identifier_attribute_target vvp_tests/sv_type_identifier_attribute_target.json sv_type_identifier_block_label_name vvp_tests/sv_type_identifier_block_label_name.json sv_type_identifier_config_name vvp_tests/sv_type_identifier_config_name.json +sv_type_identifier_discipline_name vvp_tests/sv_type_identifier_discipline_name.json +sv_type_identifier_discipline_nature_ref vvp_tests/sv_type_identifier_discipline_nature_ref.json sv_type_identifier_enum_item_name vvp_tests/sv_type_identifier_enum_item_name.json sv_type_identifier_event_name vvp_tests/sv_type_identifier_event_name.json sv_type_identifier_for_name vvp_tests/sv_type_identifier_for_name.json @@ -413,6 +415,7 @@ sv_type_identifier_named_function_argument vvp_tests/sv_type_identifier_named_fu sv_type_identifier_named_parameter_value vvp_tests/sv_type_identifier_named_parameter_value.json sv_type_identifier_named_port_connection vvp_tests/sv_type_identifier_named_port_connection.json sv_type_identifier_named_task_argument vvp_tests/sv_type_identifier_named_task_argument.json +sv_type_identifier_nature_name vvp_tests/sv_type_identifier_nature_name.json sv_type_identifier_net_name vvp_tests/sv_type_identifier_net_name.json sv_type_identifier_package_item vvp_tests/sv_type_identifier_package_item.json sv_type_identifier_package_name vvp_tests/sv_type_identifier_package_name.json diff --git a/ivtest/vvp_tests/sv_type_identifier_discipline_name.json b/ivtest/vvp_tests/sv_type_identifier_discipline_name.json new file mode 100644 index 000000000..1947092fb --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_discipline_name.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_type_identifier_discipline_name.v", + "iverilog-args" : [ "-g2005-sv", "-gverilog-ams" ] +} diff --git a/ivtest/vvp_tests/sv_type_identifier_discipline_nature_ref.json b/ivtest/vvp_tests/sv_type_identifier_discipline_nature_ref.json new file mode 100644 index 000000000..d740f86fa --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_discipline_nature_ref.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_type_identifier_discipline_nature_ref.v", + "iverilog-args" : [ "-g2005-sv", "-gverilog-ams" ] +} diff --git a/ivtest/vvp_tests/sv_type_identifier_nature_name.json b/ivtest/vvp_tests/sv_type_identifier_nature_name.json new file mode 100644 index 000000000..89c0d37ec --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_nature_name.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_type_identifier_nature_name.v", + "iverilog-args" : [ "-g2005-sv", "-gverilog-ams" ] +}