Skip to content

feat(sv): run nonblocking assignments in processes - #1501

Merged
mergify[bot] merged 2 commits into
masterfrom
feature/sv-process-nba
Oct 18, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
feature/sv-process-nba

Conversation

@tignear

@tignear tignear commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Part of #1123, step 4, PR 3 of 6. Stacked on #1480; I'll rebase it onto master once #1480 merges.

What changes

Lowering. A nonblocking assignment in an SV initial or always process now runs, where it used to be rejected ("nonblocking assignment in an initial block that runs as a process"). The kernel evaluates the right-hand side once, into a hidden value. Each target part then becomes an NbaSite, and the runtime of #1361 queues its update for the NBA region (IEEE 1800-2023 10.4.2).

Targets covered:

  • whole variables;
  • constant bit and part selects;
  • concatenations of those.

Still rejected, each under its own name (#1492):

  • a run-time position, q[i] <= v: the site can't publish only in-range bits;
  • unpacked array elements;
  • reversed part selects.

Pending fast path deferred. Every update goes through the ordered queue. NbaSite::pending requires that the target has no other writer, including writers outside the module through hierarchical references or package bindings, and that can't be decided while lowering one module. It needs a design-level check in assembly (#1492).

Tests

  • New timing::nonblocking_assignments_in_processes_update_in_the_nba_region. It checks that:

    • an update stays pending through #0;
    • the last update of a time slot wins;
    • part-select and concatenation targets update their bits;
    • a register sampling a value that a stimulus process drives with <= at the same edge sees the old value.

    It passes on Icarus 13.0 and Verilator 5.052 and runs on all five backends.

  • The test of the former rejection became nonblocking_assignments_in_initial_processes_update_after_the_display: the $display in the same slot prints the old value.

  • New review_regressions::rejects_process_nonblocking_assignments_without_a_constant_target covers the names of the remaining rejections.

  • Scoped runs, all passing:

    • cargo test -p celox --features systemverilog: lib with golden traces unchanged, the SV suite (2812), and the checkpoint, processes, state_file, simulation_step and flip_flop suites;
    • cargo test -p celox-frontend-sv -p celox-sv-analyzer -p celox-frontend-core -p celox-test-suite;
    • the sv-tests conformance example: unchanged;
    • clippy -D warnings and fmt --check.

Perf

SIR. For all 376 untimed SV suite designs, the SIR and runtime schema are byte-identical to #1480.

Callgrind. Same SV gate and method as before: 200,000 minus 20,000 cycles, five runs.

#1480 this PR
(a) pure RTL 1140723411, 1141291977, 1129152915, 1139643259, 1010183976 1140628821, 1020392037, 1007342861, 1007962687, 1022322622
(b1) + @(posedge clk) stimulus kernel, blocking median 1,380,951,352 median 1,382,690,689
(b5) the same stimulus with <= (new) — median 1,938,980,578

A nonblocking assignment in an `initial` or `always` process evaluates
its right-hand side once and queues one update per target part for the
NBA region (IEEE 1800-2023 10.4.2), through the kernel builder's
nonblocking sites. Targets are whole variables, constant bit and part
selects, and concatenations of those; assignments with a run-time
position, to unpacked array elements or to reversed part selects are
rejected under their own names (#1492). Every update goes through the
runtime's ordered queue.

Change-Id: Id854e4d004740d36f65ea395b3da6948a0bcaad9
Add a timing case for nonblocking updates in processes, checked against
Icarus and Verilator: an update stays pending through `#0`, the last one
of a time slot wins, part selects and concatenations update their bits,
and a register sampling a value a stimulus process drives at the same
edge sees the old value. Replace the test of the former rejection with
one of the update order, and test the rejection of run-time targets.

Change-Id: I790c8b6a5e2004e403468d6f5007eb140d83fc2e
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 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 ✅ Completed 2026-10-18T11:01:05.556412Z 6bf1fbf 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.

Base automatically changed from feature/ff-active-nba-commit to master October 18, 2026 10:59

@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: 6bf1fbfcea

ℹ️ 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 on lines +3220 to +3221
for part in parts {
targets.push(self.nba_target(part)?);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate unrolled loop indices before classifying NBA targets

When a timed process contains a constant-bound loop such as for (int i = 0; i < 4; i++) q[i] <= 1'b1;, exec_loop unrolls the loop and records each i value in self.overlay, but this path passes the original lvalue directly to nba_target. Consequently, eval_const_expr_with_types cannot resolve i and rejects the assignment as having a run-time position, even though each unrolled target is constant. Apply propagate_lvalue before resolving the NBA target, as the blocking assignment path already does.

Useful? React with 👍 / 👎.

Comment on lines +3309 to +3313
let (Some(msb), Some(lsb)) = (
packed_index_offset(variable, msb),
packed_index_offset(variable, lsb),
) else {
return Err(unsupported("nonblocking assignment outside its target"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat out-of-range constant NBA targets as no-ops

For a timed process containing a constant out-of-range bit select such as logic [7:0] q; initial #1 q[8] <= side_effect();, the select is a constant target but packed_index_offset returns None and this path rejects the entire design. SystemVerilog writes through an out-of-range bit select have no effect, while the RHS must still be evaluated; the existing blocking process path likewise returns successfully without storing. Preserve RHS evaluation and omit the corresponding update instead of reporting an unsupported target.

Useful? React with 👍 / 👎.

@tignear

tignear commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 48 minutes 16 seconds in the queue, including 46 minutes 35 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 18, 2026
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 18, 2026
@mergify
mergify Bot merged commit b137b8b into master Oct 18, 2026
30 checks passed
@mergify
mergify Bot deleted the feature/sv-process-nba branch October 18, 2026 12:31
@mergify mergify Bot removed the queued Mergify queue entry label Oct 18, 2026
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