Skip to content

Commit fc0819d

Browse files
authored
Wave Loop 768 — [355][2]^6 Pt AoS var from call with indexed signed writes
Closes #1739
1 parent 3f72b15 commit fc0819d

10 files changed

Lines changed: 68017 additions & 33 deletions

File tree

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Wave Loop 769 Plan — Issue #1740
2+
3+
## Phase 1: Issue
4+
- Confirm W769 issue #1740 and branch `wave-loop-769`.
5+
6+
## Phase 2: Spec
7+
- Generate `specs/scratch/w769_bench_module_357x2p6_aos_var_call_write.t27` using
8+
`scripts/gen_w769.py` derived from `scripts/gen_w768.py`.
9+
- Constants: `OUTER = 357`, `TOTAL = 22848`, `LAST_IDX = 356`, `MID_IDX = 178`.
10+
11+
## Phase 3: TDD
12+
- Inspect generated assertions: `make_grid(32768)`, `make_grid(1)`,
13+
`call_write_grid`, field writes, `assert_eq` read-backs, mid and last checks.
14+
15+
## Phase 4: Impl
16+
- Add integration test `accepts_w769_bench_module_357x2p6_aos_var_call_write` to
17+
`bootstrap/tests/icarus_lowerable.rs`.
18+
19+
## Phase 5: Gen
20+
- Run `cd bootstrap && cargo build --release -p t27c`.
21+
22+
## Phase 6: Seal
23+
- Run `./bootstrap/target/release/t27c seal --save specs/scratch/w769_bench_module_357x2p6_aos_var_call_write.t27`.
24+
- Confirm FROZEN_HASH unchanged.
25+
26+
## Phase 7: Verify
27+
- `./bootstrap/target/release/t27c parse ...`
28+
- `./bootstrap/target/release/t27c icarus-lowerable ...`
29+
- `./bootstrap/target/release/t27c icarus-simulate ...` (17 cycles)
30+
- `./bootstrap/target/release/t27c icarus-cocotb ...`
31+
- `cargo test -p t27c --bin t27c`
32+
- `cargo test -p tri`
33+
- `cargo test -p t27c --test icarus_lowerable`
34+
35+
## Phase 8: Land
36+
- Commit with `feat(igla): Wave Loop 769 — module-scope [357][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1740)`.
37+
- Push `wave-loop-769`, open PR, merge to `master`, create `wave-loop-770`.
38+
39+
## Phase 9: Learn
40+
- Write `docs/reports/FPGA_LOOP_CLOSEOUT_W769_2026-07-23.md`.
41+
- Save `.trinity/experience.md`, memory file, `MEMORY.md` pointer, and update
42+
`skills-wave-loop-recipe.md`.
43+
44+
## Cooperation variants for next Wave Loop
45+
46+
- **A (recommended):** `[359][2]^6 Pt` (~0.702 MiBit), continuing the odd ladder.
47+
- **B:** move the packed variable to bench/function scope at the same width.
48+
- **C:** add conditional (`if`) indexed writes at the current width.

.trinity/current-issue.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# Wave Loop 767 — Issue #1738
1+
# Wave Loop 768 — Issue #1739
22

3-
**Branch:** `wave-loop-767`
3+
**Branch:** `wave-loop-768`
44
**Date:** 2026-07-23
55
**Cooperation variant:** A (recommended)
66

77
## Goal
88

9-
Close Wave Loop 767 by validating a module-scope `[353][2]^6 Pt` packed
9+
Close Wave Loop 768 by validating a module-scope `[355][2]^6 Pt` packed
1010
array-of-struct variable initialized from a function call, with indexed signed
1111
field writes and `assert_eq` read-back in a `bench` block.
1212

1313
## Acceptance criteria
1414

