Skip to content

refactor(runtime): generate the edges of derived clock domains as SIR - #1844

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/derived-edge-sir-a
Oct 24, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/derived-edge-sir-a

Conversation

@tignear

@tignear tignear commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Part of #1123, step 3b-2: #1786 (derived clock domains), PR A of four (A → B → D → C).

A generator that emits one edge of an event's signal, with every derived clock domain the edge reaches, as SIR. Nothing runs it yet: B uses it for Simulator::tick, D inlines it into the compiled scheduler's slots. No user-visible change and no perf change: only the tests attach its units.

What it emits

derived_edge::EdgePlan is celox_runtime::DerivedTickPlan over the program's units: the event's own domain, the state-derived domains (EventTopology::derived_events) and the gated clocks (combinational_derived) with their gate programs. EdgePlan::emit emits DerivedTickPlan::run for an edge whose signal already moved, step for step:

  1. the state-derived clocks' levels before the edge, the baseline of their edges for the whole phase (sample_domains);
  2. each gated clock judged from its gate program with the signal at its old and new level (run_gated_fast); its level after the edge is its baseline in the rounds;
  3. the event's domain (when it sees its active edge) and the fired gated domains run together: one by eval_apply, several by eval_only for each, then apply for each, in entry order (fire), or, when the gated domains are independent, those first, one at a time, then the event's own (fire_with_gated); with a settle first when combinational logic is stale;
  4. a settle, then rounds: every state-derived or gated domain not fired yet whose clock moved to its active edge fires, together; a settle; until none does (rounds).

One fire section serves the edge and the rounds; the domains to fire and those fired so far are its block parameters, so each domain's units and combinational logic are inlined once (logic twice: before and after a fire). Gate programs (GateOp) become 64-bit SIR operations; settled_edge's two-state rows become the edge tests.

It covers the plans the Rust walk runs without settling for its gates: two-state designs whose gated clocks all have gate programs (DerivedTickPlan::fast). Four-state designs, gates without programs and plans of coincident sources (several levers) stay with the Rust walk.

Validation

  • derived_edge unit tests: a test-only builder option attaches one unit per event, edge, settle and own-edge case; each test drives 60 edges of clk (rising, falling, repeated edges that change nothing) and host writes of en, runs each edge through the Rust walk (celox_runtime::run_edge) and through the generated unit, and compares the whole design state and the stale-logic flag after every edge. Designs: a gated clock; an inverted clock with a falling-edge gated domain; a divider cascade (half, quarter); a gated clock whose enable the clock's domain toggles; an independent gated domain. Skipping the rounds, or never firing gated domains at the edge, fails them.
  • --lib: 213 passed.
  • cargo test -p celox --features systemverilog --test systemverilog (CELOX_SCHEDULER=differential): 4,351 passed, 20 ignored.
  • napi build --platform --target wasm32-wasip1-threads: builds. clippy -D warnings (with and without tests) and cargo fmt --check: clean.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-24T05:19:13.999594Z 491b133 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 24, 2026
A derived-edge generator emits one edge of an event's signal as SIR,
with the rules of DerivedTickPlan: gated clocks judged from their gate
programs at the signal's old and new level and fired with the event's
domain (one at a time first when they are independent), a settle, then
cascade rounds that fire every state-derived or gated domain whose clock
moved to its active edge, each at most once, until none does. One fire
section serves the edge and the rounds; the mask of domains to fire and
those fired so far are its block parameters.

It covers two-state plans whose gated clocks all have gate programs.
Nothing runs it yet: its tests attach a unit per edge case and compare
each edge with the Rust plan walk on gated, inverted, falling-edge,
divided and commit-enabled clocks and independent gated domains.

Change-Id: If25bbf2ad20810c16ad37ad44998d8059c25be02
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 2 hours 16 minutes 25 seconds in the queue, including 1 hour 32 minutes 15 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant