Repository navigation
feat(sim)!: show the regions of a time slot to a slot observer - #1934
Merged
Merged
Conversation
A host such as a VPI driver needs to see an edge before the flip-flop domains commit, and every settled slot. Simulation::observe_slots installs a SlotObserver: before_domains runs in every round once its processes and scheduled values have run and before its domains evaluate, end_of_slot once the slot has settled. Writes there are blocking host writes at the slot's time; the round settles them before the domains read them, and those at the end of a slot are settled at that time before the simulation advances. The compiled scheduler keeps every kernel it can. SchedulerSchema records, per kernel, the event signals it writes: the slots of the kernels and host clocks that may change an observed event signal run in the reference loop, the others stay compiled, one slot per run while an observer is installed. A differential simulation stops checking, as its shadow does not see the observer's writes. BREAKING CHANGE: native image containers are version 35; images of earlier versions no longer load. SchedulerSchema has a new public field, kernel_events. Part of #1730 Change-Id: I4ffaef0e5b3b716ec5185ff0250aeb33114fb496
Change-Id: I5737eb89d7389cb84585ee295af57fac35d9ccc4
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 24, 2026
Contributor
|
Queued — the merge queue status continues in this comment ↓. |
Contributor
Merge Queue Status
This pull request spent 1 hour 43 minutes 26 seconds in the queue, including 33 minutes 9 seconds running CI. Required conditions to merge
|
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1730, PR 2 of 3. The VPI host (PR 3) needs to see, inside a time slot of a timed
Simulation:RisingEdge(clk)reads the values from before the nonblocking updates;This PR adds that observation point and keeps every compiled kernel it can.
Change
Simulation::observe_slots(observer, signals)/stop_observing_slots()install aSlotObserver<B>:before_domains(io, time)runs in every round, once its processes and scheduled values have run and before its domains evaluate. The round's edges are in state and nothing has committed. Writes throughSlotIoare blocking host writes attime. The round logs them for the waits, settles comb and only then evaluates the domains.end_of_slot(io, time)runs when the slot has settled. Writes there are updates oftime, which the simulation settles at that time before it advances.HostBoundarygainsbefore_domainsandtake_slot_writes. Both default to doing nothing, so other executors are unchanged.SchedulerSchema::kernel_eventsrecords, per process kernel, the bits ofeventsit writes, computed fromPlan'sKernel::writes.e,compiled_limittreats the wakeups of kernels that writee, and the edges of host clocks that drivee, as reference-loop work. A waiting kernel that writesekeeps compiled runs from starting while it waits, because the slot it resumes in is not known in advance.CompiledSlots::Onepath that VCD and the heap use), soend_of_slotsees each slot.end_of_slotsays so.Simulation; herea_settled_slot_shows_every_change_and_its_writes_stay_in_the_slotshows it.sched_benchgets an optional fifth argument,observe=<signal>: an observer that counts the signal's changes at the end of every slot, as a value-change callback does.BREAKING CHANGE
SchedulerSchemais serialized in images and gainskernel_events. Images written by earlier versions are rejected on load and must be rebuilt.celox_design::SchedulerSchema: new public fieldkernel_events: Vec<Vec<usize>>. Struct literals of it must add the field.Perf
callgrind,
sched_bench. Per cycle = (Ir at 200,000 − Ir at 20,000) / 180,000, medians of five runs each,taskset -c 3. Base is c430061 (master).outclkalways #5clock + stimulus kerneladd_clockout(a data signal): about 7.6× in b1 and 9.9× in ac, from one compiled run per slot instead of one run for the wholerun_until. Per slot in ac: the compiled slot code is about 540 Ir; the hand-off is about 1,050 Ir inrun_compileditself, 500 Ir in 7 slot writes and 230 Ir incompiled_limit;try_finish_timed_stepis about 500 Ir, including about 340 Ir in the observer. This is the same hand-off cost VCD recording already pays. A cheaper hand-off for one-slot runs would help both and is a possible follow-up.clk(an event signal): every slot of these designs has an edge of the observed clock, so every slot runs in the reference loop, as it must for the callback to see the edge before the domains commit. Under cocotb, each such slot also costs a Python callback, which is much more expensive.Tests
New
crates/celox/tests/slot_observer.rs:always #5clock are seen before theiralways_ffupdate (q = 0, 1, 2, 3 at 5, 15, 25, 35);always #7kernel stay compiled (0 < compiled_slots < unobserved), with identical results;end_of_slotsees every change of a compiled clock's register, and a flag written there wakes awaitat the same time;Validation
cargo nextest run -p celox -p celox-runtime -p celox-vpi --features celox/systemverilog,celox-test-suite/runtime-cases --lib --tests(excluding the SV vtest binary): 9758 passed.node scripts/run-vtest.mjs --test systemverilog: 4542 passed.CELOX_SCHEDULER=differentialontiming::: 661 passed.cargo clippy -p celox-runtime -p celox -p celox-vpi -p celox-napi -p celox-design -p celox-frontend-core --all-targets -- -D warningsandcargo fmt --check: clean.