Repository navigation
fix(js): return normally when bounded simulations stop - #1490
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 142d77198f
ℹ️ 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 (max > 0) { | ||
| this._state.dirty = false; | ||
| if (this.isStopped()) return; |
There was a problem hiding this comment.
Normalize maxSteps before treating a stop as newly encountered
When a caller resumes an already-stopped simulation with a fractional positive budget below 1, the NAPI boundary truncates max_steps to zero (crates/celox-napi/src/lib.rs:2048), so the bounded run returns false without executing a step and leaves the old stopped state set. Because the original JavaScript value still satisfies max > 0, this branch mistakes that old state for a newly encountered $stop and returns normally instead of reporting budget exhaustion. Validate or normalize maxSteps before both the native call and this test so the effective zero-step budget retains the documented timeout behavior.
Useful? React with 👍 / 👎.
| this._state.dirty = false; | ||
| if (this.isStopped()) return; |
There was a problem hiding this comment.
Preserve dirty inputs when resuming into another stop
When an input is written while the simulation is already suspended and the allowed step resumes directly into another $stop, the runtime prioritizes the suspended time slot and returns before processing the pending host write (crates/celox-runtime/src/simulation/time.rs:92-103). This new normal-return path nevertheless clears _state.dirty, so a subsequent output read skips its lazy evalComb() and can expose stale combinational outputs. Preserve the dirty state unless the bounded run actually consumed the host write.
Useful? React with 👍 / 👎.
Simulation.runUntil(endTime, { maxSteps }) treated the Rust bounded loop's
false result as a timeout even when a design executed $stop. Return normally
when an allowed step suspends the simulation, so callers can inspect
isStopped() and resume it. Normalize fractional, negative and NaN budgets
before the native call and the stop check so effective zero-step budgets
still time out, including while a previous stop is pending.
A resumed time slot can stop again or exhaust its budget before consuming
pending host writes. Preserve dirty inputs after these interrupted resumptions
so output reads still perform lazy combinational evaluation.
Add TypeScript regressions for stop and resumption, normalized budgets, and
pending input writes across repeated stops and budget exhaustion. Extend the
Rust SystemVerilog $stop regression to verify bounded-loop results with
actual stopped processes.
Validation:
- TypeScript Simulation unit tests (54 passed), package type checks, and Biome.
- NAPI Simulation, timing-addon, cascaded-clock-addon, and e2e tests (168 passed).
- Rust stop_suspends_the_simulation_until_it_continues regression.
- cargo fmt and Clippy for the SystemVerilog integration test.
- Reused the successful NAPI build and Rust checks from the prior revision;
native sources are unchanged by this review fix.
Fixes #1464
Change-Id: I3756bef676de6da4b8e9884f9025a72083dc21ae
142d771 to
85a9753
Compare
Revision history
|
Merge Queue Status
This pull request spent 42 minutes 24 seconds in the queue, including 36 minutes 45 seconds running CI. Required conditions to merge
|
Simulation.runUntil(endTime, { maxSteps }) treated the Rust bounded loop's
false result as a timeout even when a design executed $stop. Return normally
when an allowed step suspends the simulation, so callers can inspect
isStopped() and resume it. Normalize fractional, negative and NaN budgets
before the native call and the stop check so effective zero-step budgets
still time out, including while a previous stop is pending.
A resumed time slot can stop again or exhaust its budget before consuming
pending host writes. Preserve dirty inputs after these interrupted resumptions
so output reads still perform lazy combinational evaluation.
Add TypeScript regressions for stop and resumption, normalized budgets, and
pending input writes across repeated stops and budget exhaustion. Extend the
Rust SystemVerilog $stop regression to verify bounded-loop results with
actual stopped processes.
Validation:
native sources are unchanged by this review fix.
Fixes #1464