Enhance AUTO_TEMPLATE for unpacked array connections and merging - #1908
Open
anythingelse0 wants to merge 7 commits into
Open
Enhance AUTO_TEMPLATE for unpacked array connections and merging#1908anythingelse0 wants to merge 7 commits into
anythingelse0 wants to merge 7 commits into
Conversation
- preserve unmergeable unpacked ranges when mixed with numeric ranges - merge compatible ascending numeric unpacked ranges without expanding indexes - support signed single indexes and escaped identifiers in generated connections - add tpl_arr_edge regressions for mixed, signed, and escaped array cases - update tpl_arr_edge golden whitespace to match generated output
- preserve unmergeable unpacked ranges when mixed with numeric ranges - merge compatible ascending numeric unpacked ranges without expanding indexes - support signed single indexes and escaped identifiers in generated connections - add tpl_arr_edge regressions for mixed, signed, and escaped array cases - update tpl_arr_edge golden whitespace to match generated output
"[].[index]" connections previously warned "Couldn't Merge" even when the merged declaration was correct, e.g. an unpacked-array input feeding two instances made AUTOINPUT emit a spurious warning. Merge such ranges silently via min/max, the same way packed bits are merged; keep the warning only for mixes with unmergeable forms (descending or symbolic ranges). This also removes the O(n^2) overlap scan. Also report an error when "[].[@]" expands to an empty "[].[]" index because the instance name provides no value for @, instead of silently emitting a nonsense connection. Add a fanout regression test (unpacked-array input into two instances), and update goldens for the no-longer-warning cases.
wsnyder
requested changes
Jul 21, 2026
Remove lines about unpacked array connections from the AUTOWIRE limitations section as they are not applicable there.
Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>
Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>
anythingelse0
commented
Jul 22, 2026
anythingelse0
left a comment
Author
There was a problem hiding this comment.
- Remove inapplicable documentation about unpacked arrays in AUTOWIRE
- Apply formatting suggestion to unpacked array documentation
- Improve comment clarity for unpacked declaration handling"
Member
|
Looks good, I pushed some minor indent cleanups. As these changes are non-trival you need to email assign@fsf.org and complete a copyright assignment. Let me know when done and the name to commit under; Emacs does not allow anonymous commits. |
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.
Summary
Add support for connecting one element of an unpacked array per instance
in an AUTO_TEMPLATE, and have AUTOWIRE/AUTOINPUT declare the net as an
unpacked array covering all connected indexes.
expands it to:
Implementation
verilog-auto-inst-port: rewritesig[].[idx]so only the unpackedindex stays executable; the port ranges go into a
/*[bits].[idx]*/comment (extending the existing comment convention used for memory
ports), keeping the connection legal Verilog.
verilog-read-sub-decls-expr: canonicalize the comment back into anunpacked range so AUTOWIRE and friends can parse it; numeric indexes
become single-element ranges (
[2:2]), non-numeric indexes passthrough unchanged.
verilog-signals-combine-bus: merge ascending numeric unpacked rangesvia min/max into one covering range, the same way packed bits are
merged. Overlapping or duplicate ranges merge silently — an
unpacked-array net fanned out to several instances must not warn.
", Couldn't Merge" is kept only when a numeric range mixes with an
unmergeable form (descending like
[3:0], or symbolic like[IDX]),in which case the first unmergeable form wins so existing declarations
keep their direction/expression.
[].[@]on an instance whose name provides no value for@nowraises an error instead of silently emitting a nonsense connection.
Tests
tests/autoinst_tpl_array_index.v: basic expansion, duplicate elementindex (merges to a single-element range), non-numeric index.
tests/tpl_arr_edge.v: non-consecutive indexes, descending packed +ascending unpacked, multiple ports per template, mixed
mergeable/unmergeable forms, hard-coded index gaps, single instance,
descending instance order, overlapping ranges, signed ranges,
descending-vs-numeric and symbolic-vs-numeric conflicts, negative
single index, escaped identifiers, and a fanout regression test
(unpacked-array input feeding two instances stays warning-free in
AUTOINPUT).