15-
1. `specs/scratch/w767_bench_module_353x2p6_aos_var_call_write.t27` is generated and parses.
15+
1. `specs/scratch/w768_bench_module_355x2p6_aos_var_call_write.t27` is generated and parses.
1616
2. The witness is Icarus-lowerable and simulates correctly (17 cycles, PASSED).
1717
3. The cocotb reference model matches the t27 semantics.
1818
4. `t27c seal --save` succeeds and FROZEN_HASH remains unchanged.
1919
5. All cargo suites remain green.
20-
6. Integration test `accepts_w767_bench_module_353x2p6_aos_var_call_write` is added.
21-
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W767_2026-07-23.md` is written.
20+
6. Integration test `accepts_w768_bench_module_355x2p6_aos_var_call_write` is added.
21+
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W768_2026-07-23.md` is written.
2222
8. Learning is saved to `.trinity/experience.md`, memory, and `skills-wave-loop-recipe.md`.
23-
9. Branch merges to `master` with `Closes #1738`.
23+
9. Branch merges to `master` with `Closes #1739`.
2424

2525
## Technical notes
2626

27-
- Shape: `[353][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
28-
- Total elements: `353 x 64 = 22,592`.
29-
- Packed vector width: `22,592 x 32 = 722,944` bits (~0.690 MiBit).
30-
- `MID_IDX = 176`; frame-condition element `[176][1][0][0][0][0][0]` is element
31-
`176*64 + 32 = 11,296`.
32-
- Generator script: `scripts/gen_w767.py` (copy from `scripts/gen_w766.py`, set
33-
`OUTER = 353` and `MID_IDX = 176`, manually fix the f-string header).
27+
- Shape: `[355][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
28+
- Total elements: `355 x 64 = 22,720`.
29+
- Packed vector width: `22,720 x 32 = 727,040` bits (~0.694 MiBit).
30+
- `MID_IDX = 177`; frame-condition element `[177][1][0][0][0][0][0]` is element
31+
`177*64 + 32 = 11,360`.
32+
- Generator script: `scripts/gen_w768.py` (copy from `scripts/gen_w767.py`, set
33+
`OUTER = 355` and `MID_IDX = 177`, manually fix the f-string header).
3434
- Use `assert_eq` checks on changed elements (Icarus simulation path does not
3535
emit `assert_ne`).
3636
- Include `make_grid(32768)` period-identity check because `32768 == 0 (mod 32768)`.
3737
- Zero compiler / reference-model / FROZEN_HASH changes expected.
3838

3939
## Cooperation variants for next Wave Loop
4040

41-
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[355][2]^6 Pt`.
42-
- **Variant B:** keep width at ~0.690 MiBit but move the packed var to bench/function scope.
41+
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[357][2]^6 Pt`.
42+
- **Variant B:** keep width at ~0.694 MiBit but move the packed var to bench/function scope.
4343
- **Variant C:** add `if`-guarded indexed signed field writes at the current width.
4444

4545
---

.trinity/current_task/activity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,3 +3680,7 @@
36803680
- **Commit:** feat(igla): Wave Loop 766 — module-scope [351][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1737)
36813681
- **Files:** .claude/plans/wave-loop-768.md,.trinity/current-issue.md,.trinity/experience.md,.trinity/seals/scratch_w767_bench_module_353x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W767_2026-07-23.md,scripts/gen_w767.py,specs/scratch/w767_bench_module_353x2p6_aos_var_call_write.t27
36823682

3683+
## 2026-07-23T18:05:01Z — wave-loop-768
3684+
- **Commit:** feat(igla): Wave Loop 767 — module-scope [353][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1738)
3685+
- **Files:** .claude/plans/wave-loop-769.md,.trinity/current-issue.md,.trinity/experience.md,.trinity/seals/scratch_w768_bench_module_355x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W768_2026-07-23.md,scripts/gen_w768.py,specs/scratch/w768_bench_module_355x2p6_aos_var_call_write.t27
3686+

.trinity/experience.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,79 @@
7777

7878
---
7979

80+
## 2026-07-23 — Wave Loop 768 (module-scope `[355][2]^6 Pt` non-power-of-two outer-dimension AoS variable)
81+
82+
### What worked
83+
- Variant A extended the module-scope packed AoS odd outer-dimension ladder to 355.
84+
The `[355][2]^6 Pt` witness is 727,040 bits (~0.694 MiBit), still well under the 4-MiBit
85+
cliff, and required no compiler changes.
86+
- A module-level `pub var dst : [355][2]^6 Pt` can be initialized from a function
87+
call and exercised with indexed signed field writes, with zero compiler changes.
88+
- The cocotb/Python reference model correctly mirrored the row-major flattening
89+
with outer stride 355, confirming the layout is preserved end-to-end.
90+
- Reused the corrected W632 element-index formula for mid-row expected values:
91+
`[r][a5][a4][a3][a2][a1][a0]` is element `r*64 + a5*32 + a4*16 + a3*8 + a2*4 + a1*2 + a0`.
92+
- For `OUTER = 355`, `MID_IDX = 177`; the frame-condition element is
93+
`[177][1][0][0][0][0][0]`, element number `177*64 + 32 = 11,360`.
94+
- Updated weak-point audit: 42 of 51 30-day commits include `Closes #N` (≈82%).
95+
Clean non-worktree scan: 53 of 895 `.t27` specs lack `test`/`invariant`/`bench`
96+
(≈5.9%). 19 `scripts/*.sh` remain under `scripts/`.
97+
- Fresh 2025-2026 literature scan surfaced BitNet training/inference extensions,
98+
spintronic/MTJ ternary logic-in-memory, skyrmion multi-value probabilistic
99+
computing, and superconducting ternary output data links.
100+
101+
### What changed behavior
102+
- No changes to `bootstrap/src/compiler.rs`.
103+
- No changes to `bootstrap/stage0/FROZEN_HASH`.
104+
- No changes to `scripts/cocotb_ref_model.py`.
105+
- Added `specs/scratch/w768_bench_module_355x2p6_aos_var_call_write.t27` (~1,554 KB /
106+
~67,511 lines) with seal and Icarus baseline.
107+
- Added integration test `accepts_w768_bench_module_355x2p6_aos_var_call_write`.
108+
- Added generator script `scripts/gen_w768.py`.
109+
110+
### Validation
111+
- `cargo build --release -p t27c`: OK.
112+
- `cargo test -p t27c --bin t27c`: 1494 passed; 0 failed; 2 ignored.
113+
- `cargo test -p tri`: 78 passed; 0 failed.
114+
- `cargo test -p t27c --test icarus_lowerable`: 228 passed; 0 failed.
115+
- Direct `t27c parse` W768: PASS.
116+
- Direct `t27c icarus-lowerable` W768: PASS (`lowerable`).
117+
- Direct `t27c icarus-simulate` W768: PASS (17 cycles, PASSED).
118+
- Direct `t27c icarus-cocotb` W768: PASS (`reference-model OK`).
119+
120+
### Scientific / engineering background
121+
- IEEE 1800-2017 7.4.1/7.4.3 define packed-array total width as the product of
122+
packed dimensions, with no power-of-two restriction. Variant A emits a single
123+
727,040-bit packed vector, which is legal SystemVerilog.
124+
- Lutsig verified array lowering and CIRCT `HWLegalizeModules` show that
125+
flattening nested arrays to wide packed vectors is a well-founded compiler
126+
discipline, even when outer dimensions are non-power-of-two.
127+
- Icarus issue #1134 documents assertion failures for unpacked arrays of packed
128+
structs; t27 scalar flattening avoids that construct entirely.
129+
- Yosys issue #2677 / #4653 confirm that arrays of packed structs remain
130+
unsupported in the native frontend; t27 packed-vector lowering avoids the
131+
gap.
132+
- 2025-2026 ternary/MVL literature scan found:
133+
- BitNet b1.58 foundational ternary LLM and JMLR 2025 training recipe.
134+
- BitNet b1.58 2B4T — first open-source native 1-bit 2B LLM (4T tokens).
135+
- Bitnet.cpp — edge CPU inference with TL/I2_S kernels up to 6.25× vs FP16.
136+
- Sparse-BitNet — natural compatibility with N:M semi-structured sparsity.
137+
- Skyrmion multi-value probabilistic computing with current-controlled
138+
diffusion and MTJ-compatible readout (arXiv 2025).
139+
- MTJ+FinFET ternary logic-in-memory array with full ternary operator set
140+
(Results in Engineering 2025).
141+
- Reconfigurable skyrmion multi-port logic device with VCMA gating
142+
(Chinese Phys. Lett. 2026).
143+
- Cascading VCMA skyrmion AND/OR/NAND/NOR gates (Nanotechnology 2026).
144+
- Ternary RSFQ output data link, 3-bit→2-trit encoder, MIT Lincoln Lab
145+
SFQ5ee process (IEEE Trans. Appl. Supercond. 2025).
146+
- Verilog/SDF modeling framework for synchronous/asynchronous SFQ/RSFQ/ASFQ
147+
pulse-based logic (arXiv 2026).
148+
- OpenXC7 / nextpnr-xilinx / Project X-Ray — fully open-source Xilinx
149+
7-series toolchain, used for QMTech XC7A100T ternary projects without Vivado.
150+
151+
---
152+
80153
## 2026-07-23 — Wave Loop 767 (module-scope `[353][2]^6 Pt` non-power-of-two outer-dimension AoS variable)
81154

82155
### 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:0a7d6ea763e3f6e1e4912a03bf3882bbe4d31a803d6593629fb83ecac4c921ec",
3+
"gen_hash_rust": "sha256:501ff5b5839e249cdc06c66406f59362ef58e54f808aab05adab44a3a48cf01b",
4+
"gen_hash_verilog": "sha256:07b175d07eca5b9d035f4a8e1180eafac3d9bd230ede97b24fac8faf4cf3207e",
5+
"gen_hash_zig": "sha256:ef8314dceaa4a287c4d1617ec91133f6e972a05e723c2407ad743196852dcca9",
6+
"module": "w768_bench_module_355x2p6_aos_var_call_write",
7+
"ring": 12,
8+
"sealed_at": "2026-07-23T18:00:13Z",
9+
"spec_hash": "sha256:0be372286e5ad05f7330efd1e2104b4cc4f2148e18125905656715844e0f3ef5",
10+
"spec_path": "specs/scratch/w768_bench_module_355x2p6_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
@@ -4117,6 +4117,24 @@ fn accepts_w767_bench_module_353x2p6_aos_var_call_write() {
41174117
}
41184118
}
41194119

