Skip to content

feat(sv): support non-ANSI module port declarations - #1954

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/feat/426-sv-non-ansi-ports
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/feat/426-sv-non-ansi-ports

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #426.

What

Non-ANSI module port declarations (IEEE 1800-2023 23.2.2.1). The header lists port names; input / output / inout declarations in the body give their direction and type; a net or variable declaration of the same name may complete a port declaration without a net or variable type:

module ff(clk, d, q);
  input clk;
  input [7:0] d;
  output [7:0] q;
  reg [7:0] q;
  always @(posedge clk) q <= d;
endmodule

rtlmeter's C906 needs this: 277 of its 289 modules use this form, all with simple identifier headers.

Supported:

  • port declarations with or without a net type, var, a data type, signing, packed and unpacked dimensions and several names (input a, b;);
  • completion by a net or variable declaration. A vector one repeats the port declaration's range; the port declaration's range and signed carry over to a scalar one (input signed [3:0] a; wire a;);
  • a net declaration assignment of a port (output [4:0] s; wire [4:0] s = a + b;), which stays the continuous assignment it is (10.3.1).

Rejected by name:

  • a header port without a port declaration;
  • a port declared twice;
  • a port declaration that names no header port;
  • differing ranges;
  • a second declaration of a port whose port declaration already has a net or variable type;
  • a variable initializer, unpacked dimensions or strength/delay qualifiers on the completing declaration.

Headers with port expressions (selects, concatenations, .p(expr), empty ports) stay unsupported. They are split out as #1953, and the rejection now names them.

How

celox-sv-syntax/src/parser/non_ansi.rs runs when a unit finishes parsing. If every header port is a simple name, it:

  • parses the body port declarations, which the generic body parser keeps as unconverted input/output items;
  • moves each one onto its header port;
  • removes a completing net or variable declarator, merging its type;
  • marks the unit ANSI.

Analysis and lowering then see the same unit an ANSI header would produce. Units whose header is already ANSI, or that have no ports, return immediately.

Validation

  • Shared case hierarchy::non_ansi_ports_take_body_declarations: register-style ports, completing reg / wire signed declarations, a port net declaration assignment, and positional and named connections. It passes on every Celox backend, verify-sv-icarus 1/1 and verify-sv-verilator 1/1.
  • Celox test rejects_malformed_non_ansi_port_declarations covers each rejection. Parser test non_ansi_port_declarations_fold_into_the_header. The existing rejection test now uses a port expression.
  • cargo nextest run -p celox -p celox-sv-syntax -p celox-sv-analyzer -p celox-frontend-sv -p celox-test-suite --features celox/systemverilog: 15261 passed. retained_reports passes. Clippy (workspace, all targets) and fmt are clean.
  • sv-tests: no verdict changes. The conformance cases with body port declarations fail for other reasons (UVM, assertions, procedural assign/deassign).
  • C906 now passes port adoption and analysis up to its hierarchical references (feat(sv): support hierarchical references #1893).

Performance

The fold runs only for units with a non-ANSI header and returns before any work otherwise, so ANSI designs (including b2_vm_dispatch_bit.sv) take the same path as before.

@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-25T02:36:13.259086Z
We couldn’t complete this review. Comment @codex review to try again.
ffebc79 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.

@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

  • ✅ Entered queue — 2026-10-25 03:53 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue — 2026-10-25 04:30 UTC · at ffebc79b781a54ad41e352147034d9279ab49bac

This pull request spent 36 minutes 46 seconds in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

The pull request was held in the queue, conflicting with at least one of 2 pull requests ahead of it. The conflict became a base branch one after #1893, #1952 merged.

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

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

@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 25, 2026
@tignear
tignear force-pushed the feature/feat/426-sv-non-ansi-ports branch from ffebc79 to 67833a3 Compare October 25, 2026 07:28
@mergify mergify Bot removed the dequeued Mergify stopped this queue entry; investigate before retrying label Oct 25, 2026
A non-ANSI header lists port names, and port declarations in the body
give their direction and type; a net or variable declaration of the same
name may complete a port declaration without a type (IEEE 1800-2023
23.2.2.1). When every header port is a simple name, the parser now folds
the body declarations into the header ports and gives the unit the ANSI
form, so analysis sees one declaration per port. A vector net or variable
declaration must repeat the port declaration's range; the port
declaration's range and signing carry over to a scalar one. A net
declaration assignment of a port stays a continuous assignment (10.3.1).

A header port without a port declaration, a port declared twice, a port
declaration that names no header port, differing ranges, a second
declaration of a port whose port declaration has a net or variable type,
and a variable initializer on a completed port are rejected by name. Headers with port
expressions (selects, concatenations, named or empty ports) stay
unsupported and are tracked in #1953.

Closes #426

Change-Id: I548cd471cd50819374b833c057bc2bfa39355e6a
@tignear
tignear force-pushed the feature/feat/426-sv-non-ansi-ports branch from 67833a3 to abc4ac6 Compare October 25, 2026 08:34
@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 1 hour 41 minutes 34 seconds in the queue, including 46 minutes 38 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

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): support non-ANSI module port declarations

1 participant