Skip to content

Store associative array elements of multi-dimensional, offset and ascending packed types (§7.8, §7.4.1, #958) - #959

Closed
chuanseng-ng wants to merge 6 commits into
aionhw:mainfrom
chuanseng-ng:fix/assoc-packed-elem
Closed

chuanseng-ng wants to merge 6 commits into
aionhw:mainfrom
chuanseng-ng:fix/assoc-packed-elem

Conversation

@chuanseng-ng

@chuanseng-ng chuanseng-ng commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #958. Builds on #957: this branch contains its three commits, and the last three commits are this change.

An associative array's packed type describes its elements (§7.8, §7.4.1). For logic [3:0][7:0] p [int], logic [8:1] r [int] and logic [0:7] u [int], p[1] = 32'h11223344, r[1] = 8'h02 and u[1] = 8'h80 made no associative entry: the bookkeeping that describes a plain packed vector was also kept under the array's name, and the generic select paths took p[1] as a select into a scalar signal named p before the associative paths ran.

Change.

  • packed_nested_select (src/compiler/simulator/collections.rs) returns early for an associative root, so p[1] is no longer read or written as packed element 1 of a scalar p.
  • Simulator::new (src/compiler/simulator/initialization.rs) drops associative names from packed_signal_elem_widths (which made the context-width read of p[1] an 8-bit element) and from ascending_packed (which complete_ascending_ranges fills from the packed range, making u[1] = 8'h80 a bit write). It runs after complete_ascending_ranges. packed_full_dims keeps them; the associative paths use it for selects into an element.
  • assoc_elem_bit_write (src/compiler/simulator/assignments.rs) writes the whole slice of the leading packed dimension, so p[1][2] = 8'hFF writes 8 bits instead of one.
  • assoc_elem_select_read (from Read a select past an associative array's dimensions from the element (§7.8, §11.5.1, #956) #957) goes more than one packed dimension deep (p[1][1][4]).

Result (ticket reproducer):

Output
the reference simulator p=11223344 bits=32 n=1 p1=33 r=02 u=80 / p=11ff3344
xezim 343b6d75 p=44 bits=8 n=0 p1=xxxxxxxx r=xx u=0 / p=44
this branch p=11223344 bits=32 n=1 p1=33 r=02 u=80 / p=11ff3344

Tests. tests/collections/assoc_packed_elem.rs, 6 tests, expected values from the reference simulator: a multi-dimensional element stored whole, offset and ascending elements, selects into a packed-array element, a bit of a packed-array element (p[1][1][4]), slice and bit writes into elements, and a slice write that creates an element on a 2-state array. All 6 fail on #957's branch without this change.

Suite. Rebased on 5ca27d9e (pinned core 5b0b02e) with #957; the only conflict was the test list in tests/collections.rs. Full suite on this branch: 6348 passed, 0 failed, 1 ignored. No new clippy or rustfmt findings on the changed lines.

Notes and caches. The last commit adds the NOTES.md entry. The change is in the interpreter and setup (src/compiler/simulator/); compiled-method instructions and the admit/decline decision are unchanged, so METHOD_CACHE_COMPILER_SALT stays.

Performance. perf is not available on my machine (perf_event_paranoid=4), so no profile. The pruning in Simulator::new is a one-time pass over two maps at setup. On the select paths the added cost is one associative-name lookup in packed_nested_select; the write and read helpers already ran for associative arrays.

Known, not changed: an out-of-range part-select into an element's packed dimension (p[1][15:8] on logic [3:0][7:0]) reads the in-range byte instead of X; it is not covered by the tests.

@aionhw

aionhw commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Integrated by cherry-pick with @chuanseng-ng's authorship preserved: f33558ea, 434a7be0 (#956, the commits of #957) and 204cfcd8, 80ac751a (#958).

Follow-up 0741c8fe, 41ef2995: a part-select of a multi-dimensional packed element (p[1][3:2], +:, -:) read 0; it now selects whole elements.

Published in xezim 603c9bf3 with xezim-core 212dde0.
Validation: the full xezim suite passes (6610 tests, 0 failed, 1 ignored), with xezim-core 514 and parser 233 tests, the JIT smoke and DPI fallback tests, and a 1.92 MSRV check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants