Repository navigation
fix(sv): compare the bounds, not the spelling, of non-ANSI port ranges - #2133
Merged
Merged
Conversation
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
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Change-Id: I1b666c99bf3bec2c6ea31960c88f76d9c5286bc0
Contributor
✅ Merged into
|
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
This was referenced Oct 31, 2026
Closed
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;andwire [CLICINTNUM-1:0] busif_kid_clicintattr_sel;withCLICINTNUM= 64+16, and the compile failed.The parser cannot evaluate parameters, so the check moves to elaboration:
Port::declared_type.ports_from_scopeevaluates 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 ofxdiffer".Closes #2126.
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_declarationsalso rejects ranges that differ through a parameter (input [3:0] a; wire [N-1:0] a;with N = 8).Verification
fffffffffffffffffffffor 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-analyzerwith CI's features: 16165 passed. clippy (workspace minus lydite,--all-targets -D warnings): clean.retained_reports: passed.prepare.py): identical toconformance/sv-tests/expected.tsv.--backend native, two runs each):step_until4,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.