Skip to content

Conversation

kroening
Copy link
Collaborator

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
Collaborator 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
@kroening kroening deleted the assignment_pattern branch June 30, 2024 07:40
Romy15200 pushed a commit to Romy15200/nws that referenced this pull request Aug 19, 2025
Verilog: assignment pattern expressions
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