From 36a79568b70463af1b8af75496135270fb3d38b8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 9 Jul 2026 22:31:52 -0700 Subject: [PATCH] Add regression tests for attribute names matching type identifiers Check that a standard attribute name can match a visible typedef. Also check that the global `$attribute` extension can target a primitive whose name is visible as a type identifier. Signed-off-by: Lars-Peter Clausen --- .../sv_type_identifier_attribute_name.v | 12 ++++++++++ .../sv_type_identifier_attribute_target.v | 23 +++++++++++++++++++ ivtest/regress-vvp.list | 2 ++ .../sv_type_identifier_attribute_name.json | 5 ++++ .../sv_type_identifier_attribute_target.json | 5 ++++ 5 files changed, 47 insertions(+) create mode 100644 ivtest/ivltests/sv_type_identifier_attribute_name.v create mode 100644 ivtest/ivltests/sv_type_identifier_attribute_target.v create mode 100644 ivtest/vvp_tests/sv_type_identifier_attribute_name.json create mode 100644 ivtest/vvp_tests/sv_type_identifier_attribute_target.json diff --git a/ivtest/ivltests/sv_type_identifier_attribute_name.v b/ivtest/ivltests/sv_type_identifier_attribute_name.v new file mode 100644 index 000000000..0e3654347 --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_attribute_name.v @@ -0,0 +1,12 @@ +// Check that attribute names can match visible type identifiers. + +typedef int ATTR; + +(* ATTR = 1 *) +module test; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/ivltests/sv_type_identifier_attribute_target.v b/ivtest/ivltests/sv_type_identifier_attribute_target.v new file mode 100644 index 000000000..5b5b5bef7 --- /dev/null +++ b/ivtest/ivltests/sv_type_identifier_attribute_target.v @@ -0,0 +1,23 @@ +// Check that $attribute targets can match visible type identifiers. + +primitive ATTR_TYPE (out, in); + output out; + input in; + + table + 0 : 0; + 1 : 1; + endtable +endprimitive + +typedef int ATTR_TYPE; + +$attribute(ATTR_TYPE, "test", "true") + +module test; + + initial begin + $display("PASSED"); + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index b256f7422..04be7ee50 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -392,6 +392,8 @@ sv_soft_packed_union vvp_tests/sv_soft_packed_union.json sv_soft_packed_union_fail1 vvp_tests/sv_soft_packed_union_fail1.json sv_super_member_fail vvp_tests/sv_super_member_fail.json sv_type_identifier_ams_name_fields vvp_tests/sv_type_identifier_ams_name_fields.json +sv_type_identifier_attribute_name vvp_tests/sv_type_identifier_attribute_name.json +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_enum_item_name vvp_tests/sv_type_identifier_enum_item_name.json diff --git a/ivtest/vvp_tests/sv_type_identifier_attribute_name.json b/ivtest/vvp_tests/sv_type_identifier_attribute_name.json new file mode 100644 index 000000000..598982a44 --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_attribute_name.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_type_identifier_attribute_name.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/sv_type_identifier_attribute_target.json b/ivtest/vvp_tests/sv_type_identifier_attribute_target.json new file mode 100644 index 000000000..bb1ecb5f6 --- /dev/null +++ b/ivtest/vvp_tests/sv_type_identifier_attribute_target.json @@ -0,0 +1,5 @@ +{ + "type" : "normal", + "source" : "sv_type_identifier_attribute_target.v", + "iverilog-args" : [ "-g2005-sv" ] +}