Repository navigation
feat(sv): run nonblocking assignments in processes - #1501
Conversation
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
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. |
There was a problem hiding this comment.
💡 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".
| for part in parts { | ||
| targets.push(self.nba_target(part)?); |
There was a problem hiding this comment.
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 👍 / 👎.
| let (Some(msb), Some(lsb)) = ( | ||
| packed_index_offset(variable, msb), | ||
| packed_index_offset(variable, lsb), | ||
| ) else { | ||
| return Err(unsupported("nonblocking assignment outside its target")); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@Mergifyio queue |
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
|
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
initialoralwaysprocess 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 anNbaSite, and the runtime of #1361 queues its update for the NBA region (IEEE 1800-2023 10.4.2).Targets covered:
Still rejected, each under its own name (#1492):
q[i] <= v: the site can't publish only in-range bits;Pending fast path deferred. Every update goes through the ordered queue.
NbaSite::pendingrequires 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:#0;<=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$displayin the same slot prints the old value.New
review_regressions::rejects_process_nonblocking_assignments_without_a_constant_targetcovers 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;-D warningsandfmt --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.
@(posedge clk)stimulus kernel, blocking<=(new)