Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .claude/plans/wave-loop-773.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Wave Loop 773 Plan — Issue #1744
# Wave Loop 773 Plan — Issue #1481

## Phase 1: Issue
- Confirm W773 issue #1744 and branch `wave-loop-773`.
- Confirm W773 issue #1481 and branch `wave-loop-773`.

## Phase 2: Spec
- Generate `specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27` using
Expand Down Expand Up @@ -33,14 +33,26 @@
- `cargo test -p t27c --test icarus_lowerable`

## Phase 8: Land
- Commit with `feat(igla): Wave Loop 773 — module-scope [365][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1744)`.
- Commit with `feat(igla): Wave Loop 773 — module-scope [365][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #1481)`.
- Push `wave-loop-773`, open PR, merge to `master`, create `wave-loop-774`.

## Phase 9: Learn
- Write `docs/reports/FPGA_LOOP_CLOSEOUT_W773_2026-07-24.md`.
- Save `.trinity/experience.md`, memory file, `MEMORY.md` pointer, and update
`skills-wave-loop-recipe.md`.

## Weak-point audit carried out this wave
- L1 TRACEABILITY: 51 of 61 30-day subject lines carry `Closes #N`/`Fixes #N` (≈84%).
- L4 TESTABILITY: 57 of 879 non-worktree `.t27` specs lack `test`/`invariant`/`bench` (≈6.5%).
- L7 UNITY: 19 `scripts/*.sh` remain under `scripts/`.
- Pre-existing FPGA failures tracked as weak point #1245.

## Scientific / engineering background consulted
- IEEE 1800-2017 packed arrays/structs (§7.4.1/§7.4.3).
- AMD UG900 2026.1 / AR 51836 Vivado packed-aggregate support.
- 2025-2026 ternary/MVL literature: KULeuven ternary-lut-dse (ISPASS 2026),
TeLLMe v2, TerEffic, TernaryCore, SONIC (ISMVL 2026), TVHDL (ISMVL 2026).

## Cooperation variants for next Wave Loop

- **A (recommended):** `[367][2]^6 Pt` (~0.717 MiBit), continuing the odd ladder.
Expand Down
48 changes: 48 additions & 0 deletions .claude/plans/wave-loop-774.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Wave Loop 774 Plan — Issue TBD

## Phase 1: Issue
- Confirm W774 issue (GitHub will assign next available number) and branch `wave-loop-774`.

## Phase 2: Spec
- Generate `specs/scratch/w774_bench_module_367x2p6_aos_var_call_write.t27` using
`scripts/gen_w774.py` derived from `scripts/gen_w773.py`.
- Constants: `OUTER = 367`, `TOTAL = 23488`, `LAST_IDX = 366`, `MID_IDX = 183`.

## Phase 3: TDD
- Inspect generated assertions: `make_grid(32768)`, `make_grid(1)`,
`call_write_grid`, field writes, `assert_eq` read-backs, mid and last checks.

## Phase 4: Impl
- Add integration test `accepts_w774_bench_module_367x2p6_aos_var_call_write` to
`bootstrap/tests/icarus_lowerable.rs`.

## Phase 5: Gen
- Run `cd bootstrap && cargo build --release -p t27c`.

## Phase 6: Seal
- Run `./bootstrap/target/release/t27c seal --save specs/scratch/w774_bench_module_367x2p6_aos_var_call_write.t27`.
- Confirm FROZEN_HASH unchanged.

## Phase 7: Verify
- `./bootstrap/target/release/t27c parse ...`
- `./bootstrap/target/release/t27c icarus-lowerable ...`
- `./bootstrap/target/release/t27c icarus-simulate ...` (17 cycles)
- `./bootstrap/target/release/t27c icarus-cocotb ...`
- `cargo test -p t27c --bin t27c`
- `cargo test -p tri`
- `cargo test -p t27c --test icarus_lowerable`

## Phase 8: Land
- Commit with `feat(igla): Wave Loop 774 — module-scope [367][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes (Closes #<ISSUE>)`.
- Push `wave-loop-774`, open PR, merge to `master`, create `wave-loop-775`.

