Skip to content

feat(sv)!: support packed unions, scoped locals and named calls - #1211

Merged
tignear merged 10 commits into
masterfrom
feature/sv-milestone-remaining
Oct 12, 2026
Merged

tignear merged 10 commits into
masterfrom
feature/sv-milestone-remaining

Conversation

@tignear

@tignear tignear commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Veryl-emitted RTL containing packed unions, shadowed procedural locals, named calls, X/Z constant casts or array-parameter patterns now compiles and simulates through the SystemVerilog frontend.

  • Give equal-width hard packed untagged union members the same storage while preserving signedness and state kind.
  • Keep block-local identities separate from module signals and other processes; prune constant procedural branches without dropping runtime subroutine effects.
  • Bind named actuals by the active declaration's formal names, including generate scopes, constant expressions and supported DPI-C prototypes. Preserve source order for input evaluation and output copy-out; DPI registers are passed in C formal order.
  • Preserve omitted expression actuals until lowering, evaluate ANSI defaults only when used in the enclosing declaration scope, and reject missing required actuals. Constant calls retain parameter dependencies and declared result widths; array-pattern leaves evaluate the caller's installed constant functions.
  • Evaluate unsigned'(byte'(X)) in constant initializers with four-state parameter values, including conversion of X/Z to zero.
  • Bind array-pattern references and explicit pattern types in the caller scope, then specialize the callee's overridable header or body parameter. Serialize self-determined packed patterns as values, preserving width, signing, X/Z and callee struct metadata even when field names or divisions differ. Typed scalar patterns also override ordinary defaults. Preserve assignment context for unbased fill literals and arithmetic; repetition counts and index keys retain caller bindings.

Re-enable the corresponding Veryl-to-SV regressions, add portable lexical-scope cases, and update the English/Japanese support guides.

Compatibility: public ast::Expr::Call, ir::Expr::Call and StmtBase::Call gain arg_order; expression-call args change from Vec<Expr> to Vec<Option<Expr>> to represent omitted actuals. Downstream constructors and exhaustive field patterns must account for these changes.

Expression and statement calls support ANSI argument defaults under IEEE 1800-2023 13.5.3. Named calls with procedural effects in selection indices and packed union assignment patterns remain unsupported.

Closes #440.
Closes #445.
Closes #1187.
Closes #1188.
Closes #1189.

Scope relative to other PRs

Includes master 0c62248fe. Mixed-interface behavior (#1204), unpacked-dimension queries (#1171), and the clock/DSE changes are inherited from that merged base and covered by the integration checks. Timed testbench execution and removing the systemverilog feature gate remain separate work; #1191 and #1192 remain open.

Validation

  • Formatting, diff checks and affected all-target Clippy passed with celox/sv-dpi and both external-adapter features.
  • Final native coverage: 4,019 passed across every applicable backend: 2,273 SV, 62 DPI, 53 package, 160 Veryl-context, 827 comb-observer, 13 frontend-SDK, 170 interface, 46 advanced-interface, 385 basic and 30 multi-clock tests. Existing backend exclusions remain unchanged.
  • Portable regressions cover caller constant-function patterns, body array-parameter overrides, named calls in constant contexts and dimension queries, generate-local signatures, declaration-bound dynamic defaults, packed patterns with different struct names/layouts, typed scalar overrides, and mixed two/four-state members and integer atoms. The final focused selection passes 168 tests.
  • Analyzer/frontend unit tests: 394 passed; four existing manual probes ignored. Shared-suite unit/integration, all three retained-evidence checks and affected doctests pass. An analyzer test re-evaluates an exported named-call parameter with a changed W; a mixed-language test verifies named/defaulted SV constant calls under Veryl interface overrides across all four mixed-language backends.
  • Fixed-revision sv-tests: all 923 expectations are satisfied (409 pass, 457 fail, 57 no top). The packed-union expectation is the only intentional baseline change in this PR; the merged $printtimescale support adds a pass without relaxing the baseline.
  • Verilator 5.052: six pattern cases pass, two four-state cases are outside its supported comparison, and typed int pattern sign extension disagrees with IEEE 1800-2023 10.9/6.11.3/6.20.2. A standalone probe confirms it zero-extends the pattern directly but sign-extends through an int variable/cast. Named constant/query and generate-signature cases pass; dynamic-default scope remains its separately reviewed disagreement under 13.5.3.
  • Icarus 13.0: the pattern cases hit its retained array/typed-pattern syntax limitations; generate-signature calls pass. It returns the wrong rank for a named/defaulted integral function query (existing function-return-dimension limitation) and rejects dynamic defaults. Observed failures are narrowly retained with their actual diagnostics; assertions and unrelated successful evidence are preserved.
  • NAPI build and 256 JavaScript runtime tests pass with a 30s per-test limit.
  • Workflow/classifier tests (31) and actionlint pass. The proof-corpus job has a 120-minute budget for measured cold runs; every proof/mutation gate and artifact remains enabled.

All local builds use the locked Nix environment and managed default target/. Routine successful simulator results and proof manifests were not regenerated.

Latest head 8c82448ac: CI and lydite both succeeded. Every selected check passes; platform skips follow the existing PR job-selection policy. All seven review threads are resolved, and GitHub reports the PR mergeable with a clean merge state.

Also preserve X/Z constant casts and bind unpacked-array parameter patterns in the caller scope. Re-enable the matching Veryl-to-SV regressions and add shared lexical-scope coverage.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T22:56:58.510630Z 8c82448 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: 257c6dc84e

ℹ️ 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 thread crates/celox-sv-analyzer/src/ast/expressions.rs
Comment thread crates/celox-sv-analyzer/src/ast/instances.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/instances.rs Outdated
Keep fill literals and arithmetic in their assignment context, and include DPI prototypes in named-call signatures. Add shared regressions and retain the observed Icarus array-parameter limitation. Update only the newly passing packed-union conformance expectation.

@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: fdd6847dde

ℹ️ 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 thread crates/celox-sv-analyzer/src/ast/instances.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/type_parameters.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/expressions.rs
@tignear
tignear enabled auto-merge October 11, 2026 19:04
The only conflict is the retained Icarus evidence report, where both sides
appended reviewed failures to the same list.

- Keep both appends: master's `$printtimescale` exclusions and this branch's
  `hierarchy::parameter_patterns_*` exclusions, raising `compile_error` from 81
  to 87 and the case count from 97 to 103.
- Give the four pattern rows the schema-3 metadata (`stronger_than_sv`, `tags`,
  `tag_reasons`) that the report writer always emits, so they match the
  neighbouring retained rows and a fresh run instead of only the older
  schema-2 leftovers.
- The exclusion table, the aggregate limitations evidence and the case
  catalogue merged without conflict; no reviewed failure or coverage contract
  changed beyond that union. The merged row set is exactly the union of both
  parents' rows.

@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: 07a5b7ad65

ℹ️ 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 thread crates/celox-sv-analyzer/src/ast/expressions.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/expressions.rs Outdated
@tignear
tignear added this pull request to the merge queue Oct 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 11, 2026

@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: 3ce85c9db2

ℹ️ 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 thread crates/celox-sv-analyzer/src/ast/patterns.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/instances.rs
@tignear
tignear added this pull request to the merge queue Oct 12, 2026
Merged via the queue into master with commit 34fa409 Oct 12, 2026
32 checks passed
@tignear
tignear deleted the feature/sv-milestone-remaining branch October 12, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment