ast: Add support for array-to-array assignment#5630
Open
apullin wants to merge 1 commit intoYosysHQ:mainfrom
Open
ast: Add support for array-to-array assignment#5630apullin wants to merge 1 commit intoYosysHQ:mainfrom
apullin wants to merge 1 commit intoYosysHQ:mainfrom
Conversation
whitequark
reviewed
Jan 23, 2026
Member
whitequark
left a comment
There was a problem hiding this comment.
This looks okay to me, although I'm far from the expert on the Verilog frontend.
This approach will generate quite a lot of code if the arrays have large dimensions. Any thoughts on addressing that or (more likely) at least surfacing it as something other than OS resource exhaustion?
This commit adds support for SystemVerilog array-to-array assignment operations that were previously unsupported: 1. Direct array assignment: `b = a;` 2. Array ternary expressions: `out = sel ? a : b;` Both single-dimensional and multi-dimensional unpacked arrays are supported. The implementation expands these array operations during AST simplification into element-wise assignments. Example of now-supported syntax: ```systemverilog wire [7:0] state_regs[8]; wire [7:0] r[8]; wire [7:0] sel[8]; assign sel = condition ? state_regs : r; ``` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c2f7d00 to
deadaa9
Compare
Author
AFAIK, RTLIL just has to be a ton of entries, wires, ports - there's no bulk memory copy primitive, so combinational array assignment fundamentally requires N parallel paths. But large code gen is an issue: arrays of ~100K elements take ~3s, and ~1M elements can take 60s+. I added a warning for arrays over 10,000 elements. |
Member
|
I'm happy with a warning, and I don't think you can do better here, either. |
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.
This commit adds support for SystemVerilog array-to-array assignment operations that were previously unsupported:
b = a;out = sel ? a : b;Both single-dimensional and multi-dimensional unpacked arrays are supported. The implementation expands these array operations during AST simplification into element-wise assignments.
Example of now-supported syntax:
I was generating some verilog with Google XLS, and this pattern came up, and I found that it was not supported by Yosys.
Tests are added in
tests/svtypes/array_assign.sv.This collides with PR #2331, but that PR has been up for > 5 years. This implementation also addresses the review feedback from that PR, including support for array ternary expressions
(
out = sel ? a : b) and multi-dimensional unpacked arrays.