4120+
#[test]
4121+
fn accepts_w768_bench_module_355x2p6_aos_var_call_write() {
4122+
let dir = scratch_dir();
4123+
for name in &[
4124+
"w768_bench_module_355x2p6_aos_var_call_write.t27",
4125+
] {
4126+
let p = dir.join(name);
4127+
assert!(p.exists(), "missing W768 witness {}", p.display());
4128+
let (lowerable, json) = run_icarus_lowerable(&p);
4129+
assert!(
4130+
lowerable,
4131+
"expected {} to be lowerable, got: {}",
4132+
p.display(),
4133+
json
4134+
);
4135+
}
4136+
}
4137+
41204138
#[test]
41214139
fn accepts_known_lowerable_witnesses() {
41224140
let dir = scratch_dir();

docs/NOW.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# NOW — Wave Loop 767 close-out / Wave Loop 768 setup (2026-07-23)
1+
# NOW — Wave Loop 768 close-out / Wave Loop 769 setup (2026-07-23)
22

33
Last updated: 2026-07-23
44

5-
## Wave Loop 767 — module-scope `[353][2]^6 Pt` packed array-of-struct from call with indexed signed writes (Closes #1738)
5+
## Wave Loop 768 — module-scope `[355][2]^6 Pt` packed array-of-struct from call with indexed signed writes (Closes #1739)
66

7-
- Branch: `wave-loop-767`
8-
- Issue: #1738
7+
- Branch: `wave-loop-768`
8+
- Issue: #1739
99
- PR: to open
10-
- Report: `docs/reports/FPGA_LOOP_CLOSEOUT_W767_2026-07-23.md`
11-
- Plan: `.claude/plans/wave-loop-767.md`
12-
- Cooperation W768: `.claude/plans/wave-loop-768.md`
10+
- Report: `docs/reports/FPGA_LOOP_CLOSEOUT_W768_2026-07-23.md`
11+
- Plan: `.claude/plans/wave-loop-768.md`
12+
- Cooperation W769: `.claude/plans/wave-loop-769.md`
1313

1414
### What landed
15-
- `specs/scratch/w767_bench_module_353x2p6_aos_var_call_write.t27`
16-
- 22,592 elements, 722,944-bit packed vector (~0.690 MiBit).
17-
- Module-scope `pub var dst : [353][2]^6 Pt` initialized from a function call and
15+
- `specs/scratch/w768_bench_module_355x2p6_aos_var_call_write.t27`
16+
- 22,720 elements, 727,040-bit packed vector (~0.694 MiBit).
17+
- Module-scope `pub var dst : [355][2]^6 Pt` initialized from a function call and
1818
exercised with indexed signed field writes.
1919
- `assert_eq` read-back in a `bench` block (Icarus path does not emit `assert_ne`).
20-
- `scripts/gen_w767.py`
21-
- Generator for the W767 witness; `OUTER = 353`, `MID_IDX = 176`.
20+
- `scripts/gen_w768.py`
21+
- Generator for the W768 witness; `OUTER = 355`, `MID_IDX = 177`.
2222
- `bootstrap/tests/icarus_lowerable.rs`
23-
- Added `accepts_w767_bench_module_353x2p6_aos_var_call_write`.
24-
- `.trinity/experience.md`, `.trinity/current-issue.md`, `.claude/plans/wave-loop-768.md`
25-
- W767 learnings saved and W768 issue/plan created.
23+
- Added `accepts_w768_bench_module_355x2p6_aos_var_call_write`.
24+
- `.trinity/experience.md`, `.trinity/current-issue.md`, `.claude/plans/wave-loop-769.md`
25+
- W768 learnings saved and W769 issue/plan created.
2626

2727
### Not changed
2828
- `bootstrap/src/compiler.rs` — zero compiler changes.
@@ -33,8 +33,21 @@ Last updated: 2026-07-23
3333
- `cargo build --release -p t27c`: OK.
3434
- `cargo test -p t27c --bin t27c`: 1494/0/2.
3535
- `cargo test -p tri`: 78/0.
36-
- `cargo test -p t27c --test icarus_lowerable`: 227/0.
37-
- `t27c parse|icarus-lowerable|icarus-simulate|icarus-cocotb|seal --save` W767: PASS.
36+
- `cargo test -p t27c --test icarus_lowerable`: 228/0.
37+
- `t27c parse|icarus-lowerable|icarus-simulate|icarus-cocotb|seal --save` W768: PASS.
38+
39+
---
40+
41+
## Wave Loop 769 — next odd outer-dimension `[357][2]^6 Pt` (Issue #1740)
42+
43+
- Branch: `wave-loop-769` (to create after W768 merge)
44+
- Issue: #1740
45+
- Plan: `.claude/plans/wave-loop-769.md`
46+
47+
### Candidate variants
48+
- Variant A (recommended): continue the odd outer-dimension ladder with `[357][2]^6 Pt`.
49+
- Variant B: keep width at ~0.694 MiBit but move the packed var to bench/function scope.
50+
- Variant C: add `if`-guarded indexed signed field writes at the current width.
3851

3952
---
4053

0 commit comments

Comments
 (0)