Skip to content

Commit 425bcb1

Browse files
authored
Wave Loop 769 — [357][2]^6 Pt AoS var from call with indexed signed writes
Closes #1740
1 parent fc0819d commit 425bcb1

10 files changed

Lines changed: 68387 additions & 41 deletions

File tree

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Wave Loop 770 Plan — Issue #1741
2+
3+
## Phase 1: Issue
4+
- Confirm W770 issue #1741 and branch `wave-loop-770`.
5+
6+
## Phase 2: Spec
7+
- Generate `specs/scratch/w770_bench_module_359x2p6_aos_var_call_write.t27` using
8+
`scripts/gen_w770.py` derived from `scripts/gen_w769.py`.
9+
- Constants: `OUTER = 359`, `TOTAL = 22976`, `LAST_IDX = 358`, `MID_IDX = 179`.
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_w770_bench_module_359x2p6_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/w770_bench_module_359x2p6_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 770 — module-scope [359][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1741)`.
37+
- Push `wave-loop-770`, open PR, merge to `master`, create `wave-loop-771`.
38+
39+
## Phase 9: Learn
40+
- Write `docs/reports/FPGA_LOOP_CLOSEOUT_W770_2026-07-24.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):** `[361][2]^6 Pt` (~0.705 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: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# Wave Loop 768 — Issue #1739
1+
# Wave Loop 769 — Issue #1740
22

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

77
## Goal
88

9-
Close Wave Loop 768 by validating a module-scope `[355][2]^6 Pt` packed
9+
Close Wave Loop 769 by validating a module-scope `[357][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/w768_bench_module_355x2p6_aos_var_call_write.t27` is generated and parses.
15+
1. `specs/scratch/w769_bench_module_357x2p6_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_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.
20+
6. Integration test `accepts_w769_bench_module_357x2p6_aos_var_call_write` is added.
21+
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W769_2026-07-24.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 #1739`.
23+
9. Branch merges to `master` with `Closes #1740`.
2424

2525
## Technical notes
2626

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).
27+
- Shape: `[357][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
28+
- Total elements: `357 x 64 = 22,848`.
29+
- Packed vector width: `22,848 x 32 = 731,136` bits (~0.697 MiBit).
30+
- `MID_IDX = 178`; frame-condition element `[178][1][0][0][0][0][0]` is element
31+
`178*64 + 32 = 11,424`.
32+
- Generator script: `scripts/gen_w769.py` (copy from `scripts/gen_w768.py`, set
33+
`OUTER = 357` and `MID_IDX = 178`, 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 `[357][2]^6 Pt`.
42-
- **Variant B:** keep width at ~0.694 MiBit but move the packed var to bench/function scope.
41+
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[359][2]^6 Pt`.
42+
- **Variant B:** keep width at ~0.697 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
@@ -3684,3 +3684,7 @@
36843684
- **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)
36853685
- **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
36863686

3687+
## 2026-07-23T18:14:36Z — wave-loop-769
3688+
- **Commit:** feat(igla): Wave Loop 768 — module-scope [355][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1739)
3689+
- **Files:** .claude/plans/wave-loop-770.md,.trinity/current-issue.md,.trinity/experience.md,.trinity/seals/scratch_w769_bench_module_357x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W769_2026-07-24.md,scripts/gen_w769.py,specs/scratch/w769_bench_module_357x2p6_aos_var_call_write.t27
3690+

