Skip to content

feat(sv): lower expression events and @* in processes - #1681

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/sv-expression-events
Oct 22, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/sv-expression-events

Conversation

@tignear

@tignear tignear commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1123, step 4, PR 4: expression events in SV processes.

What is lowered

  • Event items other than a whole module variable: bit and part selects, variable-index selects, any expression, pure function calls.
    • Each item becomes a hidden continuous assignment $event[k] = expr.
    • A real or shortreal expression gives a 64- or 32-bit 2-state $event[k] holding the IEEE payload bits, so a fractional change is still an event.
    • The wait term is ($event[k], Rises | Falls | Changes); edge still gives a Rises term and a Falls term.
    • Each update of the value is an occurrence. An edge is judged on the expression's LSB (IEEE 1800-2023 9.4.2, Table 9-2).
    • Selects are not widened to the whole variable, and nothing is re-checked in wake_if.
  • Process-local and automatic operands (for example an automatic task formal) are copied into $event[k].arg[n] before suspend_wait. The assignment reads those copies and the module-scope sources.
  • Sampling (option A, coordinator decision): just before suspending, the process stores the expression's value into $event[k], so the event control samples it when it begins.
    • The kernel only stores and never compares. Detection stays the assignment plus the value baseline.
    • The store does not make $event[k] a counted signal. The variables are hidden, so assembly declares no counters for them; a test checks this.
  • @* / @(*) in a process waits on the variables its statement reads (9.4.2.2): right-hand sides, conditions, case items, arguments and left-hand-side indices.
    • Assignment targets and identifiers that appear only in timing controls (delay, wait, event) are excluded.
    • Constant-folded branches still count.
  • Hiding: $event[...] and its copies are left out of named_signals() and the VCD, like the $initial[...] process slots, and they are kept in state files.
  • Still rejected: iff (feat(sv): support iff-qualified event controls in processes #1444), impure calls (impure call f in an event expression), and event expressions reading a static task argument. The last one is the same rule as wait.
  • No static proofs; no new fast paths.

Tests

  • Exclusions: all 14 timing.rs exclusions are removed; each case passes on all five backends.

  • New timing.vtest cases, each first checked with verify-sv-icarus / verify-sv-verilator --fresh:

    Case Covers
    expression_events_see_pulses_within_a_time_slot a pulse of (a ^ b) within one slot
    real_expression_events_see_fractional_changes @(r * 2.0) with changes below 1.0
    bit_select_edges_follow_the_selected_bit @(posedge v[3]) while v[0] stays 0
    part_select_events_see_pulses_of_the_selected_bits a part select pulsing within a slot
    variable_index_events_follow_the_index @(q[i]), including an index change
    pure_function_events_change_with_the_result a pure function in an event
    event_expressions_read_automatic_task_locals the t(0)/t(1) repro
    event_controls_sample_the_expression_when_they_begin the a = 1; @(a ^ b); repro
    implicit_event_controls_in_processes_wait_on_their_reads @* in initial forever and in an always with a delay
  • External results:

    • Icarus 13.0 and Verilator 5.052 both pass the t(0)/t(1) task case.
    • Icarus differs on a = 1; @(a ^ b);: it wakes the process. The case asserts the Verilator and spec behaviour, and is excluded for Icarus as sv_icarus_expression_event_sample, with the pre-exclusion result in verification/repros/.
    • Verilator rejects @* in initial forever ("Unsupported: … in this context"). A standalone always @* with a delay in its body does not terminate in Verilator. That case is excluded for Verilator as sv_verilator_implicit_event_in_process.
    • Icarus reports an event of a new expression at time 0, so the affected waits begin after time 0.
    • verification/sv/{icarus,verilator}/timing.json are refreshed from full fresh timing:: runs. The diff only adds cases, including several that had been missing from the retained reports.
  • Rust tests:

    • a hidden-state test: VCD and named_signals leave the variables out, the state file keeps $event[0] and $event[0].arg[0] as State, and there are no counters;
    • a rejection test: impure function, $time, static task argument;
    • an analyzer IR test for the @* list.
  • Extra cross-check: a probe of @(mem[i]), @(posedge v[3] or negedge (a & b)), @(edge (a ^ b)), @(v[k]) in a for loop, @* reading mem[i] and @(v[i +: 2]) gave the same counts as Icarus at every step, at O0 and O1.

  • Scoped runs, all passing after rebasing onto 3078a32:

    • --test systemverilog: 3394 passed;
    • golden call traces (executor_call_traces*) unchanged;
    • -p celox-sv-analyzer -p celox-frontend-sv -p celox-test-suite;
    • the SV integration test files (state files, checkpoints, VCD, host requests, …);
    • clippy -D warnings and fmt --check.
  • sv-tests conformance example: verdicts are identical to expected.tsv, both before and after the rebase. No fail→pass, so the file is unchanged. The 9.4.2 cases that still fail are rejected for always_ff edge forms and iff.

Perf

(a) Pure RTL.

  • SIR: for all 412 untimed SV suite designs, a digest of the optimized SIR plus the runtime program is byte-identical between master 8b0f2b1 and this branch on that base. Both sides' digests are stable across runs.

  • Callgrind on a local SV gate (not committed): 64 lanes of always_ff accumulators, ticked by the host.

    • Method: whole program at 200,000 cycles minus at 20,000 cycles, five runs, median.
    • Both binaries are built from 8b0f2b1.
    runs median
    master 165788333, 165780017, 165788286, 165780022, 165780027 165,780,027
    this PR 165780036, 165797333, 165797333, 165762739, 165780036 165,780,036

    Equal.

(b) Design with an expression event, reported with no target. It is the same RTL with its own always #5 clock and initial forever @(posedge (clk & en)) hits++. Same method: 1877220058, 1877220058, 1877217692, 1877220058, 1877217692, median 1,877,220,058 for 180,000 cycles.

@chatgpt-codex-connector

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-21T03:51:08.982796Z
We couldn’t complete this review. Comment @codex review to try again.
f7bca37 PR opened
ℹ️ 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.

@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.

@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 21, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 17 minutes 9 seconds in the queue, including 8 minutes 53 seconds running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • Lint & Format

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for
  • check-success = Queue validation
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
    • check-success = @github-actions/Lint & Format
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
    • check-success = @github-actions/NAPI Build (Windows)
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
    • check-success = @github-actions/Rust Test & NAPI Build
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
    • check-success = @github-actions/JS Test (Ubuntu)
  • any of: [🛡 GitHub repository ruleset rule master]
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
    • check-success = @github-actions/JS Test (Windows)
All conditions
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
    • check-success = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
    • check-success = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
    • check-success = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
    • check-success = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
    • check-success = @github-actions/JS Test (Windows)
  • check-success = Conventional Commit title
  • 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

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

@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 21, 2026
@tignear tignear removed the merge-ready Request merging through Mergify after required checks label Oct 21, 2026
Part of #1123, step 4 PR 4. An event item other than a whole module
variable (selects, variable-index selects, any expression, pure function
calls) becomes a hidden continuous assignment `$event[k] = expr`, and the
wait term watches `$event[k]` (Rises, Falls or Changes). Each update of
its value is an occurrence; an edge is one of the expression's LSB
(IEEE 1800-2023 9.4.2, Table 9-2).

Process-local and automatic operands are copied into `$event[k].arg[n]`
before the process suspends, and the process stores the expression's
value into `$event[k]`, so the event control samples it when it begins.
The process only stores; detection stays the assignment plus the value
baseline, and the store does not make `$event[k]` a counted signal.
These variables are hidden from the signal listing and the waveform like
the process slots, and persist in state files.

`@*` in a process waits on the variables its statement reads (9.4.2.2).
`iff`, impure calls and static task arguments stay rejected.

Change-Id: Ifaff84d2abec60db0541d6ba8455b8815726c52a
@tignear
tignear force-pushed the feature/sv-expression-events branch from f7bca37 to dafc7c9 Compare October 21, 2026 12:31
@mergify mergify Bot removed the dequeued Mergify stopped this queue entry; investigate before retrying label Oct 21, 2026
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 22, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 22, 2026
@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-22 00:15 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1681 on master (144bbcc) #1705
  • ✅ Merged — 2026-10-22 01:41 UTC · at b811bbc32d3e2bee35bfc2424cf37f12d5c561d8 · merge

This pull request spent 1 hour 26 minutes 45 seconds in the queue, including 1 hour 24 minutes 33 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant