Repository navigation
fix(sv): write the bits inside a part-select partly outside its vector - #1782
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. |
de340eb to
f6997d8
Compare
f6997d8 to
c32f6db
Compare
A blocking, comb, always_ff or continuous write to a constant part-select partly outside the vector wrote nothing; it now writes the bits inside, taking the matching bits of the value (IEEE 1800-2023 11.5.1). A write wholly outside still has no effect, and a continuous one is no longer rejected as a run-time position. A run-time select within one array element whose position is known while the design is compiled, from a time-zero initial block or an unrolled loop, was folded to a constant position of the whole array and wrote into the neighbouring elements. Such a fold is kept only while it stays within the element. Verilator 5.052 writes these out-of-range bits; the three new cases join the existing part-select overhang exclusion. Icarus passes them. Fixes #1778 Change-Id: I85269ba41a9587ee1e8f159dde592f0ddb2061b6
Change-Id: I479256f5f43fad0f27b36f979226b3abed2cd284
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c32f6db59d
ℹ️ 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".
| .and_then(|(msb, lsb)| constant_select_write(variable, msb, lsb)?.0) | ||
| .unwrap_or(whole), |
There was a problem hiding this comment.
Skip wholly out-of-range targets in the process scan
When an always_comb body only contains a now-supported no-op such as q[11:8] = v for an 8-bit q, constant_select_write returns Some((None, _)), but this and_then converts it to None and unwrap_or(whole) records all of q as written. The generated body contains no store, so retention analysis can report an inferred latch for a statement that writes no bits; edge-process metadata likewise contains a phantom whole-variable target. Handle the wholly-outside result separately and avoid adding a target.
Useful? React with 👍 / 👎.
| if start > end { | ||
| return Some((None, 0)); |
There was a problem hiding this comment.
Exclude no-op slices from driver overlap analysis
For two assignments to the same wholly out-of-range slice, such as two continuous assignments to q[11:8] when q is 8 bits, this helper makes both writes no-ops during lowering, but continuous_driver_ranges and local_driver_ranges still collect the raw [8:11] ranges through net_lvalue_range. Their overlap check therefore rejects the module as having multiple drivers before lowering reaches this return. The driver scans need to clip ranges to the destination and omit ranges with no in-bounds bits.
Useful? React with 👍 / 👎.
c32f6db to
1358eba
Compare
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 1 hour 13 minutes 10 seconds in the queue, including 1 hour 11 minutes 33 seconds running CI. Required conditions to merge
|
Part of #1123. Fixes #1778.
IEEE 1800-2023 11.5.1: a write to a part-select partly outside the vector writes the bits inside, and a write wholly outside has no effect.
q[9:6] = vonlogic [7:0] q, inalways_comb, a process,always_ff(blocking or nonblocking)q[7:6] = v[1:0]up[6:9] = vonlogic [0:7] upup[6:7] = v[3:2]assign q[9:6] = v;q[7:6]drivenassign q[11:8] = v;a[1][k +: 4] = vwithkknown at compile time (time-zeroinitial, unrolled loop)a[0]/a[2]a[1]Fix
constant_select_write: clips a constant select to the variable. It returns the bits inside and how many low value bits fall below the variable.Target::Staticnow carries the select width and the dropped bits), by the always_ff and processwrite, and by the write-target scans of both.dynamic_packed_write). Comb's store propagation and the always_ff loop overlay replaced its position with a constant, which counts from bit 0 of the whole array.keep_element_window: keeps the fold only while the folded range stays within the element, and otherwise falls back to the run-time form.packed_index_positionis identical to the one in feat(sv): run nonblocking assignments in processes to array elements and run-time positions #1773, at the same place, so the two merge cleanly.Not in this PR (unchanged, rejected with a clear error)
r = q[9:6], is rejected ("always_ff expression"); 11.5.1 reads x for the missing bits.m[1][9:6]("part-select ofmoutside its declared range").Both are candidates for a follow-up.
Perf
Optimized SIR (
TraceOptions::post_optimized_sir, hashed Debug text) is byte-identical between base d7bb5a3 and this branch for 626 of the 629 SV suite cases, timed and untimed. The three that differ are the new cases.Since #1720, a
Simulatorbuild of a timed design fails, but its trace still holds the SIR produced before that error. The digest now reads the trace, so timed designs are compared as real SIR rather than as build errors.Tests
indexed_select:constant_part_selects_partly_outside_write_the_bits_insideascending_part_selects_partly_outside_write_the_bits_insideknown_run_time_selects_stay_within_their_element(timed)0x5ffor the wholly outside write, the wrong end for the ascending one, and0x80for the element). The three cases join the existingsv_verilator_part_select_write_overhangexclusion; its pre-exclusion records and the LIMITATIONS table are updated.indexed_select.jsonreports gain only the three new records.continuous_part_selects_partly_outside_drive_the_bits_insidecovers the continuous assignment. Icarus 13.0 aborts on it (vvpset_vecassertion), so it can't be a suite case.expected.tsv.