Skip to content

fix(gen-verilog): array-param element index -> part-select (#1745) - #1748

Merged
gHashTag merged 1 commit into
masterfrom
fix/verilog-array-param-index
Aug 5, 2026
Merged

gHashTag merged 1 commit into
masterfrom
fix/verilog-array-param-index

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 5, 2026

Copy link
Copy Markdown
Owner

An [N]T array parameter lowers to a packed input [N*W-1:0] vector, but indexing it with a variable emitted a bit-select (xs[i]) instead of an element part-select — so it read one bit instead of the W-bit element. Confirmed by simulation: sum_arr([1,2,3,4]) returned 1, not 10.

Closes #1745

Fix

try_emit_primitive_array_access recognised only module- and local-scope packed arrays; array-typed parameters fell through to the naive bit-select. Added a param_types fallback (via primitive_array_info) so an array param is indexed by xs[i*W +: W], matching the packing used for its declaration.

Verification

Unblocks fully-parameterized loops over packed-array inputs — e.g. an N-chunk BitNet neuron over a [N]u64 weight/activation array (the neuron in #1746 had to use separate scalar params as a workaround).

🤖 Generated with Claude Code

An [N]T array parameter lowers to a packed input [N*W-1:0] vector, but
indexing it with a variable emitted a bit-select (xs[i]) instead of an
element part-select, reading one bit (sum_arr([1,2,3,4]) returned 1, not 10).
try_emit_primitive_array_access only recognised module/local packed arrays;
add a param_types fallback via primitive_array_info so array params index by
xs[i*W +: W]. Now sum_arr([1,2,3,4]) == 10.

New regression test tests/verilog_array_param_index.rs; full compiler suite
green (excl. pre-existing #1726); FROZEN_HASH re-sealed.

Closes #1745

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-05 19:12:10 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 0
PRs with All Checks Green 50
READY 0
FAILING 0
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=9393a1c6258f != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gen-verilog: packed-array param element index emits bit-select, not part-select

1 participant