Repository navigation
Read a select past an associative array's dimensions from the element (§7.8, §11.5.1, #956) - #957
Closed
chuanseng-ng wants to merge 3 commits into
Closed
chuanseng-ng wants to merge 3 commits into
chuanseng-ng wants to merge 3 commits into
Conversation
This was referenced Nov 8, 2026
chuanseng-ng
force-pushed
the
fix/assoc-elem-bit-read
branch
from
November 9, 2026 01:12
41c065e to
e92d929
Compare
Owner
|
Integrated as part of #959, which contains these two commits unchanged: f33558ea and the tests 434a7be0, with @chuanseng-ng's authorship preserved. Published in xezim 603c9bf3 with xezim-core 212dde0. |
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.
Fixes #956.
A select past the unpacked dimensions of an associative array selects into the element (§7.8, §7.4.6, §11.5.1).
a[7][3]onlogic [31:0] a [int]read the absent elementa[7][3]instead of bit 3 ofa[7], so it read the element default at the element's width (X for 4-state, 0 for 2-state).Change.
assoc_elem_select_read(src/compiler/simulator/collections.rs) runs in the Index read arm ofeval_exprbefore the associative-key handlers. When the selects already reach the array's declared associative depth (one fora[int], the registered shape forab[int][string]), it reads the element and applies the next select to it: a bit select for a one-dimensional packed element, or the packed slice for a multi-dimensional one. It mirrorsassoc_elem_bit_writeon the write path. Rows of multidimensional associative arrays, dynamic arrays and queues are left to the existing handlers. The check is skipped when the module has no associative arrays.Result (ticket reproducer):
a=1 ab=1 miss=0 m=1343b6d75a=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ab=0000000000000000 miss=00000000 m=xxxxxxxxxxxxxxxxa=1 ab=1 miss=0 m=1Tests.
tests/collections/assoc_elem_select_read.rs, 10 tests: each key type (int, typedef,string,[*]), variable key and bit, a generate block, a packed struct element, past a two-dimensional associative array, an absent element, a bit write then read, and guards for part-selects, whole-element reads and rows of multidimensional associative arrays and queues. 8 of 10 fail without the fix; the two guards pass on both.Suite. Rebased on
5ca27d9e(pinned core5b0b02e); the only conflict was the test list intests/collections.rs. Full suite on the head of #959, which contains this branch: 6348 passed, 0 failed, 1 ignored. Before the rebase, on this branch alone (base343b6d75, core60e6508): 6322 passed, 0 failed, 1 ignored. No new clippy or rustfmt findings on the changed lines.Notes and caches. The third commit adds the
NOTES.mdentry. The change is in the interpreter (src/compiler/simulator/); compiled-method instructions and the admit/decline decision are unchanged, soMETHOD_CACHE_COMPILER_SALTstays.Performance.
perfis not available on my machine (perf_event_paranoid=4), so no profile. On the read path the added cost is oneis_empty()check for modules without associative arrays; for modules with them, one walk of the Index chain and a map lookup before the existing handlers.Not in this PR: an associative element whose packed type is multi-dimensional, offset or ascending (
logic [3:0][7:0] p [int],logic [8:1] r [int],logic [0:7] u [int]) is not stored correctly. That has a separate cause and will be its own ticket and PR.