Skip to content

Commit 0d2aaed

Browse files
author
Dmitrii Vasilev
committed
feat(igla): Wave Loop 818 — module-scope [455][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
Closes #1564
1 parent c2c6e5d commit 0d2aaed

12 files changed

Lines changed: 86991 additions & 65 deletions

.claude/plans/wave-loop-819.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Wave Loop 819 Plan
2+
3+
**Date:** 2026-07-29
4+
**Issue:** #1565
5+
**Branch:** `wave-loop-819`
6+
7+
## Goal
8+
Continue the mechanical module-scope packed array-of-struct ladder from `[455][2]^6 Pt` to the next rung, choosing among three cooperation variants.
9+
10+
## Variants
11+
12+
### A — `[457][2]^6 Pt` module-scope packed array-of-struct variable from call with indexed signed writes (recommended)
13+
14+
- Outer dimension increases by 2 to 457; inner dimensions stay `[2]^6`.
15+
- Expected witness: 29,184 elements, 933,888-bit packed vector (~0.891 MiBit).
16+
- Keeps the established mechanical generator pattern unchanged.
17+
- Generator `scripts/gen_w819.py` with `OUTER = 457`, `MID_IDX = 228`; fix copy hazard before first run.
18+
- Witness `specs/scratch/w819_bench_module_457x2p6_aos_var_call_write.t27`.
19+
- Add integration test `accepts_w819_bench_module_457x2p6_aos_var_call_write`.
20+
- Expected zero compiler / reference-model / FROZEN_HASH changes.
21+
22+
### B — `[455][3]^6 Pt` — grow the second inner dimension to stress stride scaling
23+
24+
- Keep outer dimension 455; change inner shape from `[2]^6` to `[3]^6`.
25+
- This exercises a different stride scaling direction: inner dimension 3 produces a 3^6 = 729 inner product, yielding 455 × 729 = 331,695 elements and 10,614,240 bits (~10.12 MiBit), which crosses the 4-MiBit cliff. Use only if the maintainers explicitly want to probe that boundary; otherwise it is intentionally more disruptive.
26+
27+
### C — `[455][2]^6 Pt` with negative-index writes to exercise wrap-around addressing
28+
29+
- Same outer/inner dimensions as variant A (455) but add negative signed index writes inside the bench block (e.g., `dst[-1][...] = ...`).
30+
- Verifies that the Verilog backend handles signed index wrap-around correctly.
31+
- Requires careful choice of negative indices so the wrapped positions are deterministic and the reference model agrees.
32+
33+
## Recommended variant
34+
35+
**A** — the mechanical ladder is still well below the 4-MiBit cliff at `[457][2]^6 Pt` (~0.891 MiBit), and the generator/test/seal pipeline is fully reusable. Variant A minimizes risk and keeps the ladder moving predictably.
36+
37+
## Acceptance criteria
38+
39+
- [ ] Generator `scripts/gen_w819.py` with `OUTER = 457`, `MID_IDX = 228`; copy hazard fixed before first run.
40+
- [ ] Witness `specs/scratch/w819_bench_module_457x2p6_aos_var_call_write.t27` generated and parsed.
41+
- [ ] `t27c icarus-lowerable`, `icarus-simulate`, `icarus-cocotb`, and `seal --save` all PASS.
42+
- [ ] Integration test `accepts_w819_bench_module_457x2p6_aos_var_call_write` added to `bootstrap/tests/icarus_lowerable.rs`.
43+
- [ ] `bootstrap/stage0/FROZEN_HASH` unchanged.
44+
- [ ] Closeout report, W820 cooperation plan, docs, skill tracker, autopilot skill, and persistent memory updated.
45+
- [ ] Commit with `Closes #1565`, push branch, open PR to `master`.

.claude/skills/t27-wave-loop.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,48 @@ both. Continue grepping for stale wave numbers and outer dimensions after each
23902390
copy, keep the `make_grid(32768)` period-identity check, and use `assert_eq` on
23912391
changed elements because `assert_ne` is not emitted by the Icarus simulation path.
23922392

2393+
## Worked example — Wave Loop 818
2394+
2395+
Wave Loop 818 extended the module-scope packed-array-of-struct ladder with no
2396+
compiler changes, branching from `wave-loop-817` HEAD because earlier wave PRs
2397+
remained open awaiting review:
2398+
2399+
- Generated `scripts/gen_w818.py` from `scripts/gen_w817.py` with `OUTER = 455`
2400+
and `MID_IDX = 227`.
2401+
- Fixed both the generator destination path and the module header f-string from
2402+
stale `w817` / `453` references to `w818_bench_module_455x2p6_aos_var_call_write`
2403+
before regenerating; also corrected the stale `MID_IDX` comment to `227`.
2404+
- Produced `specs/scratch/w818_bench_module_455x2p6_aos_var_call_write.t27`
2405+
(29,120 elements, 931,840-bit packed vector, ~0.889 MiBit).
2406+
- Added integration test `accepts_w818_bench_module_455x2p6_aos_var_call_write`
2407+
after the existing W817 tests in `bootstrap/tests/icarus_lowerable.rs`.
2408+
- Ran `t27c parse`, `icarus-lowerable`, `icarus-simulate` (17 cycles, PASSED),
2409+
`icarus-cocotb` (reference-model OK), and `t27c seal --save`.
2410+
- No changes to `bootstrap/src/compiler.rs`, `bootstrap/stage0/FROZEN_HASH`, or
2411+
`scripts/cocotb_ref_model.py` for the witness itself.
2412+
- Validation: `cargo build --release -p t27c` green,
2413+
`cargo clippy -p t27c` green (626 warnings, 0 errors),
2414+
`cargo test -p t27c --bin t27c` 1494/0/2, `cargo test -p tri` 78/0,
2415+
`cargo test -p flash-spi` 2/0,
2416+
`cargo test -p t27c --test bitnet_pipeline` 20/0,
2417+
`cargo test -p t27c --test bitnet_top` 17/0,
2418+
`cargo test -p t27c --test icarus_lowerable` 278/0,
2419+
`cargo test -p t27c --test verilog_const_array` 2/0.
2420+
- Refreshed weak-point audit and 2025–2026 ternary/MVL literature scan.
2421+
- Wrote `docs/reports/FPGA_LOOP_CLOSEOUT_W818_2026-07-29.md` and
2422+
`.claude/plans/wave-loop-819.md` with three cooperation variants.
2423+
- Updated `.claude/skills/wave-loop-autopilot.md` run-list and status.
2424+
- Updated this skill's Live Wave Loop Tracker to wave 819.
2425+
2426+
Key learning: the mechanical ladder is now 45 waves deep (W774–W818) with zero
2427+
compiler changes, confirming the packed-vector AoS lowering is robust up to at
2428+
least `[455][2]^6 Pt` (29,120 elements, ~0.889 MiBit). The generator copy hazard
2429+
remains the only manual failure mode and continues to span two text locations.
2430+
A parameterized wave-prefix variable in the generator template would eliminate
2431+
both. Continue grepping for stale wave numbers and outer dimensions after each
2432+
copy, keep the `make_grid(32768)` period-identity check, and use `assert_eq` on
2433+
changed elements because `assert_ne` is not emitted by the Icarus simulation path.
2434+
23932435
## Live Wave Loop Tracker
23942436

23952437
This section is updated at the end of every completed Wave Loop. It is the
@@ -2398,13 +2440,13 @@ variants are queued."
23982440

23992441
| Field | Value |
24002442
|-------|-------|
2401-
| **Current wave** | 818 |
2402-
| **Issue** | #1564 (to open) |
2403-
| **Branch** | `wave-loop-818` |
2404-
| **Parent branch** | `wave-loop-817` HEAD because earlier wave PRs remain open |
2405-
| **Recommended variant** | A — module-scope `[455][2]^6 Pt` packed array-of-struct variable from call with indexed signed writes |
2443+
| **Current wave** | 819 |
2444+
| **Issue** | #1565 |
2445+
| **Branch** | `wave-loop-819` |
2446+
| **Parent branch** | `wave-loop-818` HEAD because earlier wave PRs remain open |
2447+
| **Recommended variant** | A — module-scope `[457][2]^6 Pt` packed array-of-struct variable from call with indexed signed writes |
24062448
| **Status** | READY TO START |
2407-
| **Next wave variants queued** | W819 Variant A `[457][2]^6 Pt`; Variant B `[455][3]^6 Pt` stride scaling; Variant C `[455][2]^6 Pt` negative-index wrap-around |
2449+
| **Next wave variants queued** | W820 Variant A `[459][2]^6 Pt`; Variant B `[457][3]^6 Pt` stride scaling; Variant C `[457][2]^6 Pt` negative-index wrap-around |
24082450

24092451
### Open backlog (non-blocking)
24102452

.claude/skills/wave-loop-autopilot.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ criteria, generator copy-hazard checklist, and open backlog.
6262
| 815 | #1559 | wave-loop-815 | 449 | 224 | 28,736 | 919,552 | 0.877 | closed | TBD |
6363
| 816 | #1561 | wave-loop-816 | 451 | 225 | 28,864 | 923,648 | 0.881 | closed | #1560 |
6464
| 817 | #1562 | wave-loop-817 | 453 | 226 | 28,992 | 927,744 | 0.885 | closed | #1563 |
65-
| **818** | **#1564** | **wave-loop-818** | **455** | **227** | **29,120** | **931,840** | **0.889** | **READY** | **TBD** |
66-
| 819 | #1566 | wave-loop-819 | 457 | 228 | 29,248 | 935,936 | 0.893 | planned | TBD |
67-
| 820 | #1568 | wave-loop-820 | 459 | 229 | 29,376 | 940,032 | 0.897 | planned | TBD |
68-
| 821 | #1570 | wave-loop-821 | 461 | 230 | 29,504 | 944,128 | 0.900 | planned | TBD |
65+
| 818 | #1564 | wave-loop-818 | 455 | 227 | 29,120 | 931,840 | 0.889 | closed | #1566 |
66+
| **819** | **#1565** | **wave-loop-819** | **457** | **228** | **29,248** | **935,936** | **0.893** | **READY** | **TBD** |
67+
| 820 | #1567 | wave-loop-820 | 459 | 229 | 29,376 | 940,032 | 0.897 | planned | TBD |
68+
| 821 | #1569 | wave-loop-821 | 461 | 230 | 29,504 | 944,128 | 0.900 | planned | TBD |
6969

7070
### Run-list notes
7171
- Issue numbers follow the observed pattern (issue = previous issue + 2; PR = issue + 1).
@@ -152,10 +152,10 @@ criteria, generator copy-hazard checklist, and open backlog.
152152

153153
## Current status
154154

155-
- **Latest completed wave:** 817
156-
- **Latest issue/PR:** #1562 / #1563
157-
- **Current wave in progress:** 818
158-
- **Next wave queued:** 819
159-
- **Ladder depth:** W774–W817 = 45 waves
155+
- **Latest completed wave:** 818
156+
- **Latest issue/PR:** #1564 / #1566
157+
- **Current wave in progress:** 819
158+
- **Next wave queued:** 820
159+
- **Ladder depth:** W774–W818 = 45 waves
160160

161161
*φ² + φ⁻² = 3 | TRINITY*

.trinity/current-issue.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# Current Issue — Wave Loop 818
1+
# Current Issue — Wave Loop 819
22

33
| Field | Value |
44
|-------|-------|
5-
| Wave | 818 |
6-
| Issue | #1564 |
7-
| Branch | `wave-loop-818` |
8-
| Base | `wave-loop-817` (parent branch because earlier waves' PRs remain open) |
9-
| Variant | `[455][2]^6 Pt` module-scope AoS variable from call with indexed signed writes |
10-
| Target packed vector | 29,120 elements × 32 bits = 931,840 bits (~0.889 MiBit) |
5+
| Wave | 819 |
6+
| Issue | #1565 |
7+
| Branch | `wave-loop-819` |
8+
| Base | `wave-loop-818` (parent branch because earlier waves' PRs remain open) |
9+
| Variant | `[457][2]^6 Pt` module-scope AoS variable from call with indexed signed writes |
10+
| Target packed vector | 29,184 elements × 32 bits = 933,888 bits (~0.891 MiBit) |
1111
| Status | planned |
1212

1313
## Goal
14-
Increment the non-power-of-two outer-dimension ladder by one rung to `[455][2]^6 Pt`, keeping the established inner-dimension (`2^6`) and struct (`Pt { x : i16, y : i16 }`) pattern. Validate that t27c still lowers, simulates, cocotb-matches, and seals the wider packed vector without compiler or FROZEN_HASH changes.
14+
Increment the non-power-of-two outer-dimension ladder by one rung to `[457][2]^6 Pt`, keeping the established inner-dimension (`2^6`) and struct (`Pt { x : i16, y : i16 }`) pattern. Validate that t27c still lowers, simulates, cocotb-matches, and seals the wider packed vector without compiler or FROZEN_HASH changes.
1515

1616
## Acceptance criteria
17-
- [ ] Generator `scripts/gen_w818.py` with `OUTER = 455`, `MID_IDX = 227`; copy hazard fixed before first run.
18-
- [ ] Witness `specs/scratch/w818_bench_module_455x2p6_aos_var_call_write.t27` generated and parsed.
17+
- [ ] Generator `scripts/gen_w819.py` with `OUTER = 457`, `MID_IDX = 228`; copy hazard fixed before first run.
18+
- [ ] Witness `specs/scratch/w819_bench_module_457x2p6_aos_var_call_write.t27` generated and parsed.
1919
- [ ] `t27c icarus-lowerable`, `icarus-simulate`, `icarus-cocotb`, and `seal --save` all PASS.
20-
- [ ] Integration test `accepts_w818_bench_module_455x2p6_aos_var_call_write` added to `bootstrap/tests/icarus_lowerable.rs`.
20+
- [ ] Integration test `accepts_w819_bench_module_457x2p6_aos_var_call_write` added to `bootstrap/tests/icarus_lowerable.rs`.
2121
- [ ] `bootstrap/stage0/FROZEN_HASH` unchanged.
2222
- [ ] Closeout report, next-wave plan, docs, skill tracker, autopilot skill, and persistent memory updated.
23-
- [ ] Commit with `Closes #1564`, push branch, open PR to `master`.
23+
- [ ] Commit with `Closes #1565`, push branch, open PR to `master`.
2424

25-
## Cooperation variants for W819
26-
- **A (recommended):** `[457][2]^6 Pt`, outer += 2, MID_IDX = 228.
27-
- **B:** `[455][3]^6 Pt` — grow the second inner dimension to stress stride scaling.
28-
- **C:** `[455][2]^6 Pt` with negative-index writes to exercise wrap-around addressing.
25+
## Cooperation variants for W820
26+
- **A (recommended):** `[459][2]^6 Pt`, outer += 2, MID_IDX = 229.
27+
- **B:** `[457][3]^6 Pt` — grow the second inner dimension to stress stride scaling.
28+
- **C:** `[457][2]^6 Pt` with negative-index writes to exercise wrap-around addressing.

.trinity/current_task/activity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,3 +3956,7 @@
39563956
- **Commit:** feat(igla): Wave Loop 817 — module-scope [453][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
39573957
- **Files:** .claude/skills/wave-loop-autopilot.md,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W817_2026-07-29.md
39583958

3959+
## 2026-07-30T04:45:45Z — wave-loop-818
3960+
- **Commit:** docs: record W817 PR #1563 in NOW.md, autopilot skill, and closeout report
3961+
- **Files:** .claude/plans/wave-loop-819.md,.claude/skills/t27-wave-loop.md,.claude/skills/wave-loop-autopilot.md,.trinity/current-issue.md,.trinity/experience.md,.trinity/seals/scratch_w818_bench_module_455x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W818_2026-07-29.md,scripts/gen_w818.py,specs/scratch/w818_bench_module_455x2p6_aos_var_call_write.t27
3962+

.trinity/experience.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
1+
## 2026-07-29 — Wave Loop 818 (module-scope `[455][2]^6 Pt` non-power-of-two outer-dimension AoS variable, issue #1564)
2+
3+
### What worked
4+
- Variant A extended the module-scope packed AoS odd outer-dimension ladder to 455.
5+
The `[455][2]^6 Pt` witness is 931,840 bits (~0.889 MiBit), still well under the 4-MiBit
6+
cliff, and required no compiler changes.
7+
- A module-level `pub var dst : [455][2]^6 Pt` can be initialized from a function
8+
call and exercised with indexed signed field writes, with zero compiler changes.
9+
- The cocotb/Python reference model correctly mirrored the row-major flattening
10+
with outer stride 455, confirming the layout is preserved end-to-end.
11+
- Reused the corrected W632 element-index formula for mid-row expected values:
12+
`[r][a5][a4][a3][a2][a1][a0]` is element `r*64 + a5*32 + a4*16 + a3*8 + a2*4 + a1*2 + a0`.
13+
- For `OUTER = 455`, `MID_IDX = 227`; the frame-condition element is
14+
`[227][1][0][0][0][0][0]`, element number `227*64 + 32 = 14,560`.
15+
- The generator copy hazard struck again after copying `scripts/gen_w817.py` →
16+
`scripts/gen_w818.py`. Both the destination path and the module header f-string
17+
carried stale `w817` / `453` references. Fixing both before regenerating resolved it.
18+
The stale `MID_IDX` comment was also corrected to `227`.
19+
This is the same hazard documented in W782–W817 learnings and remains the only
20+
manual step in the otherwise mechanical flow.
21+
- Fresh weak-point audit (2026-07-29) found no new actionable items. The W783 fix
22+
for `bootstrap/tests/verilog_const_array.rs:166` remains green; the pre-existing
23+
`verilog_array_literal_expr` regression is still out of scope for the witness ladder.
24+
- 30-day subject-line traceability remained low; the closeout commit carries
25+
`Closes #1564` in the subject, but the overall rate needs improvement.
26+
Continue putting issue references in commit subjects.
27+
- Updated the live Wave Loop Tracker in `.claude/skills/t27-wave-loop.md` to wave 819.
28+
- Updated `.claude/skills/wave-loop-autopilot.md` to mark W818 READY, W819 planned,
29+
and refreshed the master run-list.
30+
31+
### What changed behavior
32+
- No changes to `bootstrap/src/compiler.rs`.
33+
- No changes to `bootstrap/stage0/FROZEN_HASH` (`68a0b933c00ba5efd7facb5997f00880c3eecae55e6ac5e8cea2aee399b92adc`).
34+
- No changes to `scripts/cocotb_ref_model.py`.
35+
- Added `specs/scratch/w818_bench_module_455x2p6_aos_var_call_write.t27` (~1,998 KB /
36+
~86,511 lines) with seal and Icarus baseline.
37+
- Added integration test `accepts_w818_bench_module_455x2p6_aos_var_call_write`
38+
in `bootstrap/tests/icarus_lowerable.rs`.
39+
- Added generator script `scripts/gen_w818.py`.
40+
- Wrote `docs/reports/FPGA_LOOP_CLOSEOUT_W818_2026-07-29.md` and
41+
`.claude/plans/wave-loop-819.md` with three cooperation variants.
42+
- Updated `.claude/skills/t27-wave-loop.md` live tracker to wave 819.
43+
44+
### Validation
45+
- `cargo build --release -p t27c`: OK.
46+
- `cargo clippy -p t27c`: OK (626 warnings, 0 errors).
47+
- `cargo test -p t27c --bin t27c`: 1494 passed; 0 failed; 2 ignored.
48+
- `cargo test -p tri`: 78 passed; 0 failed.
49+
- `cargo test -p flash-spi`: 2 passed; 0 failed.
50+
- `cargo test -p t27c --test bitnet_pipeline`: 20 passed; 0 failed.
51+
- `cargo test -p t27c --test bitnet_top`: 17 passed; 0 failed.
52+
- `cargo test -p t27c --test icarus_lowerable`: 278 passed; 0 failed.
53+
- `cargo test -p t27c --test verilog_const_array`: 2 passed; 0 failed.
54+
- Direct `t27c parse` W818: PASS.
55+
- Direct `t27c icarus-lowerable` W818: PASS (`lowerable`).
56+
- Direct `t27c icarus-simulate` W818: PASS (17 cycles, PASSED).
57+
- Direct `t27c icarus-cocotb` W818: PASS (`reference-model OK`).
58+
- Direct `t27c seal --save` W818: PASS.
59+
60+
### Scientific / engineering background
61+
- IEEE 1800-2017 §7.4.1/7.4.3 define packed-array width as the product of packed
62+
dimensions, with no power-of-two restriction. Variant A emits a single
63+
931,840-bit packed vector, which is legal SystemVerilog.
64+
165
## 2026-07-29 — Wave Loop 817 (module-scope `[453][2]^6 Pt` non-power-of-two outer-dimension AoS variable, issue #1562)
266

367
### What worked
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"gen_hash_c": "sha256:b54f4e4545743b5731fb2f72e310536cc8154fed82769a52ce06524275df5908",
3+
"gen_hash_rust": "sha256:8a53e15a700cd6df46cfbe48101011b6e1a842d71309b6ba75a1fd7a684990c3",
4+
"gen_hash_verilog": "sha256:0b56e889386a13aee4aced999ecbb676a94b7cfee4acf4eae95117d0c8478848",
5+
"gen_hash_zig": "sha256:8461dff93d83f405a8041ac49faadf0b76428c32f58625e74dbbd6712adce676",
6+
"module": "w818_bench_module_455x2p6_aos_var_call_write",
7+
"ring": 12,
8+
"sealed_at": "2026-07-30T03:08:11Z",
9+
"spec_hash": "sha256:a907723555069e7a3b3260b73842f3f8f72d52ea19d71d0ac6f7833bd434a149",
10+
"spec_path": "/Users/playra/t27/specs/scratch/w818_bench_module_455x2p6_aos_var_call_write.t27"
11+
}

bootstrap/tests/icarus_lowerable.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5017,6 +5017,24 @@ fn accepts_w817_bench_module_453x2p6_aos_var_call_write() {
50175017
}
50185018
}
50195019

5020+
#[test]
5021+
fn accepts_w818_bench_module_455x2p6_aos_var_call_write() {
5022+
let dir = scratch_dir();
5023+
for name in &[
5024+
"w818_bench_module_455x2p6_aos_var_call_write.t27",
5025+
] {
5026+
let p = dir.join(name);
5027+
assert!(p.exists(), "missing W818 witness {}", p.display());
5028+
let (lowerable, json) = run_icarus_lowerable(&p);
5029+
assert!(
5030+
lowerable,
5031+
"expected {} to be lowerable, got: {}",
5032+
p.display(),
5033+
json
5034+
);
5035+
}
5036+
}
5037+
50205038
#[test]
50215039
fn accepts_known_lowerable_witnesses() {
50225040
let dir = scratch_dir();

0 commit comments

Comments
 (0)