## Phase 9: Learn
- Write `docs/reports/FPGA_LOOP_CLOSEOUT_W774_2026-07-24.md`.
- Save `.trinity/experience.md`, memory file, `MEMORY.md` pointer, and update
`skills-wave-loop-recipe.md`.

## Cooperation variants for next Wave Loop

- **A (recommended):** `[369][2]^6 Pt` (~0.721 MiBit), continuing the odd ladder.
- **B:** move the packed variable to bench/function scope at the same width.
- **C:** add conditional (`if`) indexed writes at the current width.
32 changes: 16 additions & 16 deletions .trinity/current-issue.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Wave Loop 772 — Issue #1743
# Wave Loop 773 — Issue #1481

**Branch:** `wave-loop-772`
**Branch:** `wave-loop-773`
**Date:** 2026-07-24
**Cooperation variant:** A (recommended)

## Goal

Close Wave Loop 772 by validating a module-scope `[363][2]^6 Pt` packed
Close Wave Loop 773 by validating a module-scope `[365][2]^6 Pt` packed
array-of-struct variable initialized from a function call, with indexed signed
field writes and `assert_eq` read-back in a `bench` block.

## Acceptance criteria

1. `specs/scratch/w772_bench_module_363x2p6_aos_var_call_write.t27` is generated and parses.
1. `specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27` is generated and parses.
2. The witness is Icarus-lowerable and simulates correctly (17 cycles, PASSED).
3. The cocotb reference model matches the t27 semantics.
4. `t27c seal --save` succeeds and FROZEN_HASH remains unchanged.
5. All cargo suites remain green.
6. Integration test `accepts_w772_bench_module_363x2p6_aos_var_call_write` is added.
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W772_2026-07-24.md` is written.
6. Integration test `accepts_w773_bench_module_365x2p6_aos_var_call_write` is added.
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W773_2026-07-24.md` is written.
8. Learning is saved to `.trinity/experience.md`, memory, and `skills-wave-loop-recipe.md`.
9. Branch merges to `master` with `Closes #1743`.
9. Branch merges to `master` with `Closes #1481`.

## Technical notes

