-hier: parasitics wrong for nets on a top-level port that connect into a submodule (read_spef drops net, *D_NET too low)

Abierto
#11,574 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@dsengupta0628 ya está trabajando en esto.

Desde el 29/9/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

dbSta
Describe the bug
Describe the bug

With link_design -hier, parasitics are handled wrongly for a net on a top-level port that also connects into a submodule. I see two symptoms.

  1. read_spef silently drops the whole net. After reading a SPEF into a -hier design, the net has wire capacitance 0 and its driver is reported as unannotated. read_spef prints no warning. The same file read into the flat-linked design annotates correctly.
  2. The pin node for the top-level port is wrongly flagged external. This makes the *D_NET total written by estimate_parasitics -spef_file too low. The node's capacitance is still written in *CAP, so the two disagree. The external flag is also read by the Arnoldi and Prima delay calculators.

Hierarchy should not change capacitance, and in flat mode both symptoms go away. The in-memory RC network from estimate_parasitics is identical in the two modes; only the external flag on the port node differs.

Both symptoms are present before and after https://github.com/The-OpenROAD-Project/OpenROAD/pull/11552. That PR only changed which pin-node *CAP entries get written.

Test case: est_rc2 from src/grt/test, with r1 and u2 moved into a submodule h1. Net in1 goes from top port in1 through module port h1/in1 to h1/r1/D:

 top
 ┌──────────────────────────────────────────────┐
 │                  h1 : sub                    │
 │               ┌───────────────────────┐      │
 in1 ●───────────┼──●────────────► r1/D  │      │   net in1: broken in -hier
 (top port)      │ h1/in1                │      │
 │               │ (module port)         │      │
 │               └───────────────────────┘      │
 │                                              │
 in2 ●────────────────────────────► r2/D        │   net in2: fine (top level only)
 └──────────────────────────────────────────────┘

Symptom 1: read_spef. The same flat.spef is read into each link mode, followed by report_net in1:

link_design top link_design -hier top
Wire capacitance 0.776778 0.000000
Total capacitance 1.839120–1.917068 1.062342–1.140290 (the h1/r1/D Liberty pin cap only)
report_parasitic_annotation -report_unannotated in1 annotated in1 unannotated
Warnings from read_spef none none

Every other net annotates correctly in -hier. For example, in2 (top-level only) reads back 1.770961. The other unannotated drivers (h1/r1/QN, r2/QN, r3/QN) are unconnected outputs and show up in both modes.

Symptom 2: the *D_NET total. This is estimate_parasitics -global_routing -spef_file, net in1:

flat:                          -hier:
*D_NET in1 0.776778            *D_NET in1 0.719166      <- 0.0576124 low
*CAP                           *CAP
1 in1 0.0576124                1 in1 0.0576124          <- port pin node
2 h1/r1:D 0.0289813            2 h1/r1:D 0.0289813
3 in1:1 0.132077               3 in1:1 0.132077
4 in1:2 0.074465               4 in1:2 0.074465
5 in1:3 0.22733                5 in1:3 0.22733
6 in1:4 0.256312               6 in1:4 0.256312
                               (sum 0.776778 != 0.719166)

The *CAP sections are identical. The -hier total is lower by exactly the capacitance on the in1 port pin node.

Root cause (symptom 2)

The external flag on a pin node is set in ConcreteParasiticNetwork::ensureParasiticNode(const Pin*) in src/sta/parasitics/ConcreteParasitics.cc:

Net *net = network->net(pin);
if (net == nullptr && network->isTopLevelPort(pin)) {
  Term *term = network->term(pin);
  if (term)
    net = network->net(term);          // (A) top-level port: not normalized
}
else if (net)
  net = network->highestNetAbove(net); // (B) other pins: normalized
node = new ConcreteParasiticNode(pin, net != net_);  // is_external
flowchart TD
    S["ensureParasiticNode(port in1)"] --> Q{"top-level port?"}
    Q -- yes --> A["(A) net = net(term)"]
    Q -- no --> B["(B) net = highestNetAbove(net(pin))<br/>modnet → flat net"]
    A --> M{"link mode"}
    M -- flat --> F["dbNet in1 == net_<br/>internal ✅"]
    M -- "-hier" --> H["dbModNet (bterm->getModNet())<br/>!= net_ → external ❌"]
    style H fill:#f8d7da,stroke:#b02a37,color:#000
  • In -hier, dbNetwork::net(const Term*) (src/dbSta/src/dbNetwork.cc) returns bterm->getModNet() when one exists. A TODO there says it should always return the flat net.
  • net_ is the flat net, so branch (A) marks the port node external.
  • Branch (B) doesn't have this problem, because dbNetwork::highestNetAbove() maps a modnet to its related flat net. That was the fix for the earlier PRIMA crash (the "isExternal issue fix to resolve crash in PRIMA delay calc" commit).

External nodes are skipped by:

reader effect
ConcreteParasiticNetwork::capacitance() left out of the total, which is the *D_NET value
ArnoldiReduce.cc left out of the reduction
PrimaDelayCalc.cc left out of the network walk (including the driver node)
Parasitics.cc reports tagged (ext)

I haven't confirmed a timing difference with Arnoldi or Prima. In this test the port is the net's driver, and those calculators appear to use only the pin cap there.

Root cause (symptom 1): not yet traced

Losing the whole net doesn't fit "one node flagged external", which would lose only the 0.0576 on the port node. My guess is a net mismatch between where SpefReader stores the parasitic and where the driver lookup for in1 looks in -hier (flat net vs modnet). That would be the same dbNetwork::net(term) behavior reached by a different path, but I haven't verified it. SpefReader creates pin nodes through the same ensureParasiticNode(pin).

