Collapse adjacent bit selects in swizzles to ranges - #674
Merged
Conversation
desmonddak
reviewed
Jul 1, 2026
desmonddak
reviewed
Jul 1, 2026
Contributor
|
I think this PR makes sense right now to get SV much cleaner. I could see pushing some of the optimizations into the base and leaving here some SV-specific conventions like [:7]. Otherwise, the collapse could be structural, and then the strings would come out from there unless we are avoiding structural change in the synth layer for this case. |
Contributor
Author
|
I agree, makes SV a lot cleaner and is pretty elegant and limited, we can look for additional opportunities for reuse when the situation actually presents itself |
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.
Description & Motivation
This improves generated SystemVerilog for swizzles by compacting descending contiguous single-bit selections into legal slice expressions.
Examples:
{a[7], a[6], a[5]}can now emit asa[7:5]{arr[0][1], arr[0][0]}can now emit asarr[0][1:0]The collapse is intentionally conservative. It only applies to descending contiguous bit selects from the same packed source, and leaves unsupported cases expanded, including ascending selections, adjacent pre-existing range operands, expression-based selects, nested swizzle boundaries, and unpacked array sources.
Related Issue(s)
N/A
Testing
Added new tests, updated some other tests
Backwards-compatibility
No
Documentation
No