Skip to content

fix(sv)!: defer the actions of deferred assertions in processes - #1877

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d

Conversation

@tignear

@tignear tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

assert #0, assume #0, assert final and assume final in a process reported at once, like simple immediate assertions. Glitches that a deferred assertion exists to hide were therefore reported. IEEE 1800-2023 16.4 instead has the action wait in the process's deferred assertion report queue:

  • its arguments are evaluated when the assertion executes;
  • a flush point of the process discards what waits (16.4.2): a resume from an event control or a wait, but not a resume after a delay;
  • what is left matures in the Observed region (#0) or the Postponed region (final) of the time slot.

This is the second part of SVA stage 1 (#89).

Flush points as events.

  • The SV frontend gives a process that holds a deferred assertion, directly or in a subroutine it calls, a flush-point event site (DeferredSite::FlushPoint). A process kernel reports it whenever it wakes from an event control or a wait (ProcessKernelBuilder::flush_deferred_at, in wake_if). An edge-triggered process reports it at the start of each evaluation, which is a resume from its event control.
  • The site of a deferred action is DeferredSite::Action { queue, region }, where queue is the flush-point site of its process. Assembly offsets it like the other sites of the instance.
  • A deferred $fatal does not stop the evaluation; it ends the simulation when it matures.
  • The SV frontend also finds a deferred assertion in a subroutine that only the default of an omitted argument, or a timing control (wait, an event control or a delay), calls.

The queue on the host.

  • PendingRuntimeEvents, which the simulator's drain and RuntimeEventDrain share, holds back the events of action sites in issue order. A flush-point event discards those of its queue.
  • When the slot is over, mature queues what is left: the #0 actions, then the final ones, up to the first fatal one, after which the simulation ends. Events of the slot's active regions, such as $display output, come before them.
  • Nothing is needed for designs without deferred assertions: the site table is empty and Simulator::deferred_assertions is false.
  • Events lost to a full event buffer (Missed) may have held a deferred $fatal. In a design with a fatal deferred action they end the simulation when the slot matures, with missed N runtime events, which may have held a deferred $fatal.

The end of a time slot.

  • A step of the runtime ends before its slot when a process waits for zero time, and try_finish_timed_step is called at the end of every step. The new HostBoundary::try_end_time_slot is called only when no more work is due at that time; the simulator matures the queue there.
  • A design with deferred assertions runs the runtime's loop (CompiledSlots::None), which tells the two apart.
  • A Simulator call is a time slot, so the queue matures after each run of a domain (fire), after tick_events, and after edge and edges through derived domains (note_edge), which also serve tick of a clock with derived domains.

Analyzer.

  • The deferral of an immediate assertion is recorded in AssertionSite::deferral (previously always None).
  • A deferred action must be one display or severity task call (16.4). User subroutines would run in the Reactive region, which Celox does not model, so they are rejected.

Deferred assertions in always_comb, always_latch and always processes lowered as combinational logic still report at once. Module-level ones and deferred cover stay rejected. The next change handles combinational processes.

  • New crates/celox/tests/sv_deferred_assertions.rs on the interpreter, cranelift, native and wasm backends:

    • a resume from @(a or b) flushes the failure of the first execution, while the immediate assertion beside it reports;
    • the a3/a4 example of 16.4.2: a3 reports and a4 is flushed;
    • $display output, then #0 actions (fail and pass), then final ones in one slot;
    • an edge-triggered process: one edge reports, and a second edge in the slot flushes;
    • a deferred $fatal stops the run at the end of its slot and is drained as a fatal report;
    • a Simulator tick matures the action of an always_ff;
    • a timed Simulation built from a reloaded native image flushes the glitch and reports the lasting failure as the in-process build does (native_simulation_image::deferred_assertions_run_from_the_image);
    • edges and ticks of a clock with a derived domain mature each call's actions: 9 reports for 2 edges periods and 4 ticks. Without note_edge maturing none are drained;
    • a function called only from the default of an omitted argument holds a #0 assertion: its report follows the $display after the call. Without the default scan it comes first;
    • a deferred $fatal followed by 2,000 $displays in its slot still ends the run, with a missed error;
    • a final action after an #0 $fatal does not mature. Without the change it was drained;
    • a function called only by a wait condition holds an #0 assertion: its report follows the $display after the wait. Without the change it came first;
    • an action of two statements is rejected.
  • cargo nextest run with CI's features (celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus) on celox, celox-frontend-{core,sv,veryl}, celox-sv-analyzer, celox-runtime, celox-design, celox-slt, celox-test-suite, celox-vpi and celox-napi: 15,270 passed, after updating the two analyzer tests that gave deferred assertions assignment actions, which 16.4 does not allow (they now use a $info action, and check that the header's deferral makes an assignment action an error).

  • sv-tests conformance (conformance/sv-tests/run.py): unchanged from expected.tsv.

  • cargo clippy --workspace --all-targets with CI's features and -D warnings, clippy of celox without default features, cargo fmt --check.

  • celox_design::RuntimeEventSite has the new field deferred, of the new type DeferredSite. The native image container version is 36.

  • Deferred assertions in processes report when they mature, at the end of their time slot, and a flush point discards them.

@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 ⚠️ Failed 2026-10-25T06:03:03.984824Z
We couldn’t complete this review. Comment @codex review to try again.
1a5e079 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 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 fix(sv)!: defer the actions of deferred assertions in processes #1877 👈
2 feat(sv)!: defer assertions of combinational processes, module items and covers #1878
3 feat(sv): support $sampled in processes #1879
4 feat(sv): support $past and the value change functions in clocked processes #1880
5 fix(sv)!: give reports the time they are issued at #1881
6 feat(sv): sample static locals and combinational logic, and infer more clocks of $past #1882

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 713d3a65ed

ℹ️ 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".

Comment thread crates/celox/src/simulator.rs Resolved
Comment thread crates/celox/src/simulator.rs Resolved
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch from 713d3a6 to 4e94918 Compare October 24, 2026 11:06
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 branch from 693f32a to 3df1b35 Compare October 24, 2026 11:06
@tignear

tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 713d3a6 2026-10-24 11:03 UTC
2 content 713d3a6 → 4e94918 Review: a missed deferred $fatal ends the run, scan argument defaults for deferred assertions, mature on the derived edge paths; container version 35 2026-10-24 11:03 UTC
3 rebase 4e94918 → a81005a (rebase only) 2026-10-24 12:11 UTC
4 content a81005a → 2ab3a7f 2026-10-24 18:21 UTC
5 rebase 2ab3a7f → 78475a1 (rebase only) 2026-10-24 21:36 UTC
6 content 78475a1 → 6ea4a3b 2026-10-25 04:27 UTC
7 content 6ea4a3b → fce39bf 2026-10-25 05:14 UTC
8 content fce39bf → 1a5e079 2026-10-25 06:02 UTC

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e949181a0

ℹ️ 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".

@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 branch from 3df1b35 to 7b255b9 Compare October 24, 2026 12:12
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch 2 times, most recently from a81005a to 2ab3a7f Compare October 24, 2026 18:24
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 branch from 7b255b9 to 0eb27bd Compare October 24, 2026 18:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ab3a7f56c

ℹ️ 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".

Comment thread crates/celox/src/simulator.rs Resolved
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 branch from 0eb27bd to bac33ca Compare October 24, 2026 21:38
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch from 2ab3a7f to 78475a1 Compare October 24, 2026 21:38
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 branch from bac33ca to 305f5a5 Compare October 25, 2026 04:28
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch from 78475a1 to 6ea4a3b Compare October 25, 2026 04:28
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch from 6ea4a3b to fce39bf Compare October 25, 2026 05:15
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Base automatically changed from stack/tignear/feat/sva-stage1/fail-runs-reports-drain-runtime-events-typescript--4b6716e7 to master October 25, 2026 05:54
`assert #0`, `assume #0`, `assert final` and `assume final` in a process reported at once, like simple immediate assertions. Glitches that a deferred assertion exists to hide were therefore reported. IEEE 1800-2023 16.4 instead has the action wait in the process's deferred assertion report queue:
- its arguments are evaluated when the assertion executes;
- a flush point of the process discards what waits (16.4.2): a resume from an event control or a wait, but not a resume after a delay;
- what is left matures in the Observed region (`#0`) or the Postponed region (`final`) of the time slot.

This is the second part of SVA stage 1 (#89).

**Flush points as events.**
- The SV frontend gives a process that holds a deferred assertion, directly or in a subroutine it calls, a flush-point event site (`DeferredSite::FlushPoint`). A process kernel reports it whenever it wakes from an event control or a wait (`ProcessKernelBuilder::flush_deferred_at`, in `wake_if`). An edge-triggered process reports it at the start of each evaluation, which is a resume from its event control.
- The site of a deferred action is `DeferredSite::Action { queue, region }`, where `queue` is the flush-point site of its process. Assembly offsets it like the other sites of the instance.
- A deferred `$fatal` does not stop the evaluation; it ends the simulation when it matures.
- The SV frontend also finds a deferred assertion in a subroutine that only the default of an omitted argument, or a timing control (`wait`, an event control or a delay), calls.

**The queue on the host.**
- `PendingRuntimeEvents`, which the simulator's drain and `RuntimeEventDrain` share, holds back the events of action sites in issue order. A flush-point event discards those of its queue.
- When the slot is over, `mature` queues what is left: the `#0` actions, then the `final` ones, up to the first fatal one, after which the simulation ends. Events of the slot's active regions, such as `$display` output, come before them.
- Nothing is needed for designs without deferred assertions: the site table is empty and `Simulator::deferred_assertions` is false.
- Events lost to a full event buffer (`Missed`) may have held a deferred `$fatal`. In a design with a fatal deferred action they end the simulation when the slot matures, with `missed N runtime events, which may have held a deferred $fatal`.

**The end of a time slot.**
- A step of the runtime ends before its slot when a process waits for zero time, and `try_finish_timed_step` is called at the end of every step. The new `HostBoundary::try_end_time_slot` is called only when no more work is due at that time; the simulator matures the queue there.
- A design with deferred assertions runs the runtime's loop (`CompiledSlots::None`), which tells the two apart.
- A `Simulator` call is a time slot, so the queue matures after each run of a domain (`fire`), after `tick_events`, and after `edge` and `edges` through derived domains (`note_edge`), which also serve `tick` of a clock with derived domains.

**Analyzer.**
- The deferral of an immediate assertion is recorded in `AssertionSite::deferral` (previously always `None`).
- A deferred action must be one display or severity task call (16.4). User subroutines would run in the Reactive region, which Celox does not model, so they are rejected.

Deferred assertions in `always_comb`, `always_latch` and `always` processes lowered as combinational logic still report at once. Module-level ones and deferred cover stay rejected. The next change handles combinational processes.

- New `crates/celox/tests/sv_deferred_assertions.rs` on the interpreter, cranelift, native and wasm backends:
  - a resume from `@(a or b)` flushes the failure of the first execution, while the immediate assertion beside it reports;
  - the `a3`/`a4` example of 16.4.2: `a3` reports and `a4` is flushed;
  - `$display` output, then `#0` actions (fail and pass), then `final` ones in one slot;
  - an edge-triggered process: one edge reports, and a second edge in the slot flushes;
  - a deferred `$fatal` stops the run at the end of its slot and is drained as a fatal report;
  - a `Simulator` tick matures the action of an `always_ff`;
  - a timed `Simulation` built from a reloaded native image flushes the glitch and reports the lasting failure as the in-process build does (`native_simulation_image::deferred_assertions_run_from_the_image`);
  - `edges` and ticks of a clock with a derived domain mature each call's actions: 9 reports for 2 `edges` periods and 4 ticks. Without `note_edge` maturing none are drained;
  - a function called only from the default of an omitted argument holds a `#0` assertion: its report follows the `$display` after the call. Without the default scan it comes first;
  - a deferred `$fatal` followed by 2,000 `$display`s in its slot still ends the run, with a `missed` error;
  - a `final` action after an `#0` `$fatal` does not mature. Without the change it was drained;
  - a function called only by a `wait` condition holds an `#0` assertion: its report follows the `$display` after the wait. Without the change it came first;
  - an action of two statements is rejected.
- `cargo nextest run` with CI's features (`celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus`) on celox, celox-frontend-{core,sv,veryl}, celox-sv-analyzer, celox-runtime, celox-design, celox-slt, celox-test-suite, celox-vpi and celox-napi: 15,270 passed, after updating the two analyzer tests that gave deferred assertions assignment actions, which 16.4 does not allow (they now use a `$info` action, and check that the header's deferral makes an assignment action an error).
- sv-tests conformance (`conformance/sv-tests/run.py`): unchanged from `expected.tsv`.
- `cargo clippy --workspace --all-targets` with CI's features and `-D warnings`, clippy of `celox` without default features, `cargo fmt --check`.

- `celox_design::RuntimeEventSite` has the new field `deferred`, of the new type `DeferredSite`. The native image container version is 36.
- Deferred assertions in processes report when they mature, at the end of their time slot, and a flush point discards them.

Change-Id: I1062591d4b559e6f6fa13de6f7a435b7790c02e5
@tignear
tignear force-pushed the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch from fce39bf to 1a5e079 Compare October 25, 2026 06:02
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear

tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 36 minutes 54 seconds in the queue, including 34 minutes 54 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

@mergify mergify Bot added the queued Mergify queue entry label Oct 25, 2026
@mergify
mergify Bot merged commit feba1a5 into master Oct 25, 2026
23 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/sva-stage1/defer-actions-deferred-assertions-processes--1062591d branch October 25, 2026 07:13
@mergify mergify Bot removed the queued Mergify queue entry label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant