Repository navigation
feat(sv): support scalar set membership constraints - #2238
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: 4fc1740d0e
ℹ️ 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".
| DimensionKind::Index(id) => relation("==", value.clone(), recurse(id)?), | ||
| DimensionKind::Range { left, right } => relation( | ||
| "&&", | ||
| relation(">=", value.clone(), recurse(left)?), | ||
| relation("<=", value.clone(), recurse(right)?), |
There was a problem hiding this comment.
Size membership operands before expanding comparisons
When set members have different widths, expanding each member into an independent relation makes emit size the left-hand expression separately for each comparison. Membership instead needs a common width across the expression and all set members, as implemented by Verilator's membership sizing pass. For example, with four-bit unsigned properties a = 15 and b = 1, (a + b) inside {4'd0, 8'd17} should be false because the addition is evaluated at eight bits and produces 16. This lowering evaluates the first comparison at four bits, wraps the sum to zero, and incorrectly accepts the constraint. Determine and propagate the membership-wide operand context before constructing the equality and range predicates.
Useful? React with 👍 / 👎.
| for item in items { | ||
| use celox_sv_syntax::DimensionKind; | ||
| let predicate = match item.kind { | ||
| DimensionKind::Index(id) => relation("==", value.clone(), recurse(id)?), |
There was a problem hiding this comment.
Bound expansion of nested membership expressions
When the left operand itself contains membership expressions, value.clone() recursively copies the entire previously expanded tree for every set item. Repeatedly nesting (previous_expression) inside {0, 1} therefore doubles the tree at each level despite linear source growth. A standalone reproduction using the actual Typed, Kind, and relation definitions produces 786,427 nodes at only 17 levels; 25 levels require over 200 million nodes while remaining within the binder's 64-level source nesting limit. This can exhaust memory during class analysis, before the solver's resource limits apply. Add an expansion budget checked before cloning, or preserve shared subexpressions throughout lowering.
Useful? React with 👍 / 👎.
Bind inside values and inclusive bounded ranges to solver relations, preserving signed and mixed-width comparison contexts. Negation excludes a set and reversed ranges are empty. Balance membership alternatives to avoid linear expression depth. This extends the existing seeded scalar solver; it does not add a uniform sampling guarantee. Array sets, X/Z wildcard items and unbounded ranges remain rejected. IEEE 1800-2023 11.4.13 and 18.5.3 define membership semantics. Validation: 30 constrained-randomization backend tests, four analyzer randomization regressions, analyzer all-target Clippy and formatting pass. Verilator passes both new shared cases. Icarus rejects constraint syntax; the observed compile limitation is recorded in the reviewed exclusions and retained evidence. Membership sizing is determined across all set items and range endpoints before arithmetic. Analysis charges an expansion budget before copying predicates, rejecting deeply nested expansions before solver allocation. Added check-only overflow/range regressions and a 25-level nesting diagnostic test; 30 constrained backend tests, three focused analyzer tests, Verilator and analyzer Clippy pass. Icarus remains excluded for its recorded unsupported constraint syntax. Change-Id: Icdebb01d187fe5c73787b941bbef72d6bb0ef033
4fc1740 to
909723e
Compare
Revision history
|
✅ Merged into
|
| Condition | |
|---|---|
| ✅ | depends-on=celox-sim/celox#2238 |
The batch, tested on draft #2249
| 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
Bind inside values and inclusive bounded ranges to solver relations, preserving signed and mixed-width comparison contexts. Negation excludes a set and reversed ranges are empty. Balance membership alternatives to avoid linear expression depth. This extends the existing seeded scalar solver; it does not add a uniform sampling guarantee.
Array sets, X/Z wildcard items and unbounded ranges remain rejected. IEEE 1800-2023 11.4.13 and 18.5.3 define membership semantics.
Validation: 30 constrained-randomization backend tests, four analyzer randomization regressions, analyzer all-target Clippy and formatting pass. Verilator passes both new shared cases. Icarus rejects constraint syntax; the observed compile limitation is recorded in the reviewed exclusions and retained evidence.
Membership sizing is determined across all set items and range endpoints before arithmetic. Analysis charges an expansion budget before copying predicates, rejecting deeply nested expansions before solver allocation. Added check-only overflow/range regressions and a 25-level nesting diagnostic test; 30 constrained backend tests, three focused analyzer tests, Verilator and analyzer Clippy pass. Icarus remains excluded for its recorded unsupported constraint syntax.