You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(runtime): compile derived clock domains in the compiled scheduler (3b-2) #1786
Part of #1123, step 3b-2 (compiled waits). Follows #1777.
Problem
The compiled scheduler of #1777 qualifies only designs with "no cascaded, state-derived or combinationally derived clocks". Gated clocks (clk & en) and register dividers are ordinary RTL, so the designs that need the scheduler most fall back to the Rust reference loop for every slot.
The exclusion is not a missing proof. Derived-clock edge detection already runs from a structural plan built at compile time (celox-runtimeDerivedTickPlan, run_edge): which source edges reach which derived domains, the gate's expression, and the chain of state-derived clocks. Only the code that walks the plan is Rust.
Proposal
Treat a derived clock domain as a compiled wait site in 3b-2, with the plan generated as SIR:
Combinationally derived (clk & en, ~clk): in the slot of the source edge, after the settle, compare the derived clock's expression with its baseline in state and, on an edge, run the derived domain's unit. This is the same code as 3b-2's event waits: static watched signals, compare after each settle, set a ready bit, dispatch.
State-derived (a register divider, a gate whose enable the commit raises): compare again after the commit and chain, bounded by the plan's depth, as the post-commit loop of 3b-2 does.
No new static analysis: the plan is the existing structural data (per the #1123 review policy, fast paths stay syntactic).
Gate
cargo bench -p celox --bench overhead, 10000 periods, median, two-state. On master cycle is what tick is after #1776:
design
tick (active edge only)
cycle (one period)
plain
2.05 ms
2.05 ms
gated clk & en
3.50 ms
5.07 ms
register divider
3.26 ms
3.68 ms
With compiled derived domains, gated and divided should cost about plain plus the derived domain's body. A Veryl native testbench's clk.next(n) on these designs must keep a batched path.
Related: #1776 (a tick is one period), and the interim fast-path relaxation for the inactive edge on branch feature/tick-inactive-edge-fast-path, which stays useful for designs the scheduler does not take.
Activity