Repository navigation
feat(sv): bind caller scalar inputs in inline constraints - #2251
Conversation
|
This pull request is part of a Mergify stack:
|
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: 53f983e260
ℹ️ 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".
| Ok(Expr::Call { | ||
| callee: Callee::Subroutine(name), | ||
| args: vec![Some(handle), Some(selection)], | ||
| args: [vec![Some(handle), Some(selection)], input_values].concat(), |
There was a problem hiding this comment.
Read captured constraint variables after pre_randomize
When pre_randomize() modifies a caller-scope variable used by the inline constraint, passing that variable as an input argument here snapshots its value before the hook executes. In procedural/randomization.rs, lower_methods() runs the hook before solving, but the solver receives the already-copied $input parameter. For example, if module-scope wanted starts at 2 and the hook changes it to 5, p.randomize() with { x == wanted; } incorrectly solves for x == 2. Preserve access to mutable caller-scope variables until after the pre-hook so solving uses their current values.
Useful? React with 👍 / 👎.
| let candidate = match &native.expression(id).kind { | ||
| ExprKind::Name(name) => { | ||
| let name = instances::normalize_identifier(&name.spelling); | ||
| (!class.properties.iter().any(|p| p.name == name)).then_some((name.clone(), name)) |
There was a problem hiding this comment.
Check receiver static properties before caller-scope fallback
When the receiver class declares a static scalar property with the same name as a caller variable, this check incorrectly falls back to the caller because static properties are stored separately in class.statics. For example, with C::limit == 5 and a module-scope bit [7:0] limit == 3, p.randomize() with { x == limit; } silently constrains x to 3 instead of resolving the receiver's limit. Check static members before capturing a caller variable; if static constraint references remain unsupported, reject the expression rather than successfully solving against the wrong variable.
Useful? React with 👍 / 👎.
Resolve inline constraint names against the receiver class first, then the calling scope. Support local::name to bypass the receiver explicitly. Pass 1–64-bit two-state scalar variables and arguments as read-only call inputs, retaining width and signedness through solving, dynamic subclass dispatch and imported package methods. Keep local:: out of package dependency discovery. Four-state and unpacked inputs, typed parameter inputs, qualified this/super references and restricted with-name lists remain unsupported. IEEE 1800-2023 18.7 and 18.7.1. Validation: 70 constrained-randomization backend cases, 842 analyzer tests (three existing ignored), affected all-target Clippy, formatting, four retained-report tests and seven report checker tests pass. Both new shared cases pass Verilator. Icarus rejects the constraint/inline syntax; observed diagnostics extend the existing reviewed exclusion. Cases cover shadowed locals, signed values, repeated calls, range inputs, check-only calls, selected-member UNSAT preservation and imported inherited methods. Prepare the receiver (selection and pre-hook) before reading caller inputs, then solve and run the post-hook once. Receiver static members reject before caller fallback, while explicit local:: remains valid. Accept the official CI-observed fail-to-pass transition for 18.7.1--local-scope-resolution_0 in both state modes; both were rechecked with the pinned source and debug driver. Review validation: 75 constrained backend tests, three focused analyzer regressions, affected Clippy, four retained-report tests and seven report checker tests pass. The new hook case exposes Verilator 5.052 sampling inline inputs before the pre-hook; preserve the assertions and record observed evidence in the reviewed limitation. Change-Id: I65f528d40633d4cbbe253c55c98f0039c01f82aa
53f983e to
af696fe
Compare
9f0aab4 to
dfac2b8
Compare
Revision history
|
|
Queued — the merge queue status continues in this comment ↓. |
✅ Merged into
|
| Condition | |
|---|---|
| ✅ | depends-on = celox-sim/celox#2250 |
The batch, tested on draft #2261
| 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/NAPI Build (Linux ARM64 GNU), check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU), check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU) |
GitHub repository ruleset rule master |
| ✅ | any of: check-success = @github-actions/NAPI Build (Windows), check-neutral = @github-actions/NAPI Build (Windows), check-skipped = @github-actions/NAPI Build (Windows) |
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/JS Test (Windows), check-neutral = @github-actions/JS Test (Windows), check-skipped = @github-actions/JS Test (Windows) |
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 |
Times in UTC · dashboard · how the merge queue works
Resolve inline constraint names against the receiver class first, then the calling scope. Support local::name to bypass the receiver explicitly. Pass 1–64-bit two-state scalar variables and arguments as read-only call inputs, retaining width and signedness through solving, dynamic subclass dispatch and imported package methods. Keep local:: out of package dependency discovery.
Four-state and unpacked inputs, typed parameter inputs, qualified this/super references and restricted with-name lists remain unsupported. IEEE 1800-2023 18.7 and 18.7.1.
Validation: 70 constrained-randomization backend cases, 842 analyzer tests (three existing ignored), affected all-target Clippy, formatting, four retained-report tests and seven report checker tests pass. Both new shared cases pass Verilator. Icarus rejects the constraint/inline syntax; observed diagnostics extend the existing reviewed exclusion. Cases cover shadowed locals, signed values, repeated calls, range inputs, check-only calls, selected-member UNSAT preservation and imported inherited methods.
Prepare the receiver (selection and pre-hook) before reading caller inputs, then solve and run the post-hook once. Receiver static members reject before caller fallback, while explicit local:: remains valid. Accept the official CI-observed fail-to-pass transition for 18.7.1--local-scope-resolution_0 in both state modes; both were rechecked with the pinned source and debug driver.
Review validation: 75 constrained backend tests, three focused analyzer regressions, affected Clippy, four retained-report tests and seven report checker tests pass. The new hook case exposes Verilator 5.052 sampling inline inputs before the pre-hook; preserve the assertions and record observed evidence in the reviewed limitation.
Depends-On: #2250