Repository navigation
feat(sv): run nonblocking assignments in processes to array elements and run-time positions - #1773
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. |
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 3 minutes 17 seconds in the queue, with no time running CI. ReasonThe pull request conflicts with the base branch 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 ↓. |
dc7df44 to
928e44d
Compare
928e44d to
b2da215
Compare
…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
b2da215 to
605514f
Compare
There was a problem hiding this comment.
💡 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( |
There was a problem hiding this comment.
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 👍 / 👎.
| let window = write | ||
| .window | ||
| .unwrap_or_else(|| BitAccess::new(0, var_width - 1)); |
There was a problem hiding this comment.
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 👍 / 👎.
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
|
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:
m[1] <= v,m[i] <= v,grid[i][j] <= v,m[i][7:4] <= von unpacked arraysq[i] <= 1,q[i +: 3] <= v,up[i -: 2] <= vq[8] <= 1onlogic [7:0] q,q[9:6] <= vm[1:0] <= wonlogic [7:0] m [4](a slice running against the array's range)IEEE 1800-2023 rules applied:
Design
NbaPosition(celox-design). It holds two staging objects: a bit offset and the number of bits written.dynamic_array_element_lvalue,dynamic_packed_write).nonblocking_switchedpath 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_positionkeeps the position the kernel computed, asqueuedalready 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.Perf
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.Simulatorno longer builds designs with processes, so this check now reaches the timed cases only as build errors on both sides.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.Tests
process_nonblocking_assignments_to_array_elementsprocess_nonblocking_assignments_at_run_time_positionsprocess_nonblocking_assignments_outside_their_targetprocess_nonblocking_assignments_at_unknown_positions(four-state)limitations.json(sv_verilator_process_nba_positions). The adapter-free reproduction isverification/repros/process_nba_positions.sv, with the retained observation alongside it. The disagreements:q[8]into bit 0.timing.jsonwere 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.run_time_nonblocking_positions_cover_staged_and_queued_siteschecks that the staged and queued paths are both used.nonblocking_assignments_to_reversed_array_slices_reverse_the_elementscovers the slice, which neither Icarus nor Verilator compiles.unimplemented_timing_features_are_rejectedandrejects_process_nonblocking_assignments_without_a_constant_target.expected.tsv.Not in this PR
On master, a blocking or
always_ffwrite to a constant part-select that is partly out of range writes nothing. For example,q[9:6] = 4'b1111onlogic [7:0] qleaves 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.