Skip to content

get_fanin/get_fanout: flatten the pins of net arguments - #460

Open
NopeCharon wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
NopeCharon:fanin-fanout-net-args
Open

NopeCharon wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
NopeCharon:fanin-fanout-net-args

Conversation

@NopeCharon

Copy link
Copy Markdown

Fixes #457.

For net arguments, get_fanin and get_fanout added the net's pins with lappend pins $net_pins and lappend pins [net_load_pins $net]. That appends the whole pin list as one nested element. When the list is converted to a PinSeq, only one of those pins survives, so the traversal started from too few pins. For example, get_fanout -from [get_nets n1] dropped a register that n1 drives directly. Both commands now use concat, so every pin of the net is used.

get_fanout also read keys(-from) without checking that it exists. Calling it without -from raised can't read "keys(-from)"; it now reports the usage message, as get_fanin does for a missing -to.

The new search_fanin_fanout_nets test uses a small design whose nets have several loads. It checks net, multi-net, -only_cells, -flat -endpoints_only and -startpoints_only results, plus the missing -from case. On current master the net fanouts miss reg1/D/reg1, get_fanin -to the net misses the net's load pins, and the last case raises the Tcl error.

ctest -L tcl passes; no existing golden changes.

For net arguments get_fanin appended "net_pins" and get_fanout appended
"net_load_pins" to the pin list with lappend, which adds the net's pins
as one nested element. When the list is converted to a PinSeq only one
of those pins survives, so the traversal started from too few pins. For
example, the fanout of a net driving two registers dropped one of them.
Use concat so every pin of the net is used.

get_fanout also read keys(-from) without checking that it exists, so
calling it without -from raised a raw Tcl error. Report the usage
message like get_fanin does for a missing -to.

Add search_fanin_fanout_nets, which compares net and multi-net fanin
and fanout results on a design whose nets have several loads.

Fixes The-OpenROAD-Project#457

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new test case fanin_fanout_nets to verify get_fanin and get_fanout behavior on nets connecting to multiple pins, and updates tcl/Sta.tcl to ensure the -from argument is provided for get_fanout. It also changes list appending from lappend to concat. The reviewer pointed out that using concat inside a loop is a performance anti-pattern in Tcl resulting in quadratic complexity, and suggested using lappend with the expansion operator {*} instead for $O(1)$ amortized in-place appending.

Comment thread tcl/Sta.tcl
set net_pins [net_pins $net]
if { $net_pins != {} } {
lappend pins $net_pins
set pins [concat $pins $net_pins]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using set pins [concat $pins $net_pins] inside a loop is a performance anti-pattern in Tcl. Since concat creates a new list and copies all elements, doing this in a loop results in quadratic $O(N^2)$ complexity. Using lappend with the expansion operator {*} appends the elements in-place, which is significantly faster ($O(1)$ amortized per append) and avoids unnecessary memory allocations.

      lappend pins {*}$net_pins

Comment thread tcl/Sta.tcl
parse_port_pin_net_arg $keys(-from) pins nets
foreach net $nets {
lappend pins [net_load_pins $net]
set pins [concat $pins [net_load_pins $net]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using set pins [concat $pins [net_load_pins $net]] inside a loop is a performance anti-pattern in Tcl. Since concat creates a new list and copies all elements, doing this in a loop results in quadratic $O(N^2)$ complexity. Using lappend with the expansion operator {*} appends the elements in-place, which is significantly faster ($O(1)$ amortized per append) and avoids unnecessary memory allocations.

    lappend pins {*}[net_load_pins $net]

EMinsight pushed a commit to EMinsight/OpenSTA that referenced this pull request Nov 10, 2026
…le (The-OpenROAD-Project#460)

* Use more reliable mirrors for Bison and TCL in CentOS 7 Dockerfile.

ftp.gnu.org and SourceForge prdownloads are flaky in CI; switch to
dotsrc and OSUOSL mirrors.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Use GNU ftpmirror and SourceForge project URLs.

Switch CentOS 7 Dockerfile downloads to the reviewer-suggested
ftpmirror.gnu.org redirector for Bison and the SourceForge project
download URL for TCL.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_fanin/get_fanout drop pins of nets with more than one pin

2 participants