Skip to content

feat(sv): declare implicit nets for continuous assignment targets - #1952

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/feat/1946-sv-implicit-assign-nets
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/feat/1946-sv-implicit-assign-nets

Conversation

@tignear

@tignear tignear commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1946.

What

IEEE 1800-2023 6.10, third case: an identifier on the left-hand side of a continuous assignment that its scope does not declare is an implicit scalar net of the default net type, declared in the scope of the assignment. Celox already handled the port-connection case (in the frontend glue) but rejected this one with an unrelated message ("always_ff expression" / "event expression x"). rtlmeter's C906 relies on it: apb_bridge assigns busy_s9 without declaring it, and soc assigns pad_dtm_jtg_tclk, which only a port connection mentions.

  • Undeclared targets in modules and programs, including inside generate blocks and as concatenation or select bases (assign {p, q[0]} = a;), get a net declaration of the default_nettype type at the start of the scope of the assignment.
  • default_nettype none (22.8) keeps it an error, now reported at the target: "continuous assignment to undeclared x under `default_nettype none".
  • A scope that a wildcard import reaches declares no implicit nets, because the import may supply the name (26.3). The previous behavior applies there.
  • Implicit nets of interfaces stay unsupported, as documented in the interface restrictions.

How

celox-sv-syntax/src/parser/implicit_nets.rs runs when a module or program unit finishes parsing. It walks the scopes from an explicit stack (deep generate nesting stays off the call stack) and collects:

  • the names each scope declares (ports, parameters, nets, variables, instances, subroutines, types, explicit imports, generate block labels, genvars);
  • its continuous-assignment targets.

Items this pass does not interpret (unconverted declarations, unbraced generate items) count as declaring every identifier they contain, so they never gain a net by mistake. The pass then adds the synthesized NetDeclaration body items, so analysis and lowering see ordinary nets.

Validation

  • Shared case synthesizable::continuous_assignment_targets_declare_implicit_nets: module scope, concatenation targets, a generate block, and an always @(x or q) event list reading the implicit nets (the C906 pattern). It passes on every Celox backend, verify-sv-icarus 1/1 and verify-sv-verilator 1/1.
  • Celox test default_nettype_none_rejects_undeclared_assignment_targets. Parser tests cover per-scope declaration and 10,000-deep generate nesting.
  • cargo nextest run -p celox -p celox-sv-syntax -p celox-sv-analyzer -p celox-frontend-sv -p celox-test-suite --features celox/systemverilog: 15262 passed. retained_reports passes. Clippy (workspace, all targets) and fmt are clean.
  • sv-tests: chapter-6/6.10--implicit_continuous_assignment.sv goes fail → pass in both state modes; expected.tsv is updated. Simulated with a probe: c=1 in Celox (2- and 4-state) and Icarus. No other verdict changes.

Performance

The pass returns immediately for units without continuous assignments: 52 instructions on b2_vm_dispatch_bit.sv, whose simulation is unchanged. On C906 (150k lines, thousands of assigns), callgrind on the release build up to the end of parsing shows the pass at 39.2M instructions: 0.18% of the run and 1.7% of Declarations::from_tokens. Most of that is hash-set inserts of the declared names it borrows from the syntax tree.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-25T01:19:02.980604Z
We couldn’t complete this review. Comment @codex review to try again.
ca4fd42 PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

An identifier on the left-hand side of a continuous assignment that its
scope does not declare is an implicit scalar net of the default net type
in that scope (IEEE 1800-2023 6.10). The parser now gives each such
identifier of a module or program a net declaration at the start of the
scope of the assignment, including in generate blocks, so later stages
see an ordinary net. `default_nettype none` keeps it an error, now named
at the target (22.8); a scope a wildcard import reaches declares no nets,
since the import may supply the name. Implicit nets of interfaces stay
unsupported.

The sv-tests case 6.10--implicit_continuous_assignment now passes in both
state modes.

Closes #1946

Change-Id: Ie2dfd625af7422c17170c88c7c2376260bdbb425
@tignear
tignear force-pushed the feature/feat/1946-sv-implicit-assign-nets branch from ca4fd42 to a16c4c6 Compare October 25, 2026 01:37
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 25, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 25, 2026
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 36 minutes 21 seconds in the queue, including 34 minutes 7 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • 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)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify
mergify Bot merged commit 726ab26 into master Oct 25, 2026
24 checks passed
@mergify
mergify Bot deleted the feature/feat/1946-sv-implicit-assign-nets branch October 25, 2026 04:30
@mergify mergify Bot removed the queued Mergify queue entry label Oct 25, 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.

feat(sv): declare implicit nets for continuous assignment targets

1 participant