Skip to content

fix(sv): compare the bounds, not the spelling, of non-ANSI port ranges - #2133

Merged
mergify[bot] merged 2 commits into
masterfrom
feature/fix/2126-non-ansi-range-values
Oct 31, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
feature/fix/2126-non-ansi-range-values

Conversation

@tignear

@tignear tignear commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

A non-ANSI port can be declared again in a net or variable declaration, and if that declaration is a vector, the two ranges "shall be identical" (IEEE 1800-2023 23.2.2.1). The parser compared the token text of the two ranges, so equal ranges written differently were rejected. rtlmeter's XuanTie E902 and E906 declare output [79:0] busif_kid_clicintattr_sel; and wire [CLICINTNUM-1:0] busif_kid_clicintattr_sel; with CLICINTNUM = 64+16, and the compile failed.

The parser cannot evaluate parameters, so the check moves to elaboration:

  • When the spellings differ, the parser keeps the net or variable declaration's type for the port and records the port declaration's type in the new Port::declared_type.
  • ports_from_scope evaluates both ranges with the module's parameter values and rejects the port when the bounds differ: "the ranges of a non-ANSI port declaration and its net or variable declaration of x differ".
  • A port declaration without a range completed by a vector declaration is still rejected by the parser.

Closes #2126.

  • Shared case hierarchy::non_ansi_port_ranges_compare_bounds: the E902 shape (a macro-built parameter in the net's range), matching Icarus and Verilator.
  • rejects_malformed_non_ansi_port_declarations also rejects ranges that differ through a parameter (input [3:0] a; wire [N-1:0] a; with N = 8).

Verification

  • Icarus and Verilator print ffffffffffffffffffff for the E902-shape case; verify-sv-icarus / verify-sv-verilator --filter hierarchy::non_ansi: 2/2 each.
  • cargo nextest run -p celox -p celox-test-suite -p celox-frontend-sv -p celox-sv-syntax -p celox-sv-analyzer with CI's features: 16165 passed. clippy (workspace minus lydite, --all-targets -D warnings): clean. retained_reports: passed.
  • sv-tests on the pinned dashboard corpus (db159ad8e9, 1650 cases, prepared with prepare.py): identical to conformance/sv-tests/expected.tsv.
  • b2_vm_dispatch_bit callgrind gate (release, --backend native, two runs each): step_until 4,295,070,035 on both base ddb2234 and this PR; totals 20,993,122,142 / 20,991,144,656 vs 20,992,816,976 / 20,992,934,534.
  • rtlmeter E902 and E906 hello now compile; with the sources in one file (see SV: macros from one source file are not visible in later files of the same compilation (blocks rtlmeter VeeR-EL2/EH1) #2128 for macros across files) both pass in four-state.

A non-ANSI port can be declared again in a net or variable declaration, and if that declaration is a vector, the two ranges "shall be identical" (IEEE 1800-2023 23.2.2.1). The parser compared the token text of the two ranges, so equal ranges written differently were rejected. rtlmeter's XuanTie E902 and E906 declare `output [79:0] busif_kid_clicintattr_sel;` and `wire [CLICINTNUM-1:0] busif_kid_clicintattr_sel;` with `CLICINTNUM` = 64+16, and the compile failed.

The parser cannot evaluate parameters, so the check moves to elaboration:
- When the spellings differ, the parser keeps the net or variable declaration's type for the port and records the port declaration's type in the new `Port::declared_type`.
- `ports_from_scope` evaluates both ranges with the module's parameter values and rejects the port when the bounds differ: "the ranges of a non-ANSI port declaration and its net or variable declaration of `x` differ".
- A port declaration without a range completed by a vector declaration is still rejected by the parser.

Closes #2126.

- Shared case `hierarchy::non_ansi_port_ranges_compare_bounds`: the E902 shape (a macro-built parameter in the net's range), matching Icarus and Verilator.
- `rejects_malformed_non_ansi_port_declarations` also rejects ranges that differ through a parameter (`input [3:0] a; wire [N-1:0] a;` with N = 8).

Change-Id: I0fc04b280c929c9f50d191276e5cc31fb4949ad5
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-31T10:46:49.612062Z eaf776b 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.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026
Change-Id: I1b666c99bf3bec2c6ea31960c88f76d9c5286bc0
@mergify mergify Bot added the queued Mergify queue entry label Oct 31, 2026
@mergify

mergify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as 0cb1011 at 11:29 UTC

11 min in the queue, 10 min of it CI.

So far

9 merge conditions met
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • check-success = Verify workflow lockfile
  • any of · required by 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 · required by 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 · required by 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 · required by 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
  • any of · required by GitHub repository ruleset rule master:
    • check-success = @github-actions/Queue validation
    • check-neutral = @github-actions/Queue validation
    • check-skipped = @github-actions/Queue validation
  • any of · required by GitHub repository ruleset rule master:
    • check-success = @github-actions/Verify workflow lockfile
    • check-neutral = @github-actions/Verify workflow lockfile
    • check-skipped = @github-actions/Verify workflow lockfile

Times in UTC · dashboard · how the merge queue works

tignear added a commit that referenced this pull request Oct 31, 2026
…ce files

`celox run -f rtlmeter.f` previously restarted preprocessing for every source,
so macros defined in a configuration header disappeared before later RTL files.
The CLI now treats its ordered source list as one compilation unit by default.
Definitions, undefinitions, directives and unit declarations carry forward;
relative includes resolve against their own source files. Lists accept .h,
.vh and .svh headers alongside .v/.sv sources, including a leading header.

Use --separate-units or single_unit = false in celox.toml to retain per-file
isolation; --single-unit overrides a project setting. Both run and vpi build
use the same selection. Rust source-list APIs keep their existing per-file
contract; syntax::preprocess_sources explicitly preprocesses a shared unit.

IEEE 1800-2023 3.12.1 requires both compilation models and leaves the default
to tools. Preserve file boundaries in expanded text with line directives. Separate tokens
introduced by expansions so a macro's unary minus followed by -1 remains
- -1, rather than becoming the decrement --1. Explicit token pastes remain
intact; macro substitution in based literals remains supported.

Closes #2128.

Validation: project_cli (20 passed), syntax crate (136 passed), compilation_units
(3 passed), analyzer syntax tests (7 passed), analyzer doctests, affected-crate
clippy and cargo fmt. With #2133, RTLmeter hello passes in four-state on E902
(native, 5392 cycles) and E906 (native and tiered, 9816 cycles). After the token
serialization fix, both designs retain their effective token streams (174054
and 497628 tokens; based-literal whitespace normalized per IEEE 5.7.1).

Change-Id: I9acd28e899919795f02894d6fcc118ef68667d63
@mergify
mergify Bot merged commit 0cb1011 into master Oct 31, 2026
29 checks passed
@mergify
mergify Bot deleted the feature/fix/2126-non-ansi-range-values branch October 31, 2026 11:29
@mergify mergify Bot removed the queued Mergify queue entry label Oct 31, 2026
@github-actions github-actions Bot mentioned this pull request Oct 31, 2026
tignear added a commit that referenced this pull request Oct 31, 2026
…ce files

`celox run -f rtlmeter.f` previously restarted preprocessing for every source,
so macros defined in a configuration header disappeared before later RTL files.
The CLI now treats its ordered source list as one compilation unit by default.
Definitions, undefinitions, directives and unit declarations carry forward;
relative includes resolve against their own source files. Lists accept .h,
.vh and .svh headers alongside .v/.sv sources, including a leading header.

Use --separate-units or single_unit = false in celox.toml to retain per-file
isolation; --single-unit overrides a project setting. Both run and vpi build
use the same selection. Rust source-list APIs keep their existing per-file
contract; syntax::preprocess_sources explicitly preprocesses a shared unit.

IEEE 1800-2023 3.12.1 requires both compilation models and leaves the default
to tools. Preserve file boundaries in expanded text with line directives. Separate tokens
introduced by expansions so a macro's unary minus followed by -1 remains
- -1, rather than becoming the decrement --1. Explicit token pastes remain
intact; macro substitution in based literals remains supported. Comments do not
terminate escaped identifiers: expansion boundaries insert actual whitespace
before comments, and EOF line comments end before an included file's caller.

Closes #2128.

Validation: project_cli (22 passed), syntax crate (137 passed), compilation_units
(3 passed), analyzer syntax tests (7 passed), analyzer doctests, affected-crate
clippy and cargo fmt. With #2133, RTLmeter hello passes in four-state on E902
(native, 5392 cycles) and E906 (native and tiered, 9816 cycles). After the token
serialization fix, both designs retain their effective token streams (174054
and 497628 tokens; based-literal whitespace normalized per IEEE 5.7.1).

Change-Id: I9acd28e899919795f02894d6fcc118ef68667d63
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.

SV: non-ANSI port and net ranges are compared as text, rejecting equal ranges (blocks rtlmeter E902/E906)

1 participant