Repository navigation
feat(sv): pass subroutine arguments by reference - #2411
mergify[bot] merged 1 commit into
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 374971962d
ℹ️ 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".
3749719 to
bbe0ee6
Compare
Revision history
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbe0ee646f
ℹ️ 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".
bbe0ee6 to
2f84e58
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f84e58efd
ℹ️ 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".
2f84e58 to
efdb744
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efdb744705
ℹ️ 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".
Support `ref` and `const ref` formals of functions and tasks (IEEE 1800-2023 13.5.2). A formal is the actual itself: calls are inlined, so the inlined body names the actual's storage instead of a copy. Writes are visible at once, other names of the actual alias it, and a task keeps the reference while it is suspended. Calls without reference formals lower as before. Actuals can be variables (scalars, strings, class handles, queues, dynamic and associative arrays, unpacked arrays, and reference formals of the caller), class and static properties, whose object is evaluated at the call, and elements of fixed-size unpacked arrays, whose position is fixed at the call. A select past such an element reads and writes nothing instead of reaching the next element. Handles and positions held across a suspension are private to each forked activation. A formal bound to a property can be passed on to `output` and `inout` arguments. Reference formals may have container types. `const` carries over to following formals with the direction (13.3). The analyzer rejects static subroutines with reference formals, actuals that are expressions, constants, part-selects or nets, actuals of non-equivalent types (6.22.2), writes to `const ref` formals (also through selects passed to writable arguments and `$readmemb`/`$readmemh` destinations), nonblocking writes to `ref` formals (6.21), uses in `fork ... join_any/join_none` outside fork-variable initializers (9.3.2), and `ref` calls in continuous assignments or event expressions (13.4.1). `ref static`, elements of dynamically sized arrays (outdated references), elements of properties, members of unpacked structures and run-time selects of a formal bound to an element remain unsupported. New shared cases in `references.vtest` pass on all backends. Verilator, Icarus and xezim failures are retained as executed evidence with an adapter-free probe; xezim's copy semantics and subarray-element failure are reviewed as `sv_ref_copy_semantics` and `sv_ref_subarray_element`. Change-Id: I0402167840488bdc299af95f29abbfad8c2782ca
efdb744 to
2833ceb
Compare
|
Queued — the merge queue status continues in this comment ↓. |
|
@Mergifyio queue |
✅ Merged into
|
| Condition | Required by | |
|---|---|---|
| ✅ | check-success = Conventional Commit title |
— |
| ✅ | check-success = Queue validation |
— |
| ✅ | any of: check-success = @github-actions/Lint & Format, check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format |
GitHub repository ruleset rule master |
| ✅ | any of: check-success = @github-actions/Rust Test & NAPI Build, check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build |
GitHub repository ruleset rule master |
| ✅ | any of: check-success = @github-actions/JS Test (Ubuntu), check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu) |
GitHub repository ruleset rule master |
| ✅ | any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title |
GitHub repository ruleset rule master |
| ✅ | any of: check-success = @github-actions/Queue validation, check-neutral = @github-actions/Queue validation, check-skipped = @github-actions/Queue validation |
GitHub repository ruleset rule master |
Times in UTC · dashboard · how the merge queue works
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2833ceb133
ℹ️ 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".
| (Some(high), Some(low)) if high >= *width as i128 || low >= *width as i128 => { | ||
| let total = *total as i128; | ||
| ( | ||
| ConstExpr::Literal((total + high - low.min(high)).to_string()), | ||
| ConstExpr::Literal((total + low - low.min(high)).to_string()), |
There was a problem hiding this comment.
Preserve the valid bits of partially out-of-range selects
When a packed part-select straddles the boundary of an element reference, this condition moves the entire select past the containing array, discarding its valid bits too. For example, with logic [7:0] a[2], calling f(a[0]) where f(ref logic [7:0] r) executes r[9:6] = 4'hf should set a[0][7:6], but instead writes nothing. The existing constant_select_write behavior and indexed_select.vtest regressions preserve the in-range portion of such writes. Clip the access to the referenced element while retaining the corresponding RHS bits, rather than treating a partially out-of-range access as wholly invalid.
Useful? React with 👍 / 👎.
| let actual = args | ||
| .get(position) | ||
| .cloned() | ||
| .flatten() | ||
| .or_else(|| param.default.clone()); |
There was a problem hiding this comment.
Include default reference actuals in pre-scanned write targets
When an edge-triggered process omits a writable reference argument, this fallback aliases the default variable even though Ff::scan only records writable actuals explicitly present in args; default_calls scans calls inside defaults, not their destinations. For example, function automatic void inc(ref int x = g); x++; endfunction called by always @(posedge clk) inc(); writes g in the working region, but g is absent from the precomputed publication targets, so its stable value never receives the increment. Resolve omitted reference defaults during the write-target scan as well as during call execution; the existing default-argument regression only exercises an initial process, which stores directly into stable state.
Useful? React with 👍 / 👎.
| for (formal, _, target) in &references { | ||
| self.m.name_to_id.insert(formal.clone(), *target); |
There was a problem hiding this comment.
Preserve formal packed coordinates when aliasing variable storage
When equivalent integral types have different packed bounds, replacing the formal's variable ID also replaces the layout used to interpret its selects. For example, logic [15:8] a is accepted by f(ref logic [7:0] x), but x[0] = 1'b1 is subsequently interpreted by constant_select_write against a's [15:8] range, so the write is discarded instead of setting a[8]. Ascending actual ranges can likewise redirect writes to the wrong bit. Keep the formal's coordinate mapping while aliasing the actual's storage, and apply the same treatment to the corresponding remapping in Comb::call.
Useful? React with 👍 / 👎.
Support
refandconst refformals of functions and tasks (IEEE 1800-2023 13.5.2). A formal is the actual itself: calls are inlined, so the inlined body names the actual's storage instead of a copy. Writes are visible at once, other names of the actual alias it, and a task keeps the reference while it is suspended. Calls without reference formals lower as before.Actuals can be variables (scalars, strings, class handles, queues, dynamic and associative arrays, unpacked arrays, and reference formals of the caller), class and static properties, whose object is evaluated at the call, and elements of fixed-size unpacked arrays, whose position is fixed at the call. A select past such an element reads and writes nothing instead of reaching the next element. Handles and positions held across a suspension are private to each forked activation. A formal bound to a property can be passed on to
outputandinoutarguments. Reference formals may have container types.constcarries over to following formals with the direction (13.3).The analyzer rejects static subroutines with reference formals, actuals that are expressions, constants, part-selects or nets, actuals of non-equivalent types (6.22.2), writes to
const refformals (also through selects passed to writable arguments and$readmemb/$readmemhdestinations), nonblocking writes torefformals (6.21), uses infork ... join_any/join_noneoutside fork-variable initializers (9.3.2), andrefcalls in continuous assignments or event expressions (13.4.1).ref static, elements of dynamically sized arrays (outdated references), elements of properties, members of unpacked structures and run-time selects of a formal bound to an element remain unsupported.New shared cases in
references.vtestpass on all backends. Verilator, Icarus and xezim failures are retained as executed evidence with an adapter-free probe; xezim's copy semantics and subarray-element failure are reviewed assv_ref_copy_semanticsandsv_ref_subarray_element.