Repository navigation
perf(sv)!: stage nonblocking updates of a target with one writer - #1684
Conversation
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Queued — the merge queue status continues in this comment ↓. |
9769ade to
cfc6a79
Compare
Merge Queue Status
This pull request spent 11 minutes 16 seconds in the queue, with no time running CI. ReasonThe pull request conflicts with the base branch The pull request was held in the queue, conflicting with at least one of 2 pull requests ahead of it. The conflict became a base branch one after #1679, #1716 merged. Automatic conflict resolution can merge a conflict like this one instead of stopping on it, but only in a queue using the HintYou should update or rebase your pull request. If you want to requeue this pull request, you can post a Requeued — the merge queue status continues in this comment ↓. |
A nonblocking assignment in a process returned to the runtime, which queued its value for the NBA region. A site whose target nothing else writes now stages the value and sets its pending flag instead, and the kernel keeps running. The SV frontend emits both paths for each site, selected by a load of a switch variable. Assembly sees the whole design and keeps one path, replacing the selection by a jump and removing the other path, so no branch remains at run time. A site stages only if its target: - has no other nonblocking site, no store or commit in any unit, and is not a top-level port; - is read by no wait, counted signal, event domain or comb observer, directly or through combinational logic. Publication places staged updates after the queued ones, so the update order of a staged target must be unobservable. A queued site keeps its value in the frontend's staging variable, so the queued path no longer copies it. BREAKING CHANGE: `celox_frontend_core::symbolic::artifact::SimModule` has the new field `nba_switches`, of the new type `NbaSwitch`. Change-Id: I258ddca80817a101f75ae249011b7f894c7dae9f
The new timing case checks that the last update of a site in a time slot wins, that `n <= n + 1` issued twice gives 1, that updates of two sites of one target land in the order they were issued, and that a register samples the stimulus value from before the edge. It passes on Icarus 13.0 and Verilator 5.052. A Celox test checks which sites stage: only a target with one writer that no wait reads, directly or through combinational logic. Change-Id: I7d56dd4826aa8cfee3ad65e464fbc4f81dc718cc
The NBA region read each update and its target as BigUint values and merged them with BigUint masks. An update inside a target of at most 64 bits with one state plane is now merged as u64, queued and staged updates alike. The order of the updates and the masks are unchanged. Four-state targets, targets over 64 bits and array signals keep the BigUint merge. Staged sites are read from their value objects only when they are published, and the queue keeps its storage between time slots. Change-Id: I77dbee6f9b77624cc15cbbcba2fda5ad25d54c67
A part select across a byte boundary, a 64-bit target and a 65-bit target each take an update from a staged and from a queued site, and keep their other bits. A four-state variant checks that the unknown bits around an update stay unknown. Both pass on Icarus 13.0; Verilator 5.052 runs the two-state one. Change-Id: I591e062179d07de305b3f5a5fc288de1bedc328e
cfc6a79 to
4f17e00
Compare
Merge Queue Status
This pull request spent 1 hour 7 minutes 9 seconds in the queue, including 1 hour 5 minutes 24 seconds running CI. Required conditions to merge
|
Part of #1123 (step 4) and #1492: the first half of #1492, the pending fast path. Run-time targets (variable index, unpacked elements, reversed selects) stay in #1492.
Summary
Staging instead of queueing. A nonblocking assignment in an SV process used to return to the runtime, which queued the value for the NBA region. A site whose target has one writer now stages the value in the site's object and sets its
pendingflag (NbaSite::pending, from #1361), and the kernel keeps running. A site issued again in the same slot queues the staged value first, so the last update still wins.Assembly picks one path at compile time. The SV frontend emits both paths for each site, selected by a load of a switch variable. Assembly, which sees the whole design, then:
No branch and no switch state remain at run time. A site stages only if its target meets all of these (a simple syntactic check, no reachability or constant proofs):
through_combfrom fix(sim)!: commit blocking flip-flop stores in the active region #1480.The second condition is needed because publication places staged updates after the queued ones. IEEE 1800-2023 10.4.2 performs NBA updates in issue order, so the reordering is only allowed where nothing can see the order. Every other site keeps the ordered queue. A queued site keeps its value in the frontend's staging variable, so it no longer copies it into a second object.
u64 publication. The NBA region used to read each update and its target as
BigUintvalues and merge them withBigUintmasks. An update inside a target of at most 64 bits with one state plane is now merged asu64, for queued and staged updates alike. Order and masks are unchanged, and nothing new is allocated. Four-state targets, targets over 64 bits and array signals keep theBigUintmerge. The queue also keeps its storage between time slots.Perf
Local SV gate (not committed), the method of #1459/#1501:
always_ffaccumulators readingstim, with an XOR reduction;initial forever @(posedge clk) stim = stim + 3; (b5) is the same stimulus with<=;<=stimchanges there), plus the Rust publication itself. Step 3b removes both when it compiles the scheduler and the NBA region into SIR.Validation
timing::staged_nonblocking_updates_keep_their_order. It checks:n <= n + 1issued twice gives 1;timing::narrow_nonblocking_updates_keep_the_other_bits. A staged and a queued site each update:[11:4]of 16 bits);BigUintmerge).The other bits are kept.
timing::four_state_nonblocking_updates_keep_unknown_bits: the X/Z bits around a staged and a queued update survive, and also around a 65-bit one.--fresh). Verilator reports the four-state case as unsupported, being two-state. All three run on all five backends. The retained reports are not regenerated, per CONTRIBUTING (new passing cases need no baseline refresh).nonblocking_sites_stage_only_unobserved_targets_with_one_writerchecks that only the stimulus target stages. These stay queued: a target read bywait (a && !b); one read throughwire c = d & ~eby@(posedge c); one read by the expression event@(posedge (s & en))(feat(sv): lower expression events and @* in processes #1681), through its$eventvariable; one with two sites; one with a blocking writer; a top-level port. It also checks that their behaviour is the same as on master.narrow_nonblocking_updates_cover_staged_and_queued_siteschecks that the narrow case exercises both paths.narrow_merges_match_wide_mergescompares the u64 merge with theBigUintmerge over widths 1–64, every position and several bit patterns.a <= 1; b <= 1;withbhaving a second writer), Icarus 13.0 seeswait (a && !b)= 0,@(posedge (a & ~b))= 1 and@(posedge c)= 1. Verilator 5.052 sees 0, 0, 0.cargo test -p celox --features systemverilog: lib with golden traces unchanged (174), the SV suite (3299), and the SV-gated binaries plus checkpoint, state_file, processes and simulation_step;cargo test -p celox-runtime -p celox-design -p celox-frontend-core -p celox-frontend-sv -p celox-test-suite;conformance/sv-tests/run.py, both state modes) on b811bbc plus this branch: unchanged fromexpected.tsv;-D warningson the affected crates and the SV test target, andfmt --check.BREAKING CHANGE
celox_frontend_core::symbolic::artifact::SimModulehas the new fieldnba_switches, of the new typeNbaSwitch.