Repository navigation
feat(sv)!: execute final procedures at simulation termination - #2088
Conversation
|
This pull request is part of a Mergify stack:
|
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
150baf1 to
1f0b1aa
Compare
Revision history
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f0b1aa16d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if matches!( | ||
| self.simulator.mature_deferred_assertions(), | ||
| Err(RuntimeErrorCode::Fatal { .. }) | ||
| ) { | ||
| let _ = self.state.finalize_terminal(&mut self.simulator); |
There was a problem hiding this comment.
Finalize immediate fatal reports raised while draining events
When a host modifies an input and then calls drain_runtime_events(), its lazy combinational settle can execute an immediate $fatal. This path only finalizes fatal errors from mature_deferred_assertions(); the immediate fatal is swallowed by Simulator::eval_comb_for_runtime_event_drain() and returned as a report without terminating the simulation. For example, always_comb if (fail) $fatal(1); final calls++; can report the fatal while leaving is_finished() false and calls unchanged. Handle termination raised by the lazy settle as well, including when the design has no deferred assertions.
Useful? React with 👍 / 👎.
| self.host_pending = false; | ||
| self.finalizing = Some(0); | ||
| } | ||
| let result = self.run_final_procedures(executor); |
There was a problem hiding this comment.
Capture saved state after final procedures have executed
When settling dirty combinational logic during Simulation::save_state() executes $finish, the existing caller captures the file through self.simulator.save_state() before calling sync_finish_checked(). Now that finalization executes kernels, final procedures can change variables after that capture, while the subsequently exported schedule records finished = true. For example, a conditional combinational $finish followed by final result = 42; saves the old result with a terminal schedule; restoring it cannot run the skipped final updates. Settle and synchronize termination before capturing state, and recheck suspension if a final executes $stop.
Useful? React with 👍 / 👎.
|
Queued — the merge queue status continues in this comment ↓. |
SystemVerilog final procedures were rejected, so testbenches could not inspect their last state or report results at termination. Preserve them as terminal process kernels and run them once on $finish, $fatal, or explicit Simulation::finish(). The batch CLI and sv-tests driver finish on quiescence; bounded host runs remain resumable. Program finals also run after implicit termination. Keep final execution sequential and at zero simulation time. Resume $stop inside final at its cursor, stop immediately at $finish inside final, preserve the initiating fatal error, and prevent queued HDL events or deferred assertions from executing after termination. Validate function-statement restrictions, including omitted argument defaults. Route fatal errors from explicit waveform dumps and end-of-run waveform evaluation through the same terminal phase. Finalize immediate fatal errors raised by lazy runtime-event draining before collecting reports. Settle and execute final procedures before capturing saved state, and reject saving if final execution stops. Keep differential scheduling synchronized on these host-triggered termination paths. Document the lifecycle and restrictions. Validation: - 18 final API tests cover two/four-state Interpreter, Cranelift, WASM, Native and Tiered execution, differential scheduling, checkpoints and native-image roundtrip. - CI follow-up: default-feature library 150, enabled-feature library 229, VCD 36, reference-adapter 7, the unsupported-construct regression and JS boundary 9 tests pass. Formatting and Clippy pass. Fatal errors terminate execution while preserving the original diagnostic and waveform; tests no longer require recovery from $fatal. - P2 regression coverage: all four added tests fail before the fix and pass after it. Related library, checkpoint, observer, runtime API, state-file, deferred-assertion and VCD tests pass (1,281 tests; 34 existing ignores). Rebuilt the debug NAPI addon; 28 JS checkpoint/runtime-event/timing tests, formatting and Clippy pass. - Direct portable fixtures: Icarus 13.0 passes all three; Verilator 5.052 passes state/hierarchy but continues after $finish inside final, contrary to 9.2.3. Keep immediate-termination expectations. These fixtures use owning-crate API tests because the shared timed emitter has its own final checker with unspecified relative ordering. - Focused sv-tests rerun: 70 additional passing cases per mode out of 108 previously blocked by final; update exactly 140 measured expectations. Full release-driver conformance remains in CI as requested. BREAKING CHANGE: ProcessSlots and ProcessRefs use ProcessKind instead of is_initializer; fatal errors have a distinct Fatal variant; SimulationState::finish is fallible; native image format advances to version 39. Change-Id: I75200be6ce640d73a84562a25ff48cdae2237106
1f0b1aa to
7c6f1e5
Compare
Merge Queue Status
This pull request spent 38 minutes in the queue, including 33 minutes 19 seconds running CI. Required conditions to merge
|
SystemVerilog final procedures were rejected, so testbenches could not inspect their last state or report results at termination. Preserve them as terminal process kernels and run them once on $finish, $fatal, or explicit Simulation::finish(). The batch CLI and sv-tests driver finish on quiescence; bounded host runs remain resumable. Program finals also run after implicit termination.
Keep final execution sequential and at zero simulation time. Resume $stop inside final at its cursor, stop immediately at $finish inside final, preserve the initiating fatal error, and prevent queued HDL events or deferred assertions from executing after termination. Validate function-statement restrictions, including omitted argument defaults. Route fatal errors from explicit waveform dumps and end-of-run waveform evaluation through the same terminal phase. Finalize immediate fatal errors raised by lazy runtime-event draining before collecting reports. Settle and execute final procedures before capturing saved state, and reject saving if final execution stops. Keep differential scheduling synchronized on these host-triggered termination paths. Document the lifecycle and restrictions.
Validation:
BREAKING CHANGE: ProcessSlots and ProcessRefs use ProcessKind instead of is_initializer; fatal errors have a distinct Fatal variant; SimulationState::finish is fallible; native image format advances to version 39.