|
| 1 | +# Wave Loop 430 Decomposed Plan |
| 2 | + |
| 3 | +**Issue:** #1388 |
| 4 | +**Branch:** `wave-loop-430` |
| 5 | +**Date:** 2026-07-01 |
| 6 | +**Anchor:** φ² + φ⁻² = 3 | TRINITY |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 1. OBSERVE summary |
| 11 | + |
| 12 | +- We are on `wave-loop-430`, issue `#1388`. |
| 13 | +- W429 closed with PR #1387; next wave should continue the FPGA boot-evidence line. |
| 14 | +- The bench is **partially unblocked**: a Digilent HS2 FTDI cable is connected to |
| 15 | + the XC7A200T Wukong V1 board (`idcode 0x03636093`). `openFPGALoader -c digilent_hs2` |
| 16 | + works for SRAM load, STAT read, and **XADC readout**. |
| 17 | +- Live XADC probe returned: |
| 18 | + ```text |
| 19 | + temp: 42.8206 °C |
| 20 | + vccint: 1.00049 V |
| 21 | + vccaux: 1.80615 V |
| 22 | + ``` |
| 23 | +- **P12 CCLK probe is still unwired**, so real CCLK capture (Variant A) is not |
| 24 | + possible today. |
| 25 | +- No external CSV/VCD captures exist in the repo, so pure import-only Variant B |
| 26 | + is also not directly available. |
| 27 | +- Therefore the default selection rule points to **Variant B via real XADC |
| 28 | + readout**, with a small formal-extension side-car so the wave also advances |
| 29 | + the PVT-aware theorem library. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## 2. Weak points |
| 34 | + |
| 35 | +1. **XADC readout is not wired into `tri fpga`.** `boot-log`, `cold-por`, and |
| 36 | + `cclk-sweep` still emit `"source": "not_read"` for `xadc`. The live operating |
| 37 | + point cannot yet flow into generated Lean theorems or JSON logs. |
| 38 | +2. **P12 CCLK probe unwired.** Real CCLK capture for OSCFSEL 6/7 remains blocked. |
| 39 | +3. **SPI flash cold-POR automation needs a relay gate.** Without it, the physical |
| 40 | + OSCFSEL sweep still requires manual power cycles. |
| 41 | +4. **Gen-verilog #1245 residual 7 failures** are tied to tuple-return / `let` |
| 42 | + destructuring / ROM arrays / CORDIC. They are not safe as a single-wave |
| 43 | + regression-free sub-fix. |
| 44 | +5. **Competitive pressure from Lean-native HDL** (Sparkle/Verilean, CktFormalizer, |
| 45 | + Aria-HDL) is rising; the ternary + physical-evidence angle is the key |
| 46 | + differentiator. |
| 47 | +6. **PVT derating coefficients remain conservative placeholders**, not Micron |
| 48 | + datasheet values. Any new XADC-derived operating point must be explicitly |
| 49 | + framed as "within the modeled envelope" rather than "exact datasheet". |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## 3. Competitor snapshot (July 2026) |
| 54 | + |
| 55 | +- **Sparkle / Verilean**: last public push 2026-07-03; PR #66 (IP.Net + compiler |
| 56 | + perf) and PR #65 (RV32 divider proof) remain the headline 2026 signals. Still |
| 57 | + the closest Lean-native competitor. |
| 58 | +- **Clash**: 1.11.0 is only a Hackage candidate; latest release remains 1.10.0 |
| 59 | + (April 2026). No new formal headline. |
| 60 | +- **Chisel / CIRCT / firtool**: Chisel 7.13.0 (June 2026) is the latest release; |
| 61 | + firtool 1.152.0 (July 4 2026) is the latest available. No 7.14.0 / 1.153 |
| 62 | + evidence yet. |
| 63 | +- **CktFormalizer**: arXiv 2605.07782 (May 2026) — LLM-to-circuit autoformalization |
| 64 | + in Lean 4, 95–100% synthesis/P&R success, 35% area / 30% power reduction with |
| 65 | + closed-loop PPA optimization. Validates Lean 4 as a hardware proof backend. |
| 66 | +- **TernaryCore**: `shepherdscientific/ternarycore` (April–May 2026) — BitNet b1.58 |
| 67 | + ternary inference on FPGA, zero-DSP MAC/dot/GEMM, 31/31 simulation tests. |
| 68 | +- **ternfpga**: `Neumann-Labs/ternfpga` (June 2026) — multiplier-free ternary LLM |
| 69 | + engine on Arty A7-35T, claims better energy-per-token than RTX 3060. |
| 70 | +- **KU Leuven MICAS ternary-lut-dse** (April 2026) — Chisel RTL generator for |
| 71 | + LUT-based 1.58-bit LLM accelerators, validated in TSMC 16nm. |
| 72 | +- **Aria-HDL**: no new July signal; keep watching. |
| 73 | + |
| 74 | +Strategic implication: the Lean-native + ternary + physical-evidence triangle is |
| 75 | +still the unique intersection. W430 should harden the physical-evidence loop by |
| 76 | +consuming real XADC data. |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## 4. Variant selection |
| 81 | + |
| 82 | +**Primary: Variant B — real XADC readout.** |
| 83 | + |
| 84 | +The board is reachable and `openFPGALoader --read-xadc` already returns live |
| 85 | +data. Implementing a parser and wiring it into `tri fpga boot-log` / |
| 86 | +`cold-por` / `cclk-sweep` advances the physical boot-evidence story without |
| 87 | +needing the P12 probe or relay gate. |
| 88 | + |
| 89 | +**Side-car: a small formal extension.** |
| 90 | +Add a Lean lemma that any operating point with temp ≤ 85 °C, vccint ≥ 900 mV, |
| 91 | +vccaux ≥ 1800 mV lies inside the modeled PVT rectangle, plus a theorem that the |
| 92 | +real XADC values (≈43 °C, ≈1000 mV, ≈1806 mV) satisfy this rectangle. This gives |
| 93 | +AC-C1-style coverage and links the live measurement to the PVT envelope |
| 94 | +family. |
| 95 | + |
| 96 | +**Gen-verilog #1245:** re-evaluate; if no narrow subclass is safe, explicitly |
| 97 | +defer and update the defects doc. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## 5. Decomposed implementation steps |
| 102 | + |
| 103 | +### 5.1 Parse `openFPGALoader --read-xadc` output |
| 104 | +- Add `XadcContext` struct in `cli/tri/src/fpga.rs`: |
| 105 | + - `temp_c: f64`, `max_temp_c: f64`, `min_temp_c: f64` |
| 106 | + - `vccint_v: f64`, `max_vccint_v: f64`, `min_vccint_v: f64` |
| 107 | + - `vccaux_v: f64`, `max_vccaux_v: f64`, `min_vccaux_v: f64` |
| 108 | + - `raw: serde_json::Value` |
| 109 | +- Add `read_xadc_via_openfpgaloader(cable: &str) -> Result<XadcContext>`. |
| 110 | + - Run `openFPGALoader -c <cable> --read-xadc`. |
| 111 | + - Parse the emitted pseudo-JSON with `serde_json` after a normalization pass |
| 112 | + (remove trailing commas, collapse whitespace). Fallback to regex if |
| 113 | + normalization fails. |
| 114 | +- Add unit tests with captured sample output (the live probe above). |
| 115 | + |
| 116 | +### 5.2 Wire live XADC into `tri fpga` commands |
| 117 | +- Add `--xadc` flag to `FpgaCmd::BootLog`, `FpgaCmd::ColdPor`, and |
| 118 | + `FpgaCmd::CclkSweep` (default: false / auto-detect only when the flag is |
| 119 | + passed, to avoid breaking board-less CI). |
| 120 | +- When `--xadc` is set and a Digilent cable is detected: |
| 121 | + - Call `read_xadc_via_openfpgaloader`. |
| 122 | + - Populate the `xadc` field of `BootLog` / `ColdPorLog` / `SweepLog` with |
| 123 | + `source: "xadc"` and live values. |
| 124 | +- When `--xadc` is not set or the board is absent, keep the existing |
| 125 | + `"not_read"` / PVT-context fallback so board-less CI stays green. |
| 126 | +- Add `test_read_xadc_context_parses_sample_output` and a test that a missing |
| 127 | + board yields an actionable error. |
| 128 | + |
| 129 | +### 5.3 Formal bridge in Lean 4 |
| 130 | +- Add `pvt_operating_rectangle` predicate in |
| 131 | + `proofs/lean4/Trinity/TernaryFPGABoot.lean`: |
| 132 | + - `temp_c ≤ PVT_TEMP_MAX_C` |
| 133 | + - `vccint_mv ≥ PVT_VCCINT_MIN_MV` |
| 134 | + - `vccaux_mv ≥ PVT_VCCAUX_MIN_MV` |
| 135 | +- Add `xadc_operating_point_within_pvt_envelope` theorem: the real operating |
| 136 | + point (≈43 °C, ≈1000 mV, ≈1806 mV) satisfies the rectangle. |
| 137 | +- Add `xadc_context_implies_pvt_envelope` theorem: any XADC context within the |
| 138 | + rectangle implies the worst-case PVT corner bounds the flash timing. This |
| 139 | + links the live measurement to the existing `measured_cclk_from_raw_ns_with_pvt` |
| 140 | + family. |
| 141 | + |
| 142 | +### 5.4 Documentation and evidence |
| 143 | +- Update `fpga/HARDWARE_SSOT.md` §3.6.19: |
| 144 | + - Add the canonical `tri fpga read-xadc` / `--xadc` recipe. |
| 145 | + - Document the captured sample values and the `--pvt-context` workflow. |
| 146 | +- Create `docs/reports/FPGA_LOOP_EVIDENCE_W430_2026-07-01.md` with the live XADC |
| 147 | + capture and the JSON log artifact. |
| 148 | + |
| 149 | +### 5.5 Competitor refresh |
| 150 | +- Update `docs/reports/T27_VS_FORMAL_HDL_2026.md`: |
| 151 | + - Refresh date to W430. |
| 152 | + - Add the July 2026 signals above. |
| 153 | + - Note that the live XADC readout further differentiates the physical-evidence |
| 154 | + loop. |
| 155 | + |
| 156 | +### 5.6 Gen-verilog triage |
| 157 | +- Re-run `./scripts/tri test` at start of wave and confirm the same 7 failures. |
| 158 | +- If no narrow safe subclass appears, update |
| 159 | + `docs/reports/GEN_VERILOG_DEFECTS_REPRO.md` with W430 triage decision. |
| 160 | + |
| 161 | +### 5.7 Verification |
| 162 | +- `cargo test --bin tri fpga::`: must pass. |
| 163 | +- `lake build Trinity.TernaryFPGABoot`: must pass. |
| 164 | +- `./scripts/tri test`: must pass except the 7 pre-existing #1245 failures. |
| 165 | +- Manual: `tri fpga read-xadc` or `tri fpga boot-log ... --xadc` produces a JSON |
| 166 | + log with `xadc.source: "xadc"` and live values. |
| 167 | + |
| 168 | +### 5.8 Close-out |
| 169 | +- Write `docs/reports/WAVE_LOOP_430_REPORT.md`. |
| 170 | +- Write `docs/reports/FPGA_LOOP_COOPERATION_W431_2026-07-01.md` with Variant A/B/C |
| 171 | + for W431. |
| 172 | +- Create GitHub issue #1389 and branch `wave-loop-431`. |
| 173 | +- Update `.trinity/current-issue.md`, `docs/NOW.md`, `.trinity/experience.md`, and |
| 174 | + persistent memory. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +## 6. Acceptance criteria |
| 179 | + |
| 180 | +- AC-B1: `tri fpga read-xadc` (or `--xadc` flag) returns live temp/vccint/vccaux |
| 181 | + from the board and emits `source: "xadc"`. |
| 182 | +- AC-B2: `boot-log`, `cold-por`, and `cclk-sweep` can include live XADC context |
| 183 | + in their JSON logs. |
| 184 | +- AC-B3: At least one new Lean theorem links the live/any XADC operating point |
| 185 | + to the PVT envelope and builds with `lake build`. |
| 186 | +- AC-B4: The XADC recipe is documented in `fpga/HARDWARE_SSOT.md`. |
| 187 | +- AC-C1-equivalent: the formal extension above satisfies the Variant C fallback |
| 188 | + theorem requirement. |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## 7. Files to touch |
| 193 | + |
| 194 | +- `cli/tri/src/fpga.rs` |
| 195 | +- `proofs/lean4/Trinity/TernaryFPGABoot.lean` |
| 196 | +- `fpga/HARDWARE_SSOT.md` |
| 197 | +- `docs/reports/T27_VS_FORMAL_HDL_2026.md` |
| 198 | +- `docs/reports/GEN_VERILOG_DEFECTS_REPRO.md` |
| 199 | +- `docs/reports/WAVE_LOOP_430_REPORT.md` (new) |
| 200 | +- `docs/reports/FPGA_LOOP_EVIDENCE_W430_2026-07-01.md` (new) |
| 201 | +- `docs/reports/FPGA_LOOP_COOPERATION_W431_2026-07-01.md` (new) |
| 202 | +- `docs/NOW.md` |
| 203 | +- `.trinity/current-issue.md` |
| 204 | +- `.trinity/experience.md` |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## 8. Risks and mitigations |
| 209 | + |
| 210 | +| Risk | Mitigation | |
| 211 | +|---|---| |
| 212 | +| openFPGALoader `--read-xadc` output format changes | Parser uses normalization + regex fallback; unit test against captured sample. | |
| 213 | +| Board not powered during CI | `--xadc` is opt-in; board-less CI uses existing placeholder path. | |
| 214 | +| Live XADC values drift across runs | Evidence file records one representative capture; the formal theorem bounds the rectangle, not a single point. | |
| 215 | +| No narrow gen-verilog fix | Explicitly defer and update defects doc; do not broaden scope. | |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +*φ² + φ⁻² = 3 | TRINITY* |
0 commit comments