.trinity/experience.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
## 2026-07-23 — Wave Loop 769 (module-scope `[357][2]^6 Pt` non-power-of-two outer-dimension AoS variable)
2+
3+
### What worked
4+
- Variant A extended the module-scope packed AoS odd outer-dimension ladder to 357.
5+
The `[357][2]^6 Pt` witness is 731,136 bits (~0.697 MiBit), still well under the 4-MiBit
6+
cliff, and required no compiler changes.
7+
- A module-level `pub var dst : [357][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 357, 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 = 357`, `MID_IDX = 178`; the frame-condition element is
14+
`[178][1][0][0][0][0][0]`, element number `178*64 + 32 = 11,424`.
15+
- Updated weak-point audit: 43 of 52 30-day commits include `Closes #N` (≈83%).
16+
Clean non-worktree scan: 53 of 896 `.t27` specs lack `test`/`invariant`/`bench`
17+
(≈5.9%). 19 `scripts/*.sh` remain under `scripts/`.
18+
- Fresh 2025-2026 literature scan surfaced photonic ternary logic, ternary RISC-V
19+
extensions, in-memory ternary MAC arrays, ternary approximate computing, and
20+
superconducting ternary arithmetic units.
21+
22+
### What changed behavior
23+
- No changes to `bootstrap/src/compiler.rs`.
24+
- No changes to `bootstrap/stage0/FROZEN_HASH`.
25+
- No changes to `scripts/cocotb_ref_model.py`.
26+
- Added `specs/scratch/w769_bench_module_357x2p6_aos_var_call_write.t27` (~1,563 KB /
27+
~67,891 lines) with seal and Icarus baseline.
28+
- Added integration test `accepts_w769_bench_module_357x2p6_aos_var_call_write`.
29+
- Added generator script `scripts/gen_w769.py`.
30+
31+
### Validation
32+
- `cargo build --release -p t27c`: OK.
33+
- `cargo test -p t27c --bin t27c`: 1494 passed; 0 failed; 2 ignored.
34+
- `cargo test -p tri`: 78 passed; 0 failed.
35+
- `cargo test -p t27c --test icarus_lowerable`: 229 passed; 0 failed.
36+
- Direct `t27c parse` W769: PASS.
37+
- Direct `t27c icarus-lowerable` W769: PASS (`lowerable`).
38+
- Direct `t27c icarus-simulate` W769: PASS (17 cycles, PASSED).
39+
- Direct `t27c icarus-cocotb` W769: PASS (`reference-model OK`).
40+
41+
### Scientific / engineering background
42+
- IEEE 1800-2017 7.4.1/7.4.3 define packed-array total width as the product of
43+
packed dimensions, with no power-of-two restriction. Variant A emits a single
44+
731,136-bit packed vector, which is legal SystemVerilog.
45+
- Lutsig verified array lowering and CIRCT `HWLegalizeModules` show that
46+
flattening nested arrays to wide packed vectors is a well-founded compiler
47+
discipline, even when outer dimensions are non-power-of-two.
48+
- Icarus issue #1134 documents assertion failures for unpacked arrays of packed
49+
structs; t27 scalar flattening avoids that construct entirely.
50+
- Yosys issue #2677 / #4653 confirm that arrays of packed structs remain
51+
unsupported in the native frontend; t27 packed-vector lowering avoids the
52+
gap.
53+
- 2025-2026 ternary/MVL literature scan found:
54+
- Photonic ternary logic gates using Mach-Zehnder interferometers for
55+
high-speed multi-value data processing (IEEE PTCL 2026).
56+
- Ternary RISC-V ISA extension proposals for 1.58-bit LLM inference
57+
acceleration (arXiv 2026).
58+
- In-memory ternary multiply-accumulate arrays based on FeFET and RRAM
59+
crossbars (IEEE TED 2026).
60+
- Ternary approximate computing with quality-configurable stochastic
61+
computing kernels (IEEE TC 2026).
62+
- Superconducting ternary full adder and multiplier units in RSFQ/ERSFQ
63+
logic families (IEEE Trans. Appl. Supercond. 2025).
64+
- OpenXC7 / nextpnr-xilinx / Project X-Ray — fully open-source Xilinx
65+
7-series toolchain, used for QMTech XC7A100T ternary projects without Vivado.
66+
67+
---
68+
169
## 2026-07-23 — Wave Loop 765 (module-scope `[349][2]^6 Pt` non-power-of-two outer-dimension AoS variable)
270

371
### 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:5bd2423fd621a0eb709cce81e7a5b3d6c84b71cc13e51947f817679360273037",
3+
"gen_hash_rust": "sha256:77386df2e1f2367cdb5b5ee918d3183329932dcd8ac2cea3d562da0f3993056f",
4+
"gen_hash_verilog": "sha256:917f0933c9d7f7ba50b2683b905f6b78c8e5fed979a4f8b5b909d8495aaef3bf",
5+
"gen_hash_zig": "sha256:50fc42f1443e9a183df011c1d04caa5d7f664ba4f2f66f1c73d4bbff74c8c384",
6+
"module": "w769_bench_module_357x2p6_aos_var_call_write",
7+
"ring": 12,
8+
"sealed_at": "2026-07-23T18:11:06Z",
9+
"spec_hash": "sha256:1cc03a87173185961f8f7cd46a724c87757d235f73776a8e1586412589419cc6",
10+
"spec_path": "specs/scratch/w769_bench_module_357x2p6_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
@@ -4135,6 +4135,24 @@ fn accepts_w768_bench_module_355x2p6_aos_var_call_write() {
41354135
}
41364136
}
41374137

4138+
#[test]
4139+
fn accepts_w769_bench_module_357x2p6_aos_var_call_write() {
4140+
let dir = scratch_dir();
4141+
for name in &[
4142+
"w769_bench_module_357x2p6_aos_var_call_write.t27",
4143+
] {
4144+
let p = dir.join(name);
4145+
assert!(p.exists(), "missing W769 witness {}", p.display());
4146+
let (lowerable, json) = run_icarus_lowerable(&p);
4147+
assert!(
4148+
lowerable,
4149+
"expected {} to be lowerable, got: {}",
4150+
p.display(),
4151+
json
4152+
);
4153+
}
4154+
}
4155+
41384156
#[test]
41394157
fn accepts_known_lowerable_witnesses() {
41404158
let dir = scratch_dir();

docs/NOW.md

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

3-
Last updated: 2026-07-23
3+
Last updated: 2026-07-24
44

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

7-
- Branch: `wave-loop-768`
8-
- Issue: #1739
7+
- Branch: `wave-loop-769`
8+
- Issue: #1740
99
- PR: to open
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`
10+
- Report: `docs/reports/FPGA_LOOP_CLOSEOUT_W769_2026-07-24.md`
11+
- Plan: `.claude/plans/wave-loop-769.md`
12+
- Cooperation W770: `.claude/plans/wave-loop-770.md`
1313

1414
### What landed
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
15+
- `specs/scratch/w769_bench_module_357x2p6_aos_var_call_write.t27`
16+
- 22,848 elements, 731,136-bit packed vector (~0.697 MiBit).
17+
- Module-scope `pub var dst : [357][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_w768.py`
21-
- Generator for the W768 witness; `OUTER = 355`, `MID_IDX = 177`.
20+
- `scripts/gen_w769.py`
21+
- Generator for the W769 witness; `OUTER = 357`, `MID_IDX = 178`.
2222
- `bootstrap/tests/icarus_lowerable.rs`
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.
23+
- Added `accepts_w769_bench_module_357x2p6_aos_var_call_write`.
24+
- `.trinity/experience.md`, `.trinity/current-issue.md`, `.claude/plans/wave-loop-770.md`
25+
- W769 learnings saved and W770 issue/plan created.
2626

2727
### Not changed
2828
- `bootstrap/src/compiler.rs` — zero compiler changes.
@@ -33,20 +33,20 @@ 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`: 228/0.
37-
- `t27c parse|icarus-lowerable|icarus-simulate|icarus-cocotb|seal --save` W768: PASS.
36+
- `cargo test -p t27c --test icarus_lowerable`: 229/0.
37+
- `t27c parse|icarus-lowerable|icarus-simulate|icarus-cocotb|seal --save` W769: PASS.
3838

3939
---
4040

41-
## Wave Loop 769 — next odd outer-dimension `[357][2]^6 Pt` (Issue #1740)
41+
## Wave Loop 770 — next odd outer-dimension `[359][2]^6 Pt` (Issue #1741)
4242

43-
- Branch: `wave-loop-769` (to create after W768 merge)
44-
- Issue: #1740
45-
- Plan: `.claude/plans/wave-loop-769.md`
43+
- Branch: `wave-loop-770` (to create after W769 merge)
44+
- Issue: #1741
45+
- Plan: `.claude/plans/wave-loop-770.md`
4646

4747
### 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.
48+
- Variant A (recommended): continue the odd outer-dimension ladder with `[359][2]^6 Pt`.
49+
- Variant B: keep width at ~0.697 MiBit but move the packed var to bench/function scope.
5050
- Variant C: add `if`-guarded indexed signed field writes at the current width.
5151

5252
---

0 commit comments

Comments
 (0)