Repository navigation
fix(sv): keep other processes' writes made before an edge's NBA region - #1884
Merged
Conversation
An edge process evaluates into a next state seeded from stable state, and its NBA commit copies the whole written range back. A process kernel that writes the same variable after the evaluation and before the NBA region, such as a `#0` resumption or a process the edge's blocking result wakes, lost its write, even in bits no nonblocking assignment touched and when no nonblocking assignment executed (#1864). An NBA update changes only the bits its lvalue names (IEEE 1800-2023 10.4.2), and the NBA region follows the active and inactive regions (4.4.2.4). Such a variable now goes through the exact staging that variables written both by blocking and nonblocking assignments already use: the nonblocking assignments write a staging value and mark a written-bit mask, and the NBA region merges `stable = (stable & ~mask) | (value & mask)`. The variable has no seed or whole-range commit. An unpacked array merges element by element in a loop, and its mask is cleared by a commit from its zero stable copy. The change is per signal. `kernel_window_writes()` (lowering.rs) collects the variables a process kernel of the module may write after it first suspends. Code before the first timing control of an `initial` runs at time zero before any domain evaluates, so memory initialization by `initial` loops or `$readmemh` does not count. A process stages only those of its nonblocking targets it does not also write by blocking assignments or in called subroutines. Every other signal keeps today's code, and #1855's sparse array publication still applies to arrays without such a writer. Writers from other modules (hierarchical references, #1856) have to be added to `kernel_window_writes()`. A staged array costs O(array size) per edge, as before #1855. Not covered, keeping the previous behavior: nonblocking assignments in subroutines the edge process calls, and host writes while a `$stop` suspends a round after a domain evaluated. Repros from #1864 (plain `always @(posedge clk)`; with `always_ff` a second writer is illegal, 9.2.2.4 → 9.2.2.2), `celox run --top <m> --unlimited` on cranelift, interpreter, native O0 and wasm, two- and four-state, all now match Icarus 13.0: | Case | Expected (Icarus) | Before | After | |---|---|---|---| | win_c_al | `m0=00001122` | `m0=00001100` | expected | | win_d_al | `m0=00000011 m1=00000022 m5=00000033` | `m1=00000000 m5=00000000` | expected | | win_e_al | `q=00000022 r=00100008` | `q=00000000 r=00000008` | expected | | active-region wake | `q=22 p=44` | `q=00 p=44` | expected | Performance (callgrind, heliodor-dev, this vs #1855): no signal of these workloads is staged, and their JIT code executes the same instruction counts (b2_vm_dispatch_bit 411.55 M, Veryl 64K-word memory workload 15.19 M, b3_mem_sweep_14 0.43 M per run). Whole program: b2 46.686 G -> 46.683 G, Veryl 217.23 M -> 217.26 M, b3_mem_sweep_14 139.07 M -> 139.16 M (within 0.07%). Validation: - New shared cases `timing::edge_nonblocking_updates_keep_later_writes_of_other_bits`, `timing::edge_nonblocking_updates_follow_writes_their_blocking_results_wake` and `timing::edge_blocking_results_precede_later_process_writes` on cranelift, native, wasm and parallel variants. The first two fail without this change. All three pass on Verilator 5.052 and Icarus 13.0. - `cargo test -p celox --features systemverilog --test systemverilog`: 4462 passed. `cargo test -p celox-frontend-sv`. - `cargo clippy -p celox-frontend-sv -p celox --features celox/systemverilog --tests`, `cargo fmt --check`. Closes #1864 Change-Id: I8356911ef0608ae6eb0175147ca64ddc8881f7b9
Contributor
Author
|
This pull request is part of a Mergify stack:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
Queued — the merge queue status continues in this comment ↓. |
Contributor
Merge Queue Status
This pull request spent 2 hours 19 minutes 17 seconds in the queue, including 1 hour 52 seconds running CI. Required conditions to merge
|
This was referenced Oct 24, 2026
Base automatically changed from
stack/tignear/feature/fix/1855-nba-array-commit/publish-only-written-elements-nonblocking-array--04824191
to
master
October 24, 2026 15:24
mergify
Bot
deleted the
stack/tignear/feature/fix/1855-nba-array-commit/keep-other-processes-writes-made-edge-s-nba-region--8356911e
branch
October 24, 2026 16:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An edge process evaluates into a next state seeded from stable state, and
its NBA commit copies the whole written range back. A process kernel that
writes the same variable after the evaluation and before the NBA region,
such as a
#0resumption or a process the edge's blocking result wakes,lost its write, even in bits no nonblocking assignment touched and when
no nonblocking assignment executed (#1864). An NBA update changes only the
bits its lvalue names (IEEE 1800-2023 10.4.2), and the NBA region follows
the active and inactive regions (4.4.2.4).
Such a variable now goes through the exact staging that variables written
both by blocking and nonblocking assignments already use: the nonblocking
assignments write a staging value and mark a written-bit mask, and the NBA
region merges
stable = (stable & ~mask) | (value & mask). The variablehas no seed or whole-range commit. An unpacked array merges element by
element in a loop, and its mask is cleared by a commit from its zero
stable copy.
The change is per signal.
kernel_window_writes()(lowering.rs) collectsthe variables a process kernel of the module may write after it first
suspends. Code before the first timing control of an
initialruns attime zero before any domain evaluates, so memory initialization by
initialloops or$readmemhdoes not count. A process stages onlythose of its nonblocking targets it does not also write by blocking
assignments or in called subroutines. Every other signal keeps today's
code, and #1855's sparse array publication still applies to arrays
without such a writer. Writers from other modules (hierarchical
references, #1856) have to be added to
kernel_window_writes(). A stagedarray costs O(array size) per edge, as before #1855.
Not covered, keeping the previous behavior: nonblocking assignments in
subroutines the edge process calls, and host writes while a
$stopsuspends a round after a domain evaluated.
Repros from #1864 (plain
always @(posedge clk); withalways_ffa secondwriter is illegal, 9.2.2.4 → 9.2.2.2),
celox run --top <m> --unlimitedon cranelift, interpreter, native O0 and wasm, two- and four-state, all
now match Icarus 13.0:
m0=00001122m0=00001100m0=00000011 m1=00000022 m5=00000033m1=00000000 m5=00000000q=00000022 r=00100008q=00000000 r=00000008q=22 p=44q=00 p=44Performance (callgrind, heliodor-dev, this vs #1855): no signal of these
workloads is staged, and their JIT code executes the same instruction
counts (b2_vm_dispatch_bit 411.55 M, Veryl 64K-word memory workload
15.19 M, b3_mem_sweep_14 0.43 M per run). Whole program: b2 46.686 G ->
46.683 G, Veryl 217.23 M -> 217.26 M, b3_mem_sweep_14 139.07 M -> 139.16 M
(within 0.07%).
Validation:
timing::edge_nonblocking_updates_keep_later_writes_of_other_bits,timing::edge_nonblocking_updates_follow_writes_their_blocking_results_wakeand
timing::edge_blocking_results_precede_later_process_writesoncranelift, native, wasm and parallel variants. The first two fail
without this change. All three pass on Verilator 5.052 and Icarus 13.0.
cargo test -p celox --features systemverilog --test systemverilog:4462 passed.
cargo test -p celox-frontend-sv.cargo clippy -p celox-frontend-sv -p celox --features celox/systemverilog --tests,cargo fmt --check.Closes #1864
Depends-On: #1869