Skip to content

Conversation

kroening
Copy link
Collaborator

Verilog allows attributes (key-value pairs) in various parts of the grammar. These are now added to the generated parse tree.

@kroening kroening marked this pull request as ready for review August 25, 2024 21:33
Comment on lines +888 to +891
// | attribute_instance_brace udp_instantiation
// { add_attributes($2, $1); $$=$2; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this always commented out (and still is)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax is indistinguishable from the instantiation of normal modules unless a separate token type is used for the identifiers of UDP modules.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can document this in source via a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 944 to +952
// attribute_instance_brace class_property
// { add_attributes($2, $1); $$=$2; }
// | attribute_instance_brace class_method
// { add_attributes($2, $1); $$=$2; }
// | attribute_instance_brace class_constraint
// { add_attributes($2, $1); $$=$2; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was/is this commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classes are simply not done yet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be documented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 915 to 924
/*
module_or_generate_item
| attribute_instance_brace parameter_declaration { $$=$2; }
// | attribute_instance_brace local_parameter_declaration { $$=$2; }
| attribute_instance_brace parameter_declaration
// { add_attributes($2, $1); $$=$2; }
// | attribute_instance_brace local_parameter_declaration
// { add_attributes($2, $1); $$=$2; }
;
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was/is this commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not in the 1800-2017 grammar -- will clean out.

Comment on lines +172 to +174
PRECONDITION(stack_expr(attributes).id() == ID_verilog_attributes);
if(!stack_expr(attributes).get_sub().empty())
addswap(dest, ID_verilog_attributes, attributes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it perhaps be better to use ID_C_verilog_attributes? They seem to be ignored during type checking at this point, so I am guessing they don't affect the semantics?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe anything with attributes ever gets compared for equality, so it wouldn't make any difference.

The attributes seem to be entirely tool-specific, so there may well be some that have/alter semantics.

I am planning to use them to configure reasoning engines per assertion, but it's not obvious that this is the best mechanism.

Verilog allows attributes (key-value pairs) in various parts of the grammar.
These are now added to the generated parse tree.
@kroening kroening merged commit 5fd4feb into main Aug 27, 2024
8 checks passed
@kroening kroening deleted the add_attributes branch August 27, 2024 00:34
Romy15200 pushed a commit to Romy15200/nws that referenced this pull request Aug 19, 2025
Verilog: add attributes into parse tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants