[codegen] Support genvars & generate loop, use in simple array updates. #1751
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we would create a lot of Verilog output spew (even for simple cases), which can choke downstream tools that are not accustomed to generated files.
This PR sets its sights a bit low and only handles a simple case (1D array of bits typed objects) to keep things a bit more manageable for review. We can extend this technique to nested generate loops in the future from this basis.
VAST note: generate loops are interesting in that they are not statement blocks in a sense, they are “AST construct yielding”, i.e. they yield AST constructs at elaboration time that are appropriate for the enclosing scope. Which is to say, it could be creating ModuleMembers even though the generate loop’s body block is seemingly “within” the direct module scope. As a result, we have the body for a generate loop be a sequence of VastNodes to avoid artificially limiting what can be placed inside of them; i.e. a StatementBlock is not usable in this context.