Skip to content

feat(sv): support scalar set membership constraints - #2238

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sv-constraint-extensions/support-scalar-set-membership-constraints--cdebb01d
Oct 27, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/sv-constraint-extensions/support-scalar-set-membership-constraints--cdebb01d

Conversation

@tignear

@tignear tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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.

@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 scalar set membership constraints #2238 👈
2 feat(sv): solve conditional class constraints bidirectionally #2239
3 feat(sv): support per-call inline class constraints #2240
4 feat(heap): accept per-call scalar constraint inputs #2250
5 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-27T06:33:33.011744Z 909723e 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: 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".

Comment on lines +164 to +168
DimensionKind::Index(id) => relation("==", value.clone(), recurse(id)?),
DimensionKind::Range { left, right } => relation(
"&&",
relation(">=", value.clone(), recurse(left)?),
relation("<=", value.clone(), recurse(right)?),

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 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)?),

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 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
@tignear
tignear force-pushed the stack/tignear/feat/sv-constraint-extensions/support-scalar-set-membership-constraints--cdebb01d branch from 4fc1740 to 909723e Compare October 27, 2026 06:31
@tignear

tignear commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 4fc1740 2026-10-27 06:30 UTC
2 content 4fc1740 → 909723e Fix review 5663035668: global inside operand context and expansion budget 2026-10-27 06:30 UTC

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 27, 2026
@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 b15dd7b at 08:08 UTC

Merged together with #2239. 41 min in the queue, 30 min of it CI.

So far

Merge conditions: 10 of 10 met

This pull request

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

@mergify
mergify Bot merged commit b15dd7b into master Oct 27, 2026
23 of 24 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/sv-constraint-extensions/support-scalar-set-membership-constraints--cdebb01d branch October 27, 2026 08:08
@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