diff --git a/src/dbSta/include/db_sta/dbNetwork.hh b/src/dbSta/include/db_sta/dbNetwork.hh index 26e56d97d71..84e20f6e91e 100644 --- a/src/dbSta/include/db_sta/dbNetwork.hh +++ b/src/dbSta/include/db_sta/dbNetwork.hh @@ -202,6 +202,17 @@ class dbNetwork : public ConcreteNetwork // A bump's timing pin is its pad inst's single dbITerm (flat model); // nullptr for spare (unbound) bumps. odb::dbITerm* bumpPadITerm(odb::dbUnfoldedChipBumpInst* bump) const; + // The chip-net above a chiplet boundary, reached from the boundary port, the + // die-side net, or the bump's pad iterm. Null if the boundary is unbonded. + // This is the net a cross-die parasitic network is keyed on, and the net the + // 3D RCX bonds SPEF is written at. + // + // Read the bonds SPEF before the per-die SPEFs. A top-scope read replaces a + // net's parasitic network where a -path read merges into it, so the other + // order discards the die contributions without warning. + odb::dbChipNet* chipNetAbove(odb::dbBTerm* bterm) const; + odb::dbChipNet* chipNetAboveNet(const Net* net) const; + odb::dbChipNet* chipNetOfPadITerm(odb::dbITerm* iterm) const; // Raw chip-inst / chip-net -> their per-unfold-path objects (built in // setTopChip). Used by the chip-aware iterators to enumerate unfolded bumps. odb::dbUnfoldedChipInst* unfoldedChipInst(odb::dbChipInst* chip_inst) const; @@ -619,6 +630,8 @@ class dbNetwork : public ConcreteNetwork // raw chip-inst -> its unfolded chip-inst (for the pin iterator) // raw chip-net -> its unfolded chip-net (for the net-pin iterator) mutable odb::PtrMap bump_to_chip_net_; + // Die-side net -> the chip-net it reaches through one of its bump pads. + mutable odb::PtrMap net_to_chip_net_; mutable odb::PtrMap chip_inst_to_unfolded_; mutable odb::PtrMap diff --git a/src/dbSta/src/dbNetwork.cc b/src/dbSta/src/dbNetwork.cc index b2212362820..45e9b0dafce 100644 --- a/src/dbSta/src/dbNetwork.cc +++ b/src/dbSta/src/dbNetwork.cc @@ -930,6 +930,7 @@ void dbNetwork::clear() chip_master_cells_.clear(); chip_master_lib_ = nullptr; bump_to_chip_net_.clear(); + net_to_chip_net_.clear(); chip_inst_to_unfolded_.clear(); chip_net_to_unfolded_.clear(); } @@ -1073,6 +1074,7 @@ void dbNetwork::setTopChip(odb::dbChip* chip) block_to_chip_inst_.clear(); block_disc_.clear(); bump_to_chip_net_.clear(); + net_to_chip_net_.clear(); chip_inst_to_unfolded_.clear(); chip_net_to_unfolded_.clear(); unfolded_built_ = false; @@ -1197,6 +1199,19 @@ odb::dbChipInst* dbNetwork::chipInstOf(odb::dbBlock* block) const // ---- chip-object <-> STA-handle encode/decode ---- +// The single dbITerm of a chip bump's pad instance, or nullptr if the bump +// has no pad inst or the pad inst has no iterm. Does not check for a bound +// bterm; callers that need a logical endpoint do. +static odb::dbITerm* padITerm(odb::dbChipBump* chip_bump) +{ + odb::dbInst* pad_inst = chip_bump ? chip_bump->getInst() : nullptr; + if (pad_inst == nullptr) { + return nullptr; + } + dbSet iterms = pad_inst->getITerms(); + return iterms.empty() ? nullptr : *iterms.begin(); +} + // Resolve an unfolded bump to its pad inst's single dbITerm -- the bump's // timing pin (flat model: the pad iterm is the real leaf pin; it carries the // vertex id, its MTerm carries direction, and it sits directly on the @@ -1205,15 +1220,36 @@ odb::dbChipInst* dbNetwork::chipInstOf(odb::dbBlock* block) const odb::dbITerm* dbNetwork::bumpPadITerm(odb::dbUnfoldedChipBumpInst* bump) const { odb::dbChipBump* cb = bump->getChipBumpInst()->getChipBump(); - if (cb->getBTerm() == nullptr) { + return cb->getBTerm() == nullptr ? nullptr : padITerm(cb); +} + +odb::dbChipNet* dbNetwork::chipNetOfPadITerm(dbITerm* iterm) const +{ + if (iterm == nullptr) { return nullptr; } - odb::dbInst* pad_inst = cb->getInst(); - if (pad_inst == nullptr) { + ensureUnfoldedMapsFresh(); + auto it = bump_to_chip_net_.find(iterm); + return it == bump_to_chip_net_.end() ? nullptr : it->second; +} + +odb::dbChipNet* dbNetwork::chipNetAbove(dbBTerm* bterm) const +{ + return chipNetOfPadITerm(bterm ? padITerm(bterm->getChipBump()) : nullptr); +} + +odb::dbChipNet* dbNetwork::chipNetAboveNet(const Net* net) const +{ + dbNet* db_net = flatNet(net); + if (db_net == nullptr) { return nullptr; } - dbSet iterms = pad_inst->getITerms(); - return iterms.empty() ? nullptr : *iterms.begin(); + // Uses an index built in buildUnfoldedMaps. Delay calculation calls this per + // driver pin, so scanning the net's iterms would be O(fanout) every time -- + // including on big nets that never reach a bump. + ensureUnfoldedMapsFresh(); + auto it = net_to_chip_net_.find(db_net); + return it == net_to_chip_net_.end() ? nullptr : it->second; } void dbNetwork::buildUnfoldedMaps() const @@ -1221,6 +1257,7 @@ void dbNetwork::buildUnfoldedMaps() const chip_inst_to_unfolded_.clear(); chip_net_to_unfolded_.clear(); bump_to_chip_net_.clear(); + net_to_chip_net_.clear(); // raw chip-inst -> unfolded chip-inst (single-level: path is one element) for (odb::dbUnfoldedChipInst* uci : db_->getUnfoldedChipInsts()) { std::vector path = uci->getChipInstPath(); @@ -1240,6 +1277,9 @@ void dbNetwork::buildUnfoldedMaps() const for (odb::dbUnfoldedChipBumpInst* ub : ucn->getConnectedBumps()) { if (odb::dbITerm* pad_iterm = bumpPadITerm(ub)) { bump_to_chip_net_[pad_iterm] = chip_net; + if (dbNet* die_net = pad_iterm->getNet()) { + net_to_chip_net_[die_net] = chip_net; + } } } } @@ -2092,11 +2132,20 @@ Net* dbNetwork::net(const Pin* pin) const return dbToSta(dnet); } } - // only pins which act as bterms are top levels and have no net + // A bterm pin is a top-level port and has no net, except on a chiplet + // boundary. if (bterm) { - // dbNet* dnet = bterm -> getNet(); - // return dbToSta(dnet); - ; + // Return the chip-net above the boundary, not the die-side net below it. + // SpefReader::dspfBegin climbs term -> pin -> net to find which net owns a + // parasitic network, so this has to move up a level. Returning the die-side + // net would make that climb return where it started, and the unguarded + // recursions in ReportPath::hierPinsAbove and Network::hierarchyLevel then + // overflow the stack. + if (has3DicChip()) { + if (odb::dbChipNet* chip_net = chipNetAbove(bterm)) { + return dbToSta(chip_net); + } + } } if (moditerm) { if (odb::dbModNet* mnet = moditerm->getModNet()) { @@ -2748,15 +2797,25 @@ void dbNetwork::visitConnectedPins(const Net* net, // Caution: //- Network::highestConnectedNet(Net *net) retrieves the highest hierarchical // net connected to the given net. -// - But `dbNetwork::highestConnectedNet(Net* net)` retrieves the corresponding -// flat net for the given net. +// - `dbNetwork::highestConnectedNet(Net* net)` retrieves the corresponding +// flat net for the given net. On a 3DIC design it returns the dbChipNet above +// a bonded die-side net instead, which is neither a dbNet nor a dbModNet. // - It behaves differently to cope with the issue 9724. // - This redefinition may cause another issue later when // `Network::highestConnectedNet(Net *net)` is used elsewhere. const Net* dbNetwork::highestConnectedNet(const Net* net) const { const Net* flat = findFlatNet(net); - return flat ? flat : net; + const Net* highest = flat ? flat : net; + // A cross-die net's parasitics are merged into one network keyed on the + // chip-net. Parasitics::findParasiticNet looks parasitics up through here, so + // returning the chip-net is what lets a driver on either die find them. + if (has3DicChip()) { + if (odb::dbChipNet* chip_net = chipNetAboveNet(highest)) { + return dbToSta(chip_net); + } + } + return highest; } //////////////////////////////////////////////////////////////// @@ -3756,9 +3815,17 @@ void dbNetwork::staToDb(const Instance* instance, dbNet* dbNetwork::staToDb(const Net* net) const { - dbNet* db_net = reinterpret_cast(const_cast(net)); - assert(!db_net || db_net->getObjectType() == odb::dbNetObj); - return db_net; + if (net == nullptr) { + return nullptr; + } + // net(pin) returns a dbChipNet on a chiplet boundary, so a caller expecting + // a flat net can arrive here with one. Check the type through the common + // base before casting. + dbObject* obj = reinterpret_cast(const_cast(net)); + if (obj->getObjectType() != odb::dbNetObj) { + return nullptr; + } + return reinterpret_cast(obj); } dbNet* dbNetwork::flatNet(const Net* net) const @@ -4678,9 +4745,7 @@ bool dbNetwork::isConnected(const Net* net, const Pin* pin) const if (iterm == nullptr) { return false; } - ensureUnfoldedMapsFresh(); - auto it = bump_to_chip_net_.find(iterm); - return it != bump_to_chip_net_.end() && it->second == chip_net; + return chipNetOfPadITerm(iterm) == chip_net; } dbNet* dbnet; @@ -6025,6 +6090,16 @@ const Net* dbNetwork::highestNetAbove(const Net* net) const staToDb(net, dbnet, modnet); if (dbnet) { + // Must return the same net as highestConnectedNet. ensureParasiticNode + // marks a node external when highestNetAbove(net(pin)) differs from the + // network's net, so returning the die-side net here would mark every node + // of a merged cross-die network external -- the node_count_ = 0 crash + // described below, reproducible with -delay_calculator arnoldi. + if (has3DicChip()) { + if (odb::dbChipNet* chip_net = chipNetAboveNet(net)) { + return dbToSta(chip_net); + } + } // If a flat net, return it. // - We should not return the highest modnet related to the flat net. // - Otherwise, it breaks estimate_parasitics function. diff --git a/src/dbSta/test/3dic_cross.ok b/src/dbSta/test/3dic_cross.ok index 4116c871a92..bd2bbdc31fe 100644 --- a/src/dbSta/test/3dic_cross.ok +++ b/src/dbSta/test/3dic_cross.ok @@ -23,19 +23,18 @@ Net chipA/q Pin capacitance: 0.88-0.97 Wire capacitance: 0.00 Total capacitance: 0.88-0.97 - Number of drivers: 2 - Number of loads: 1 - Number of pins: 2 + Number of drivers: 3 + Number of loads: 2 + Number of pins: 3 Driver pins chipA/buf/Z output (BUF_X1) (13, 6) chipA/bump_q/PAD bidirect (BUMP) (4, 4) + chipB/bump_d/PAD bidirect (BUMP) (4, 4) Load pins chipA/bump_q/PAD bidirect (BUMP) (4, 4) - -Hierarchical pins - chipA/q output + chipB/bump_d/PAD bidirect (BUMP) (4, 4) Net chipA/ext Pin capacitance: 0.00 diff --git a/src/dbSta/test/3dic_spef.a.spef b/src/dbSta/test/3dic_spef.a.spef new file mode 100644 index 00000000000..dd00a33179e --- /dev/null +++ b/src/dbSta/test/3dic_spef.a.spef @@ -0,0 +1,27 @@ +// chipA side of the bond net: driver out to the bump pad. +*SPEF "IEEE 1481-1999" +*DESIGN "flop_chip_a" +*DATE "Tue Aug 19 00:00:00 2026" +*VENDOR "The OpenROAD Project" +*PROGRAM "OpenROAD" +*VERSION "test" +*DESIGN_FLOW "NAME_SCOPE LOCAL" "PIN_CAP NONE" +*DIVIDER / +*DELIMITER : +*BUS_DELIMITER [] +*T_UNIT 1 NS +*C_UNIT 1 FF +*R_UNIT 1 OHM +*L_UNIT 1 HENRY + +*D_NET q 2 +*CONN +*I buf:Z O +*I bump_q:PAD I +*CAP +1 q:1 1 +2 bump_q:PAD 1 +*RES +1 buf:Z q:1 10 +2 q:1 bump_q:PAD 10 +*END diff --git a/src/dbSta/test/3dic_spef.b.spef b/src/dbSta/test/3dic_spef.b.spef new file mode 100644 index 00000000000..8b6dfc7ce1a --- /dev/null +++ b/src/dbSta/test/3dic_spef.b.spef @@ -0,0 +1,27 @@ +// chipB side of the bond net: bump pad in to the receiver. +*SPEF "IEEE 1481-1999" +*DESIGN "flop_chip_b" +*DATE "Tue Aug 19 00:00:00 2026" +*VENDOR "The OpenROAD Project" +*PROGRAM "OpenROAD" +*VERSION "test" +*DESIGN_FLOW "NAME_SCOPE LOCAL" "PIN_CAP NONE" +*DIVIDER / +*DELIMITER : +*BUS_DELIMITER [] +*T_UNIT 1 NS +*C_UNIT 1 FF +*R_UNIT 1 OHM +*L_UNIT 1 HENRY + +*D_NET d 100 +*CONN +*I bump_d:PAD I +*I buf:A I +*CAP +1 d:1 50 +2 buf:A 50 +*RES +1 bump_d:PAD d:1 10 +2 d:1 buf:A 10 +*END diff --git a/src/dbSta/test/3dic_spef.bonds.spef b/src/dbSta/test/3dic_spef.bonds.spef new file mode 100644 index 00000000000..a42db4b3e51 --- /dev/null +++ b/src/dbSta/test/3dic_spef.bonds.spef @@ -0,0 +1,25 @@ +// The die-to-die bond itself, at top scope: one resistor between the two bump +// pad pins, named /: the way the 3D RCX writer +// names them. +*SPEF "IEEE 1481-1999" +*DESIGN "top" +*DATE "Tue Aug 19 00:00:00 2026" +*VENDOR "The OpenROAD Project" +*PROGRAM "OpenROAD" +*VERSION "test" +*DESIGN_FLOW "NAME_SCOPE LOCAL" "PIN_CAP NONE" +*DIVIDER / +*DELIMITER : +*BUS_DELIMITER [] +*T_UNIT 1 NS +*C_UNIT 1 FF +*R_UNIT 1 OHM +*L_UNIT 1 HENRY + +*D_NET bridge 0 +*CONN +*I chipA/bump_q:PAD B +*I chipB/bump_d:PAD B +*RES +1 chipA/bump_q:PAD chipB/bump_d:PAD 2000 +*END diff --git a/src/dbSta/test/3dic_spef.ok b/src/dbSta/test/3dic_spef.ok new file mode 100644 index 00000000000..27d8e216035 --- /dev/null +++ b/src/dbSta/test/3dic_spef.ok @@ -0,0 +1,46 @@ +[INFO ODB-0227] LEF file: ../../odb/test/Nangate45/Nangate45_tech.lef, created 22 layers, 27 vias +[INFO ODB-0227] LEF file: ../../odb/test/Nangate45/Nangate45_stdcell.lef, created 135 library cells +[INFO ODB-0227] LEF file: ../../odb/test/Nangate45/fake_bumps.lef, created 1 library cells +[INFO ODB-0128] Design: flop_chip_a +[INFO ODB-0130] Created 1 pins. +[INFO ODB-0252] Updated 3 pins. +[INFO ODB-0131] Created 3 components and 14 component-terminals. +[INFO ODB-0133] Created 6 nets and 7 connections. +[WARNING STA-1140] ../../odb/test/Nangate45/Nangate45_typ.lib line 37, library NangateOpenCellLibrary already exists. +[INFO ODB-0128] Design: flop_chip_b +[INFO ODB-0252] Updated 3 pins. +[INFO ODB-0131] Created 3 components and 14 component-terminals. +[INFO ODB-0133] Created 5 nets and 7 connections. +Found 11 unannotated drivers. +Found 0 partially unannotated drivers. +Startpoint: chipA/ff (rising edge-triggered flip-flop clocked by clk) +Endpoint: chipB/ff (rising edge-triggered flip-flop clocked by clk) +Path Group: clk +Path Type: max + + Cap Delay Time Description +---------------------------------------------------------------- + 0.00 0.00 clock clk (rise edge) + 0.00 0.00 clock network delay (ideal) + 0.00 0.00 ^ chipA/ff/CK (DFF_X1) + 1.55 0.08 0.08 v chipA/ff/Q (DFF_X1) + 0.97 0.01 0.09 ^ chipA/inv/ZN (INV_X1) + 102.97 0.08 0.17 ^ chipA/buf/Z (BUF_X1) + 1.70 0.25 0.42 ^ chipB/buf/Z (BUF_X1) + 1.06 0.01 0.43 v chipB/inv/ZN (INV_X1) + 0.00 0.43 v chipB/ff/D (DFF_X1) + 0.43 data arrival time + + 1.00 1.00 clock clk (rise edge) + 0.00 1.00 clock network delay (ideal) + 0.00 1.00 clock reconvergence pessimism + 1.00 ^ chipB/ff/CK (DFF_X1) + -0.04 0.96 library setup time + 0.96 data required time +---------------------------------------------------------------- + 0.96 data required time + -0.43 data arrival time +---------------------------------------------------------------- + 0.54 slack (MET) + + diff --git a/src/dbSta/test/3dic_spef.tcl b/src/dbSta/test/3dic_spef.tcl new file mode 100644 index 00000000000..2b968fa94ea --- /dev/null +++ b/src/dbSta/test/3dic_spef.tcl @@ -0,0 +1,24 @@ +# Cross-die parasitics. One bond net arrives as three SPEF pieces -- chipA's +# wiring (2 fF), the die-to-die bond resistor (2 kohm), and chipB's wiring +# (100 fF). read_spef must merge them onto the chip-net so chipA's driver sees +# the far die's load through the bond; without that it sees only its own 2 fF +# and the path delay collapses from ~0.41 ns to ~0.15 ns. +# +# The bonds SPEF is top-scope and must be read first: a top-scope read replaces +# the net's parasitic network, while a -path read merges into it. +# +# The hierarchical_pin report at the end is a regression guard: it walks +# term -> pin -> net, which must ascend to the chip-net. If it ever resolves +# back to the die-side net the walk becomes a self-loop and this crashes. +source "helpers.tcl" + +read_3dbx 3dic_cross.3dbx + +create_clock -name clk -period 1.0 [get_pins -of_objects [get_nets clk_top]] + +read_spef 3dic_spef.bonds.spef +read_spef -path chipA 3dic_spef.a.spef +read_spef -path chipB 3dic_spef.b.spef + +report_parasitic_annotation +report_checks -path_delay max -group_path_count 1 -fields {cap hierarchical_pin} diff --git a/src/dbSta/test/BUILD b/src/dbSta/test/BUILD index d0d3a32f1fa..78e9b45e53f 100644 --- a/src/dbSta/test/BUILD +++ b/src/dbSta/test/BUILD @@ -28,6 +28,7 @@ ALL_TESTS = [ "3dic_cross", "3dic_get_cells", "3dic_read_db", + "3dic_spef", "block_sta1", "check_axioms", "clock_pin", @@ -131,6 +132,20 @@ filegroup( ], ) +# The two-chiplet 3DIC fixture, shared by every test that reads 3dic_cross.3dbx. +# 3dic_cross itself omits the .3dbx because its own test_name + ".*" glob +# already picks it up. +_3DIC_CROSS_FIXTURES = [ + "//src/odb/test:regression_resources", + "3dic_cross.3dbx", + "3dic_cross_flop.3dbv", + "3dic_cross_flop_a.bmap", + "3dic_cross_flop_a.def", + "3dic_cross_flop_b.bmap", + "3dic_cross_flop_b.def", + "3dic_cross_top.v", +] + [ filegroup( name = test_name + "_resources", @@ -151,17 +166,10 @@ filegroup( "3dic_get_cells": [ "//src/odb/test:regression_resources", ], - "3dic_read_db": [ - "//src/odb/test:regression_resources", - "3dic_cross.3dbx", - "3dic_cross_flop.3dbv", - "3dic_cross_flop_a.bmap", - "3dic_cross_flop_a.def", - "3dic_cross_flop_b.bmap", - "3dic_cross_flop_b.def", - "3dic_cross_top.v", + "3dic_read_db": _3DIC_CROSS_FIXTURES + [ "3dic_read_db_reload.tcl", ], + "3dic_spef": _3DIC_CROSS_FIXTURES, "block_sta1": [ "example1_typ.lib", "example1.def",