Skip to content

fix(sv): lower always @(list) like always @* when it lists every read - #1722

Merged
mergify[bot] merged 4 commits into
masterfrom
feature/fix/sv-level-sensitive-lists
Oct 22, 2026
Merged

mergify[bot] merged 4 commits into
masterfrom
feature/fix/sv-level-sensitive-lists

Conversation

@tignear

@tignear tignear commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1713.

Since #1475, always @(a or b) y = a + b; is lowered as a process, so an untimed Simulator builds it but never runs it (#1712). This lowers the common case the same way always @* is lowered today.

Rule

A plain always is lowered like always @* when:

  • its event control lists plain variables with no edges, in any order, separated by or or ,;
  • the listed variables are exactly the set @* computes for the same statement (IEEE 1800-2023 9.4.2.2). The match reuses implicit_reads, the frontend's existing @* read-set computation;
  • the statement has no timing control and no nonblocking assignment, directly or in a subroutine it calls (the always @* path rejects nonblocking assignments);
  • the statement has no break, continue or return outside its own loops.

Anything else stays a process: a missing read, an extra signal, a select item, an edge, or timing in the body. Event lists keep their time-0 behaviour: like always @*, they wait for a change of a listed variable.

Combinational loops

As always @*, event-list blocks can close a combinational loop that converges when they run as processes (timing::finite_active_feedback_preserves_convergence). When the scheduler rejects a loop:

  1. it now reports the loop's members as structured (ModuleId, variable range) pairs, through schedule_symbolic_rtl_reporting_loops. schedule_symbolic_rtl is unchanged;
  2. the SV frontend demotes only the converted event-list blocks that drive a loop member, per specialized module, and schedules again;
  3. this repeats until the loop is gone, or until no converted block takes part in it. In that case the scheduler's error is reported unchanged.

A demoted block runs as a process: correctly in Simulation, and rejected in Simulator once #1712 lands.

Cost: only designs that fail to schedule pay for the retry. Each round lowers and schedules the SV design again, so a design whose loop involves converted blocks compiles once per demotion round (two compiles in every test here). There is no runtime cost.

Mixed Veryl/SystemVerilog hierarchies (prepare_external_hierarchy*) schedule through the Veryl frontend, which has no retry yet. There the event lists stay processes, as before (follow-up).

Docs

docs/guide/systemverilog{,-reference}.md and their docs/ja counterparts describe which event lists simulate like always @*. pnpm docs:build passes.

Validation

  • New suite cases:
    • always_comb::explicit_list_of_every_read_settles_like_a_wildcard: untimed Simulator, always @(a or b) and always @(b, a), gives 8.
    • Timed Simulation cases:
      • a list of every read, which waits for a change;
      • a list missing a read (always @(a) y = a + b;, which does not follow b);
      • a list with an extra signal (wakes on it);
      • a nonblocking body;
      • a loop through always_comb;
      • two lists where only one is in a loop (through an assign).
    • A frontend unit test counts process kernels: only the lists in a loop are demoted, and the one outside stays lowered.
  • Icarus 13.0: every new case passes.
  • Verilator 5.052: every new case passes except two, because it runs edgeless event-list always blocks at time 0 (against IEEE 1800-2023 6.8 and 9.4.2). These are recorded as the reviewed exclusion sv_verilator_event_list_timezero, with an adapter-free repro, next to the existing always @* time-zero exclusion.
  • SIR digest: the post-optimized SIR of all 448 untimed SV suite designs is byte-identical to master, except the new case that uses such a list.
  • sv-tests conformance: results match expected.tsv, with no changes.
  • Tests:
    • cargo test -p celox --features systemverilog --test systemverilog: 3566 passed;
    • the other celox SV test targets;
    • celox-frontend-sv, celox-sv-analyzer, celox-frontend-core and celox-test-suite;
    • clippy with CI's features.

@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-22T02:48:56.049387Z
We couldn’t complete this review. Comment @codex review to try again.
8df8717 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.

@tignear
tignear force-pushed the feature/fix/sv-level-sensitive-lists branch from 8df8717 to e01f90d Compare October 22, 2026 03:09
An always whose edgeless event list names exactly the variables @* would
compute for its statement (IEEE 1800-2023 9.4.2.2), and whose statement
neither suspends nor makes a nonblocking assignment, is lowered like
always @*, so an untimed Simulator runs it.

When such a block closes a combinational loop, the scheduler reports the
loop's members, and only the blocks that drive them run as processes.

Change-Id: I72eb16b617333506ba2aaaf58a961b0cef5c0903
…processes

Verilator runs edgeless event-list always blocks at time zero; the two
affected cases are excluded with an adapter-free reproduction.

Change-Id: I72c16f4b9aa69f06a7ea37bfa5635b972ffbb703
Change-Id: I7fb7b8ea84d8192a21b47b54d33b91574d8d8d7f
Change-Id: I7add15ad54316af2cffff68d1b3cb7fafd18d0be
@tignear
tignear force-pushed the feature/fix/sv-level-sensitive-lists branch from 2104287 to 32fa9c4 Compare October 22, 2026 04:34
@mergify

mergify Bot commented Oct 22, 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 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 06:46 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1722 on master (4babe90) #1743
  • ✅ Merged — 2026-10-22 09:58 UTC · at 13f9b9a157ea21af1c2800f46ed12935329cd66c · merge

This pull request spent 3 hours 11 minutes 31 seconds in the queue, including 1 hour 56 minutes 41 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.

SV: lower always @(list) like always @* when the list covers its reads

1 participant