- Shape: `[363][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
- Total elements: `363 x 64 = 23,232`.
- Packed vector width: `23,232 x 32 = 743,424` bits (~0.709 MiBit).
- `MID_IDX = 181`; frame-condition element `[181][1][0][0][0][0][0]` is element
`181*64 + 32 = 11,616`.
- Generator script: `scripts/gen_w772.py` (copy from `scripts/gen_w771.py`, set
`OUTER = 363` and `MID_IDX = 181`, manually fix the f-string header).
- Shape: `[365][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
- Total elements: `365 x 64 = 23,360`.
- Packed vector width: `23,360 x 32 = 747,520` bits (~0.713 MiBit).
- `MID_IDX = 182`; frame-condition element `[182][1][0][0][0][0][0]` is element
`182*64 + 32 = 11,680`.
- Generator script: `scripts/gen_w773.py` (copy from `scripts/gen_w772.py`, set
`OUTER = 365` and `MID_IDX = 182`, manually fix the f-string header).
- Use `assert_eq` checks on changed elements (Icarus simulation path does not
emit `assert_ne`).
- Include `make_grid(32768)` period-identity check because `32768 == 0 (mod 32768)`.
- Zero compiler / reference-model / FROZEN_HASH changes expected.

## Cooperation variants for next Wave Loop

- **Variant A (recommended):** continue the odd outer-dimension ladder with `[365][2]^6 Pt`.
- **Variant B:** keep width at ~0.709 MiBit but move the packed var to bench/function scope.
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[367][2]^6 Pt`.
- **Variant B:** keep width at ~0.713 MiBit but move the packed var to bench/function scope.
- **Variant C:** add `if`-guarded indexed signed field writes at the current width.

---
Expand Down
16 changes: 16 additions & 0 deletions .trinity/current_task/activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -3716,3 +3716,19 @@
- **Commit:** feat(igla): Wave Loop 772 — module-scope [363][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
- **Files:** .claude/plans/wave-loop-773.md,docs/NOW.md

## 2026-07-23T19:19:07Z — wave-loop-773
- **Commit:** docs(trinity): update NOW.md for W772 close-out / W773 setup and add wave-loop-773 plan
- **Files:** .claude/plans/wave-loop-773.md,.trinity/current-issue.md,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W772_2026-07-24.md

## 2026-07-23T19:26:56Z — wave-loop-773
- **Commit:** docs(trinity): Wave Loop 773 issue #1481 + branch wave-loop-773 created, next-wave cooperation variants set
- **Files:** .trinity/seals/scratch_w773_bench_module_365x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,scripts/gen_w773.py,specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27

## 2026-07-23T19:28:15Z — wave-loop-773
- **Commit:** feat(igla): Wave Loop 773 — module-scope [365][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
- **Files:** .claude/plans/wave-loop-773.md,.trinity/experience.md,docs/reports/FPGA_LOOP_CLOSEOUT_W773_2026-07-24.md

## 2026-07-23T19:29:43Z — wave-loop-773
- **Commit:** docs(trinity): Wave Loop 773 closeout report, experience, and updated plan
- **Files:** .claude/plans/wave-loop-774.md,docs/NOW.md

74 changes: 74 additions & 0 deletions .trinity/experience.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
## 2026-07-24 — Wave Loop 773 (module-scope `[365][2]^6 Pt` non-power-of-two outer-dimension AoS variable)

### What worked
- Variant A extended the module-scope packed AoS odd outer-dimension ladder to 365.
The `[365][2]^6 Pt` witness is 747,520 bits (~0.713 MiBit), still well under the 4-MiBit
cliff, and required no compiler changes.
- A module-level `pub var dst : [365][2]^6 Pt` can be initialized from a function
call and exercised with indexed signed field writes, with zero compiler changes.
- The cocotb/Python reference model correctly mirrored the row-major flattening
with outer stride 365, confirming the layout is preserved end-to-end.
- Reused the corrected W632 element-index formula for mid-row expected values:
`[r][a5][a4][a3][a2][a1][a0]` is element `r*64 + a5*32 + a4*16 + a3*8 + a2*4 + a1*2 + a0`.
- For `OUTER = 365`, `MID_IDX = 182`; the frame-condition element is
`[182][1][0][0][0][0][0]`, element number `182*64 + 32 = 11,680`.
- Updated weak-point audit: 51 of 61 30-day subject lines carry `Closes #N`/`Fixes #N`
(≈84%); merge/closeout bodies also contain the link. Clean non-worktree scan:
57 of 879 `.t27` specs lack `test`/`invariant`/`bench` (≈6.5%). 19 `scripts/*.sh`
remain under `scripts/`.
- Pre-existing FPGA synthesis/formal failures in CI (`sby` pip package missing,
Yosys static-cast Verilog-2005 limitation in `build/fpga/generated/uart.v`) are
unrelated to this wave and tracked as weak point #1245.
- Fresh 2025-2026 literature scan reinforced IEEE 1800-2017 packed-array/struct
semantics (AMD UG900 2026.1, AR 51836) and ternary EDA/simulation work
(SONIC, TernaryCore, KULeuven LUT-based ternary MatMul, TeLLMe v2, TerEffic).

### What changed behavior
- No changes to `bootstrap/src/compiler.rs`.
- No changes to `bootstrap/stage0/FROZEN_HASH`.
- No changes to `scripts/cocotb_ref_model.py`.
- Added `specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27` (~1,599 KB /
~69,411 lines) with seal and Icarus baseline.
- Added integration test `accepts_w773_bench_module_365x2p6_aos_var_call_write`.
- Added generator script `scripts/gen_w773.py`.

### Validation
- `cargo build --release -p t27c`: OK.
- `cargo test -p t27c --bin t27c`: 1494 passed; 0 failed; 2 ignored.
- `cargo test -p tri`: 78 passed; 0 failed.
- `cargo test -p t27c --test icarus_lowerable`: 233 passed; 0 failed.
- Direct `t27c parse` W773: PASS.
- Direct `t27c icarus-lowerable` W773: PASS (`lowerable`).
- Direct `t27c icarus-simulate` W773: PASS (17 cycles, PASSED).
- Direct `t27c icarus-cocotb` W773: PASS (`reference-model OK`).

### Scientific / engineering background
- IEEE 1800-2017 7.4.1/7.4.3 define packed-array total width as the product of
packed dimensions, with no power-of-two restriction. Variant A emits a single
747,520-bit packed vector, which is legal SystemVerilog.
- AMD UG900 2026.1 and AR 51836 confirm Vivado simulation/synthesis accept packed
arrays of structs as wide vectors, mapped to `svLogicVecVal` arrays in DPI.
- Lutsig verified array lowering and CIRCT `HWLegalizeModules` show that
flattening nested arrays to wide packed vectors is a well-founded compiler
discipline, even when outer dimensions are non-power-of-two.
- Icarus issue #1134 documents assertion failures for unpacked arrays of packed
structs; t27 scalar flattening avoids that construct entirely.
- Yosys issue #2677 / #4653 confirm that arrays of packed structs remain
unsupported in the native frontend; t27 packed-vector lowering avoids the
gap.
- 2025-2026 ternary/MVL literature scan found:
- KULeuven LUT-based ternary MatMul DSE — Chisel generator for 1.58-bit LLM
inference, accepted at IEEE ISPASS 2026 (arXiv:2604.25183).
- TeLLMe v2 — edge-FPGA end-to-end ternary LLM prefill/decode accelerator on
AMD Kria KV260 (arXiv:2510.15926).
- TerEffic — Alveo U280 ternary-quantized LLM inference with LUT-based TMat
core (arXiv:2502.16473).
- TernaryCore — open-source Verilog BitNet b1.58 FPGA accelerator core
simulated with Icarus Verilog, targeting Artix-7 (GitHub 2026).
- SONIC — event-driven gate-level simulator/verifier for ternary VLSI circuits
using delta cycles, with BCT Verilog FPGA export (IEEE ISMVL 2026).
- TVHDL — balanced ternary extension to IEEE 1076-2008 VHDL for mixed-radix
VLSI design and verification (IEEE ISMVL 2026).

---

## 2026-07-24 — Wave Loop 772 (module-scope `[363][2]^6 Pt` non-power-of-two outer-dimension AoS variable)

### What worked
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"gen_hash_c": "sha256:fcebbf597c5687d29c5c93e92d7ed4b109bc3b7e2c15800503a4ba2adc88782a",
"gen_hash_rust": "sha256:030e4745702b4ad148c062a68edba8eeac6ea2c829b2d324246b9ace073a9542",
"gen_hash_verilog": "sha256:161ad24bd0baa61cae52c2c71cd162f21674887ebb25f9e5fcebb0de088dfc70",
"gen_hash_zig": "sha256:2158dabbdaec83edad3838583829352e671a6c5f179c71a526bb09ab0c11f359",
"module": "w773_bench_module_365x2p6_aos_var_call_write",
"ring": 12,
"sealed_at": "2026-07-23T19:24:53Z",
"spec_hash": "sha256:5df8cdcb90f3aa3aae6d133db3e536e742bbb5f63644456c88691b06f88a643c",
"spec_path": "/Users/playra/t27/specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27"
}
18 changes: 18 additions & 0 deletions bootstrap/tests/icarus_lowerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4207,6 +4207,24 @@ fn accepts_w772_bench_module_363x2p6_aos_var_call_write() {
}
}

