Skip to content

feat(sv): run nonblocking assignments in processes to array elements and run-time positions - #1773

Merged
mergify[bot] merged 2 commits into
masterfrom
fix/sv-process-nba-forms
Oct 23, 2026
Merged

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

Conversation

@tignear

@tignear tignear commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Part of #1123. Fixes #1709.

A nonblocking assignment in a process can now write any target a blocking assignment can write. Before this change, these forms were rejected:

Form Before Now
m[1] <= v, m[i] <= v, grid[i][j] <= v, m[i][7:4] <= v on unpacked arrays "nonblocking assignment to an unpacked array in a process" element update in the NBA region
q[i] <= 1, q[i +: 3] <= v, up[i -: 2] <= v "nonblocking assignment with a run-time position in a process" update at the position evaluated when the assignment executes
q[8] <= 1 on logic [7:0] q, q[9:6] <= v "nonblocking assignment outside its target" no effect, or only the bits inside the target (bits 7:6)
m[1:0] <= w on logic [7:0] m [4] (a slice running against the array's range) rejected elements in reverse order, as the blocking form does

IEEE 1800-2023 rules applied:

  • 10.4.2: the position is evaluated when the assignment executes. Later changes to the index don't move the update.
  • 11.5.1, 7.4.6: bits outside the target are not written. A position with an X or Z bit, or an element index out of range, writes nothing. A run-time part-select inside one array element stays within that element.

Design

  • A run-time site has a new NbaPosition (celox-design). It holds two staging objects: a bit offset and the number of bits written.
  • When the assignment executes, the frontend computes the clipped range (offset, width, and the low bits to drop) and the unknown-position check. It reuses the blocking-write helpers (dynamic_array_element_lvalue, dynamic_packed_write).
  • The runtime adds the offset when it queues or publishes the update, and skips a zero-width update.
  • These sites go through the same nonblocking_switched path as constant sites. Assembly's existing rule (perf(sv)!: stage nonblocking updates of a target with one writer #1684) chooses between staged and queued. For the queued path, NbaSwitch::queued_position keeps the position the kernel computed, as queued already did for the value. The staged path stores the position after flushing any update still pending, so a site reached several times in one time slot keeps each update's own position.
  • Constant positions don't use the new objects: their site is the constant range clipped to the target.

Perf

  • SIR: the optimized SIR (TraceOptions::post_optimized_sir, Debug text hashed) is byte-identical between base 59f9f80 and this branch for the 611 SV suite cases that don't use these forms. The only differences are the 4 new cases.
    • Since fix(sim)!: reject designs with processes in untimed Simulator builds #1720, Simulator no longer builds designs with processes, so this check now reaches the timed cases only as build errors on both sides.
    • Before the rebase, the same comparison over the timed cases too (587 identical) also found differences only in the 4 new cases. The rebase doesn't change this PR's diff.
  • (b5) (sched_bench b5, stim <= stim + 3, a staged site): callgrind, (Ir at 200,000 − Ir at 20,000) / 180,000, median of five, both binaries built from 59f9f80. Base 11139.0, this branch 11126.0 Ir/cycle.
    • The first version measured +60 Ir/cycle: the larger site struct was copied once per update.
    • Fixed: the runtime now borrows the site and reads only the fields it needs, and it publishes queued updates by reference rather than moving them out of the queue.

Tests

  • New vtests:
    • process_nonblocking_assignments_to_array_elements
    • process_nonblocking_assignments_at_run_time_positions
    • process_nonblocking_assignments_outside_their_target
    • process_nonblocking_assignments_at_unknown_positions (four-state)
  • Icarus passes all four.
  • Verilator 5.052 passes the array-element case and can't check the four-state one. It disagrees with the standard on the other two, which are now excluded through limitations.json (sv_verilator_process_nba_positions). The adapter-free reproduction is verification/repros/process_nba_positions.sv, with the retained observation alongside it. The disagreements:
    • it keeps only the last of overlapping run-time part-select updates issued by an inner loop;
    • it writes q[8] into bit 0.
  • Retained reports: both Icarus and Verilator timing.json were refreshed from fresh runs, and the diff only adds lines. Besides these cases, they now include the timing cases master added since the last refresh.
  • Rust tests:
    • run_time_nonblocking_positions_cover_staged_and_queued_sites checks that the staged and queued paths are both used.
    • nonblocking_assignments_to_reversed_array_slices_reverse_the_elements covers the slice, which neither Icarus nor Verilator compiles.
  • Removed: the three SV: nonblocking assignments in processes to arrays, run-time positions, and out-of-range targets #1709 entries in unimplemented_timing_features_are_rejected and rejects_process_nonblocking_assignments_without_a_constant_target.
  • sv-tests: no change against expected.tsv.
  • Docs: EN and JA, assignment row and restriction list.

Not in this PR

On master, a blocking or always_ff write to a constant part-select that is partly out of range writes nothing. For example, q[9:6] = 4'b1111 on logic [7:0] q leaves bits 7:6 unchanged, but 11.5.1 requires those two bits to be written. The nonblocking process path in this PR follows the standard. The other paths are left to a follow-up.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-23T08:11:19.068237Z 605514f 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.

@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 23:26 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue — 2026-10-22 23:30 UTC · at dc7df441097660f1492416438a32a0b54eabc04b

This pull request spent 3 minutes 17 seconds in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

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 22, 2026
@tignear
tignear force-pushed the fix/sv-process-nba-forms branch from dc7df44 to 928e44d Compare October 23, 2026 00:28
@tignear tignear removed merge-ready Request merging through Mergify after required checks dequeued Mergify stopped this queue entry; investigate before retrying labels Oct 23, 2026
@tignear
tignear force-pushed the fix/sv-process-nba-forms branch from 928e44d to b2da215 Compare October 23, 2026 07:47
@tignear tignear closed this Oct 23, 2026
@tignear tignear reopened this Oct 23, 2026
…and run-time positions

A nonblocking assignment in a process can now target an unpacked array
element, a reversed array slice, and a bit or part select at a run-time
position. The position is evaluated when the assignment executes; the
update goes through the same staged or queued NBA path as a constant one.
A run-time site stages a bit offset and the number of bits written, so
bits outside the target, or in the array element a select stays within,
are not written, and a position with an X or Z bit writes nothing
(IEEE 1800-2023 7.4.6, 11.5.1). A constant position outside the target
writes nothing, and one partly outside writes the bits inside.

Verilator 5.052 drops overlapping run-time part-select updates and writes
an out-of-range update into bit 0; the two affected cases are excluded
with an adapter-free reproduction. Icarus passes all four new cases.

Fixes #1709

Change-Id: If5c77a6b7c4bdf593210070c988a351dd69138f2
Change-Id: I6eb95ebed371843c56421db2b5be708f5f491d14
@tignear
tignear force-pushed the fix/sv-process-nba-forms branch from b2da215 to 605514f Compare October 23, 2026 07:53

@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: 605514fdb2

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

},
});
}
let write = dynamic_packed_write(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve negative narrow signed positions

When a run-time position is a signed value narrower than 32 bits (for example, logic signed [3:0] i = -2; q[i +: 4] <= 4'b1010;), dynamic_packed_write builds the position through runtime_select_position_in_range, which widens such an index as unsigned because index_is_wide is false. This new process-NBA path therefore treats i as 14 and drops the update, whereas the negative select should clip against the low end and update q[1:0]; preserve the selector's signedness when widening it.

Useful? React with 👍 / 👎.

Comment on lines +4677 to +4679
let window = write
.window
.unwrap_or_else(|| BitAccess::new(0, var_width - 1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep dynamic part-selects inside their array element

When both the unpacked element and its packed position are dynamic, such as mem[addr][k +: 4] <= 4'hf with 16-bit elements and k = 14, runtime_select_window returns no element window because the flattened base contains an element-stride term. This fallback then clips against the entire flattened array, so the update writes the top two bits of mem[addr] and the low two bits of the neighboring element instead of discarding the out-of-element bits. Retain the selected element's dynamic window rather than using the whole variable in this case.

Useful? React with 👍 / 👎.

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

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 24 minutes 58 seconds in the queue, including 49 minutes 49 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 merged commit ce2c08d into master Oct 23, 2026
30 checks passed
@mergify
mergify Bot deleted the fix/sv-process-nba-forms branch October 23, 2026 10:54
@mergify mergify Bot removed the queued Mergify queue entry label Oct 23, 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.

SV: nonblocking assignments in processes to arrays, run-time positions, and out-of-range targets

1 participant