Skip to content

fix(sv): keep the bit ranges a child reads from its input ports - #1960

Merged
mergify[bot] merged 1 commit into
masterfrom
feature/fix/1955-port-bit-ranges
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feature/fix/1955-port-bit-ranges

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1955.

What

A combinational path through a child module's input port lost bit precision, so Celox reported a combinational loop that does not exist. Written in a single module, the same logic simulates. rtlmeter's C906 hits this between aq_ifu_pcgen and aq_ifu_btb. A minimal repro:

module Btb(input logic [7:0] ifpc_in, output logic [7:0] tar);
    logic [3:0] tgt = 4'h9;
    assign tar = {ifpc_in[7:4], tgt};
endmodule
module Top;
    ...
    assign fetch = tar;
    always @(posedge clk) ifpc <= fetch;
    assign ifpc_out = {ifpc[7:4], fetch[3:0]};
    Btb b(.ifpc_in(ifpc_out), .tar(tar));

Before: Combinational loop detected: tar[7:0] -> b.tar[7:0] -> b.ifpc_in[7:4] -> ifpc_out[7:0] -> fetch[3:0]. Icarus and Verilator print 59.

Why

Flattening atomizes combinational paths at the bit boundaries each variable is accessed at (propagate_boundaries → atomize_logic_paths). Boundaries cross port connections in both directions for output ports, but only parent → child for input ports. The child reads ifpc_in[7:4], but the parent's ifpc_out never got the boundary at bit 4. It stayed one node ifpc_out[7:0], which depends on fetch[3:0], and that closed the cycle. In one module the read ifpc_out[7:4] itself gives the boundary.

Fix

propagate_boundaries now also propagates the child port's boundaries to the parent variable when the input connection is a single range as wide as the port. They are mapped onto that range, so .ifpc_in(x[11:4]) splits x at 8. Other connection expressions keep the current behavior.

Validation

  • Shared cases hierarchy::child_ports_keep_the_bit_ranges_they_read (the repro) and hierarchy::child_ports_keep_the_bit_ranges_of_selected_connections (a part-select connection) pass on every Celox backend, verify-sv-icarus 2/2 and verify-sv-verilator 2/2.
  • cargo nextest run -p celox -p celox-frontend-core -p celox-frontend-sv -p celox-frontend-veryl -p celox-test-suite -p celox-vpi --features celox/systemverilog: 14595 passed. retained_reports passes; sv-tests verdicts are unchanged. Clippy (workspace, all targets) and fmt are clean.

Performance

Callgrind, release profile, b2_vm_dispatch_bit.sv (200k cycles), master de79c93 vs this branch: simulation (step_until, inclusive) is identical at 4,188,404,075. The whole process is 51,003,705,225 vs 51,003,789,351 (+0.0002%).

Flattening splits combinational paths at the bit boundaries each
variable is accessed at, and propagates boundaries across port
connections. Input ports only passed the parent's boundaries to the
child, so where a child read its input port in parts the connected parent
variable stayed one range. A parent that fed other bits of the child's
output back into that variable then formed a combinational loop that
does not exist; written in one module, the same logic simulates.

The boundaries of the child port now propagate to the parent variable
when the connection is one range as wide as the port, mapped onto that
range, so the parent is split as it is when it reads the bits itself.

Closes #1955

Change-Id: I24f244b6bb1f0b940eef0f1fbae08573ca011747
@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-25T04:29:45.395702Z
We couldn’t complete this review. Comment @codex review to try again.
7972552 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

This pull request spent 40 minutes 38 seconds in the queue, including 39 minutes 10 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 95b8742 into master Oct 25, 2026
23 checks passed
@mergify
mergify Bot deleted the feature/fix/1955-port-bit-ranges branch October 25, 2026 07:11
@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.

fix(sv): keep bit ranges of child output port dependencies in loop detection

1 participant