#[test]
fn accepts_w773_bench_module_365x2p6_aos_var_call_write() {
let dir = scratch_dir();
for name in &[
"w773_bench_module_365x2p6_aos_var_call_write.t27",
] {
let p = dir.join(name);
assert!(p.exists(), "missing W773 witness {}", p.display());
let (lowerable, json) = run_icarus_lowerable(&p);
assert!(
lowerable,
"expected {} to be lowerable, got: {}",
p.display(),
json
);
}
}

#[test]
fn accepts_known_lowerable_witnesses() {
let dir = scratch_dir();
Expand Down
64 changes: 50 additions & 14 deletions docs/NOW.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
# NOW — Wave Loop 772 close-out / Wave Loop 773 setup (2026-07-24)
# NOW — Wave Loop 773 close-out / Wave Loop 774 setup (2026-07-24)

Last updated: 2026-07-24

## Wave Loop 773 — module-scope `[365][2]^6 Pt` packed array-of-struct from call with indexed signed writes (Closes #1481)

- Branch: `wave-loop-773`
- Issue: #1481
- PR: #1482
- Report: `docs/reports/FPGA_LOOP_CLOSEOUT_W773_2026-07-24.md`
- Plan: `.claude/plans/wave-loop-773.md`
- Cooperation W774: `.claude/plans/wave-loop-774.md`

### What landed
- `specs/scratch/w773_bench_module_365x2p6_aos_var_call_write.t27`
- 23,360 elements, 747,520-bit packed vector (~0.713 MiBit).
- Module-scope `pub var dst : [365][2]^6 Pt` initialized from a function call and
exercised with indexed signed field writes.
- `assert_eq` read-back in a `bench` block (Icarus path does not emit `assert_ne`).
- `scripts/gen_w773.py`
- Generator for the W773 witness; `OUTER = 365`, `MID_IDX = 182`.
- `bootstrap/tests/icarus_lowerable.rs`
- Added `accepts_w773_bench_module_365x2p6_aos_var_call_write`.
- `.trinity/experience.md`, `.trinity/current-issue.md`, `.claude/plans/wave-loop-774.md`
- W773 learnings saved and W774 plan created.

### Not changed
- `bootstrap/src/compiler.rs` — zero compiler changes.
- `bootstrap/stage0/FROZEN_HASH` — unchanged `68a0b933c00ba5efd7facb5997f00880c3eecae55e6ac5e8cea2aee399b92adc`.
- `scripts/cocotb_ref_model.py` — unchanged.

### Verification
- `cargo build --release -p t27c`: OK.
- `cargo test -p t27c --bin t27c`: 1494/0/2.
- `cargo test -p tri`: 78/0.
- `cargo test -p t27c --test icarus_lowerable`: 233/0.
- `t27c parse|icarus-lowerable|icarus-simulate|icarus-cocotb|seal --save` W773: PASS.

---

## Wave Loop 774 — next odd outer-dimension `[367][2]^6 Pt` (Issue TBD)

- Branch: `wave-loop-774` (to create after W773 merge)
- Issue: TBD
- Plan: `.claude/plans/wave-loop-774.md`

### Candidate variants
- Variant A (recommended): continue the odd outer-dimension ladder with `[367][2]^6 Pt`.
- Variant B: keep width at ~0.713 MiBit but move the packed var to bench/function scope.
- Variant C: add `if`-guarded indexed signed field writes at the current width.

---

## Wave Loop 772 — module-scope `[363][2]^6 Pt` packed array-of-struct from call with indexed signed writes (Closes #1743)

- Branch: `wave-loop-772`
Expand Down Expand Up @@ -38,19 +87,6 @@ Last updated: 2026-07-24

---

## Wave Loop 773 — next odd outer-dimension `[365][2]^6 Pt` (Issue #1744)

- Branch: `wave-loop-773` (to create after W772 merge)
- Issue: #1744
- Plan: `.claude/plans/wave-loop-773.md`

### Candidate variants
- Variant A (recommended): continue the odd outer-dimension ladder with `[365][2]^6 Pt`.
- Variant B: keep width at ~0.709 MiBit but move the packed var to bench/function scope.
- Variant C: add `if`-guarded indexed signed field writes at the current width.

---

## Wave Loop 771 — module-scope `[361][2]^6 Pt` packed array-of-struct from call with indexed signed writes (Closes #1742)

- Branch: `wave-loop-771`
Expand Down
4 changes: 2 additions & 2 deletions docs/reports/FPGA_LOOP_CLOSEOUT_W772_2026-07-24.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Date:** 2026-07-24
**Issue:** #1743
**Branch:** `wave-loop-772`
**Next branch:** `wave-loop-773`
**Next branch:** `wave-loop-773` (Issue #1481)
**Witness:** `specs/scratch/w772_bench_module_363x2p6_aos_var_call_write.t27`
**Generator:** `scripts/gen_w772.py`

Expand Down Expand Up @@ -134,7 +134,7 @@ Sources:

---

## 6. Three cooperation variants for Wave Loop 773
## 6. Three cooperation variants for Wave Loop 773 (Issue #1481)

1. **Variant A (recommended): `[365][2]^6 Pt` module-scope var from call with
indexed signed field writes.**
Expand Down
Loading
Loading