[Buffering][HandshakeToHW] Support unused arrays#748
Merged
Conversation
Unused arrays in C previously caused multiple assertions to fail during compilation. The main problem is in the conversion from handshake to HW: Since the memory interface is only generated for memrefs used in a memory interface op, an unused memref would lead to a signature mismatch between the block arguments of the generated `hw.module` and the `handshake.func`. This PR fixes the issue slightly ad-hoc by explicitly handling the case and dropping such memref arguments entirely during the lowering. This also required adjusting the testbench generator since it assumed a memory interface to always be present. Always generating a memory interface was considered but required much larger changes to the HDL output which seemed more difficult for now. Fixes #498
Jiahui17
reviewed
Feb 26, 2026
Member
There was a problem hiding this comment.
Should we do it in the handshake dialect instead (add a pass HandshakeDropUnusedMemRefArgs or something like that) so it is easier to spot this logic?
PS: we will remove HW from the flow completely at some point in the future
Collaborator
Author
There was a problem hiding this comment.
That is indeed much simpler 😅 and requires no changes in the testbench generation. PTAL
Member
|
DynamaticPass is also deprecated, and we want to systematically migrate them back to the plain Here was the discussion: #284
|
Jiahui17
approved these changes
Feb 26, 2026
Member
Jiahui17
left a comment
There was a problem hiding this comment.
Awesome! Thanks for the fix!
ziadomalik
pushed a commit
that referenced
this pull request
Mar 11, 2026
Unused arrays in C previously caused multiple assertions to fail during compilation. The main problem is in the conversion from handshake to HW: Since the memory interface is only generated for memrefs used in a memory interface op, an unused memref would lead to a signature mismatch between the block arguments of the generated `hw.module` and the `handshake.func`. This PR fixes the issue slightly ad-hoc by explicitly handling the case and dropping such memref arguments entirely during the lowering. This also required adjusting the testbench generator since it assumed a memory interface to always be present. Always generating a memory interface was considered but required much larger changes to the HDL output which seemed more difficult for now. Fixes #498
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Unused arrays in C previously caused multiple assertions to fail during compilation. The main problem is in the conversion from handshake to HW: Since the memory interface is only generated for memrefs used in a memory interface op, an unused memref would lead to a signature mismatch between the block arguments of the generated
hw.moduleand thehandshake.func.This PR fixes the issue slightly ad-hoc by explicitly handling the case and dropping such memref arguments entirely during the lowering. This also required adjusting the testbench generator since it assumed a memory interface to always be present.
Always generating a memory interface was considered but required much larger changes to the HDL output which seemed more difficult for now.
Fixes #498