Skip to content
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

[codegen] Support genvars & generate loop, use in simple array updates. #1751

Conversation

cdleary
Copy link
Collaborator

@cdleary cdleary commented Nov 28, 2024

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.

@cdleary cdleary requested a review from meheff November 28, 2024 17:24
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.
@cdleary cdleary force-pushed the cdleary/2024-11-27-array-update-codegen-generate branch from b786977 to 8f21fe5 Compare November 28, 2024 18:48
@cdleary cdleary force-pushed the cdleary/2024-11-27-array-update-codegen-generate branch from 8f21fe5 to 79db38f Compare November 28, 2024 18:49
@copybara-service copybara-service bot merged commit 7632df0 into google:main Dec 2, 2024
6 checks passed
@hzeller
Copy link
Member

hzeller commented Dec 2, 2024

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants