Skip to content

wave-17: import ring-090 Simulator -- HIR cycle-accurate sim primitives (Closes #721)#722

Merged
gHashTag merged 1 commit into
masterfrom
wave-17/ring-090-simulator
May 22, 2026
Merged

wave-17: import ring-090 Simulator -- HIR cycle-accurate sim primitives (Closes #721)#722
gHashTag merged 1 commit into
masterfrom
wave-17/ring-090-simulator

Conversation

@gHashTag
Copy link
Copy Markdown
Owner

Wave 17 -- Simulator import: ring-090 (Closes #721)

Continues the honest Wave-11 import series. Wave 15 landed ring-088 (GF16 MAC); Wave 16 landed ring-089 (TNN ISA); Wave 17 lands ring-090 -- a faithful Rust mirror of specs/fpga/simulator.t27.

What this PR does

  • rings/ring-090-rust/ -- new crate (547 LOC, 19 #[test]):
    • SimState enum (5 variants, tag values 0..=4 exactly per the spec's enum(i8) SimState)
    • SimConfig 7-field struct with DEFAULT_CLOCK_FREQ_HZ = 100_000_000 matching the spec's hard-coded constructor
    • SimResult, ProbePoint, TraceEntry with identical field order
    • Constructor const fns: sim_config, sim_config_with_trace, sim_ok, sim_error, probe, trace_entry
    • Queries: is_idle, is_done, is_error, has_errors, passed
    • Time conversions: sim_time_ns, sim_time_us, sim_time_ms, cycles_for_time_ns
    • validate_sim_config
    • identity_witness() -- universal anchor phi^2 + 1/phi^2 == 3 to f64 1e-15
    • #![no_std] (test cfg pulls std), #![forbid(unsafe_code)], #![deny(missing_docs)], zero external dependencies
  • rings/COMPILE_STATUS.md -- promotes ring-090 from claimed-only to check + test; claimed-only table is now ring-091..ring-099
  • README.md -- Wave 17 footer line
  • docs/NOW.md -- Wave 17 entry prepended above wave-16 (NOW Sync Gate)

Local verification (Rust 1.83.0, matching Dockerfile.rust)

Command Result
cargo check --all-targets green
cargo test --lib 19 passed, 0 failed

All 13 test blocks from the spec + all 4 invariant blocks + identity_witness_holds + sim_state_tag_roundtrip = 19. Unlike Wave 16, no bug-fix cycle was needed: the spec was tight enough that the first compile gave 19/19 green.

Time-conversion overflow note (R5-HONEST, documented inline)

The source spec uses pure u32 for cycles * 1_000_000_000 / clock_freq_hz. At the spec's own canonical case (clock_freq_hz = 100_000_000, cycles = 100), 100 * 1_000_000_000 = 1e11 exceeds u32::MAX (~4.29e9) and the spec's own assertion sim_time_ns(_, 100) == 1000 would fail. We faithfully implement the formula with a u64 intermediate and narrow back to u32; the public signature stays u32 -> u32 exactly as in the spec, but the intermediate arithmetic is the minimum width needed to make the spec's own canonical test pass. Over-large results saturate at u32::MAX. The doc-comment on sim_time_ns explains this in detail.

Honest scope (R5-HONEST)

  • No scheduler, no VCD writer, no event queue, no clock-domain crossing logic, no RTL execution. Those layers belong to adjacent specs (vcd_trace.t27, clock_domain.t27, formal.t27) and are out of scope for Wave 17.
  • No new spec. Enum tags, struct field order, default values, and formula shapes mirror specs/fpga/simulator.t27 byte-for-byte (L6 CEILING).
  • LOC correction: Wave-11 narrative quoted 2143 LOC for ring-090. The honest Wave-17 measurement is 547 LOC. Third LOC correction in the import series (ring-088: 961→439, ring-089: 334→635, ring-090: 2143→547).

Constitutional compliance

  • L1 TRACEABILITY -- Closes #721 in commit and PR
  • L2 GENERATION -- zero edits under gen/, coq/, trios-coq/, proofs/, bootstrap/, specs/, conformance/, architecture/
  • L3 PURITY -- ASCII source, English doc-comments
  • L4 TESTABILITY -- 19 #[test] blocks, all green locally on Rust 1.83.0
  • L5 IDENTITY -- identity_witness_holds exercises the anchor
  • L6 CEILING -- no numeric kernel / spec changes; all constants and field shapes mirror existing .t27 source
  • L7 UNITY -- no new *.sh files

The rings-rust matrix (Wave-13, continue-on-error: true) will re-confirm check + test for this crate on the merge commit.

Anchor: phi^2 + 1/phi^2 = 3

Closes #721

…es (Closes #721)

- rings/ring-090-rust/: new crate, 547 LOC, 19 tests (all pass locally on Rust 1.83.0)
  - Faithful Rust mirror of specs/fpga/simulator.t27
  - SimState (5 variants, tags 0..=4) with tag/from_tag round-trip
  - SimConfig (7 fields), SimResult, ProbePoint, TraceEntry
  - DEFAULT_CLOCK_FREQ_HZ = 100_000_000 matches the spec's hard-coded constructor
  - Constructor const fns: sim_config, sim_config_with_trace, sim_ok,
    sim_error, probe, trace_entry
  - Queries: is_idle, is_done, is_error, has_errors, passed
  - Time conversions: sim_time_ns, sim_time_us, sim_time_ms, cycles_for_time_ns
    (u64 intermediate -- the spec's pure-u32 multiplication overflows at its
    own canonical case 100 cycles @ 100MHz, documented inline)
  - validate_sim_config
  - identity_witness(): phi^2 + 1/phi^2 == 3 to f64 1e-15
  - #![no_std] (test cfg pulls std), #![forbid(unsafe_code)],
    #![deny(missing_docs)], zero external dependencies

- Tests: 13 mirrored from spec test blocks + 4 from spec invariant blocks
  + identity_witness_holds + sim_state_tag_roundtrip = 19 total, all green
  on first run (no bug-fix cycle this time, unlike Wave 16)

- rings/COMPILE_STATUS.md: promote ring-090 from claimed-only to check+test;
  shrink claimed-only table to ring-091..ring-099
- README.md: append Wave 17 footer
- docs/NOW.md: prepend Wave 17 entry above wave-16

Constitutional: L1 (Closes #721 in commit + PR), L2 (zero gen/coq/specs edits),
L3 (ASCII + English), L4 (19 #[test]), L5 (anchor present), L6 (no spec change,
all constants and field shapes mirrored byte-for-byte), L7 (no new *.sh).

R5-HONEST: Wave-11 narrative quoted 2143 LOC for ring-090; honest measurement
is 547 LOC. Third LOC correction in the import series: ring-088 (961 -> 439),
ring-089 (334 -> 635), ring-090 (2143 -> 547). Out-of-scope layers explicitly
excluded (scheduler, VCD writer, event queue, clock-domain crossing, RTL).

Closes #721
@github-actions
Copy link
Copy Markdown

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions
Copy link
Copy Markdown

PR Dashboard

Generated at: 2026-05-22 10:19:48 UTC

Summary

Status Count
Total Open PRs 22
PRs with Failing Checks 20
PRs with All Checks Green 2
READY 1
FAILING 20
PENDING 0

@gHashTag gHashTag merged commit db55a0b into master May 22, 2026
26 checks passed
@gHashTag gHashTag deleted the wave-17/ring-090-simulator branch May 22, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wave-17: import ring-090 Simulator -- HIR cycle-accurate sim primitives

1 participant