Possible fixes (symptom 2)
# fix notes
1 Write *D_NET in SpefWriter as the sum of the *CAP entries Only fixes the file. The node stays wrongly external for Arnoldi/Prima. Rejected
2 Call highestNetAbove() in branch (A) One line in OpenSTA. A no-op for OpenSTA's own network, so it's redundant from OpenSTA's point of view, but it makes (A) consistent with (B). Needs upstream acceptance
3 Make dbNetwork::highestNetAbove() return the modnet in -hier Many changes (EST keys by dbNet in flat and by dbModNet in hier, plus dbNetwork and SpefWriter); risks bringing back the PRIMA issue
4 is_external = net == nullptr || !network->isConnected(net, net_) OpenSTA change. dbNetwork::isConnected(Net*, Net*) returns early on equality and otherwise compares flat nets, so it should be cheap in OpenROAD. The base Network::isConnected traverses
5 Make dbNetwork::net(const Term*) return the flat net (the existing TODO) OpenROAD-only. The TODO says the Verilog writer depends on the modnet

It's still open whether fix 2 or 4 also fixes symptom 1.

Expected Behavior
  • -hier and flat give the same parasitics for every net.
  • read_spef into a -hier design annotates in1 with wire capacitance 0.776778, the same as flat.
  • The in1 port pin node is not external, so the *D_NET total for in1 is 0.776778 in both modes and equals the sum of its *CAP entries.
Additional Context
  • Only tested with the top-level port as the net's driver (an input port). An output port fed from inside a submodule goes through the same branch and is expected to behave the same way, but I haven't checked it.
  • This matters most for flows that load an external SPEF into a -hier design, such as RCX output with read_spef. In the normal estimated-parasitics flow the RC network goes to STA in memory, where it is correct apart from the external flag.
Expected Behavior

-hier and flat give the same parasitics for every net.

Environment
--This is too big---
To Reproduce
To Reproduce

Attached: https://drive.google.com/file/d/1SdEGggmlG8LQ-_UVgyW0a2_01epUvyDC/view?usp=drive_link hier_port_parasitics_repro.tar.gz (hier.v, hier.def, run.tcl). Run it from a directory that has a Nangate45 symlink to test/Nangate45. hier.def is src/grt/test/est_rc2.def with r1 renamed to h1/r1 and u2 to h1/u2, and with the NETS section removed; connectivity comes from hier.v.

ln -s <OpenROAD>/test/Nangate45 Nangate45
LINK_FLAG=""      MODE=flat openroad -no_splash -no_init -exit run.tcl   # writes flat.spef; run first
LINK_FLAG="-hier" MODE=hier openroad -no_splash -no_init -exit run.tcl

run.tcl:

read_lef Nangate45/Nangate45.lef
read_liberty Nangate45/Nangate45_typ.lib
read_verilog hier.v
link_design {*}$::env(LINK_FLAG) top
read_def -floorplan_initialize hier.def
set_routing_layers -signal metal2-metal10
global_route
estimate_parasitics -global_routing -spef_file $::env(MODE).spef
puts "=== estimated (in memory)"
report_net -digits 6 in1
read_spef flat.spef
puts "=== after read_spef flat.spef"
report_net -digits 6 in1
report_parasitic_annotation -report_unannotated

hier.v:

module sub (in1, a2, ck, zn);
  input in1, a2, ck;
  output zn;
  wire r1q;
  DFF_X1 r1 (.D(in1), .CK(ck), .Q(r1q));
  AND2_X1 u2 (.A1(r1q), .A2(a2), .ZN(zn));
endmodule

module top (clk, in1, in2, out);
  input clk, in1, in2;
  output out;
  wire r2q, u2z, clknet_0_clk, clknet_1_0_0_clk, clknet_1_1_0_clk;
  sub h1 (.in1(in1), .a2(r2q), .ck(clknet_1_0_0_clk), .zn(u2z));
  DFF_X1 r2 (.D(in2), .CK(clknet_1_0_0_clk), .Q(r2q));
  DFF_X1 r3 (.D(u2z), .CK(clknet_1_1_0_clk), .Q(out));
  BUF_X4 clkbuf_0_clk (.A(clk), .Z(clknet_0_clk));
  CLKBUF_X1 clkbuf_1_0_0_clk (.A(clknet_0_clk), .Z(clknet_1_0_0_clk));
  CLKBUF_X1 clkbuf_1_1_0_clk (.A(clknet_0_clk), .Z(clknet_1_1_0_clk));
endmodule
Relevant log output
# -hier run
[WARNING ORD-0011] Hierarchical flow (-hier) is currently in development and may cause multiple issues. Do not use in production environments.
=== estimated (in memory)
 Wire capacitance: 0.776778
 Total capacitance: 1.839121-1.917068
=== after read_spef flat.spef
 Wire capacitance: 0.000000
 Total capacitance: 1.062342-1.140290
Found 4 unannotated drivers.
 in1
 h1/r1/QN
 r2/QN
 r3/QN
Found 0 partially unannotated drivers.
Screenshots

No response

Additional Context

No response

Lenguaje dominante
Verilog
Estrellas
3.4k
Forks
1.1k
Merge medio
3 d 11 h
PR fusionados (30 d)
245

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de The-OpenROAD-Project/OpenROAD

Todos los issues de The-OpenROAD-Project/OpenROAD

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.