Skip to content

Verilog: assignment pattern expressions #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

kroening
Copy link
Member

This adds support for struct and array literals to the SystemVerilog frontend by implementing the assignment_pattern_expression production rules.

@kroening kroening force-pushed the assignment_pattern branch 2 times, most recently from 0577307 to 09f605a Compare June 24, 2024 19:38
@kroening kroening marked this pull request as ready for review June 24, 2024 20:16
Comment on lines +1636 to +1657
if(dest_type.id() == ID_struct)
{
auto &struct_type = to_struct_type(dest_type);
auto &components = struct_type.components();

if(expr.operands().size() != components.size())
{
throw errort().with_location(expr.source_location())
<< "number of expressions does not match number of struct members";
}

for(std::size_t i = 0; i < components.size(); i++)
{
// rec. call
implicit_typecast(expr.operands()[i], components[i].type());
}

// turn into struct expression
expr.id(ID_struct);
expr.type() = dest_type;
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The earlier comment said these could become structs or arrays -- are the latter just not yet implemented?

Copy link
Member Author

Choose a reason for hiding this comment

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

Array case added.

@kroening kroening force-pushed the assignment_pattern branch 2 times, most recently from fc9f676 to f34f7e0 Compare June 25, 2024 21:40
This adds support for struct and array literals to the SystemVerilog
frontend by implementing the assignment_pattern_expression production rules.
@kroening kroening force-pushed the assignment_pattern branch from f34f7e0 to 8ee5500 Compare June 25, 2024 23:52
@kroening kroening merged commit f2f3a40 into main Jun 30, 2024
6 checks passed
@kroening kroening deleted the assignment_pattern branch June 30, 2024 07:40
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