Skip to content

feat(sv): bind caller scalar inputs in inline constraints - #2251

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sv-constraint-extensions/bind-caller-scalar-inputs-inline-constraints--65f528d4
Oct 27, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sv-constraint-extensions/bind-caller-scalar-inputs-inline-constraints--65f528d4

Conversation

@tignear

@tignear tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear

tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(sv): support per-call inline class constraints #2240
2 feat(heap): accept per-call scalar constraint inputs #2250
3 feat(sv): bind caller scalar inputs in inline constraints #2251 👈

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T08:32:38.279564Z af696fe New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
@tignear
tignear force-pushed the stack/tignear/feat/sv-constraint-extensions/bind-caller-scalar-inputs-inline-constraints--65f528d4 branch from 53f983e to af696fe Compare October 27, 2026 08:30
@tignear
tignear force-pushed the stack/tignear/feat/sv-constraint-extensions/accept-per-call-scalar-constraint-inputs--b35948f9 branch from 9f0aab4 to dfac2b8 Compare October 27, 2026 08:30
@tignear

tignear commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 53f983e 2026-10-27 08:29 UTC
2 content 53f983e → af696fe 2026-10-27 08:29 UTC

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added the queued Mergify queue entry label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as d597ab8 at 11:07 UTC

Merged together with #2240, #2250. 1 h 28 min in the queue, 46 min of it CI.

So far

Merge conditions: 10 of 10 met

This pull request

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

Base automatically changed from stack/tignear/feat/sv-constraint-extensions/accept-per-call-scalar-constraint-inputs--b35948f9 to master October 27, 2026 11:06
@mergify
mergify Bot merged commit d597ab8 into master Oct 27, 2026
27 of 45 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/sv-constraint-extensions/bind-caller-scalar-inputs-inline-constraints--65f528d4 branch October 27, 2026 11:07
@mergify mergify Bot removed the queued Mergify queue entry label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant