Skip to content

Commit 66dadb6

Browse files
committed
Added dbNetwork::highestNetAbove(Net*) const override.
This is required to avoid a hang issue. Signed-off-by: Jaehyun Kim <[email protected]>
1 parent a0e03d3 commit 66dadb6

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

src/dbSta/include/db_sta/dbNetwork.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ class dbNetwork : public ConcreteNetwork
337337

338338
bool hasPort(const Net* net) const;
339339

340+
// Return the highest net above the given net.
341+
// - If the net is a flat net, return it.
342+
// - If the net is a hier net, return the modnet in the highest hierarchy.
343+
Net* highestNetAbove(Net* net) const override;
344+
340345
////////////////////////////////////////////////////////////////
341346
// Edit functions
342347
Instance* makeInstance(LibertyCell* cell,

src/dbSta/src/dbNetwork.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5024,4 +5024,36 @@ bool dbNetwork::isPGSupply(dbNet* net) const
50245024
return net->isSpecial() && net->getSigType().isSupply();
50255025
}
50265026

5027+
Net* dbNetwork::highestNetAbove(Net* net) const
5028+
{
5029+
if (net == nullptr) {
5030+
return nullptr;
5031+
}
5032+
5033+
dbNet* dbnet;
5034+
dbModNet* modnet;
5035+
staToDb(net, dbnet, modnet);
5036+
5037+
if (dbnet) {
5038+
// If a flat net, return it.
5039+
// - We should not return the highest modnet related to the flat net.
5040+
// - Otherwise, it breaks estimate_parasitics function.
5041+
// . est module uses flat nets for parasitic estimation
5042+
// . It has (highestNetAbove(flat_net) != flat_net) comparison.
5043+
// . If highestNetAbove(flat_net) returns the highest modnet, it
5044+
// changes the estimate_parasitics behavior.
5045+
return net;
5046+
}
5047+
5048+
if (modnet) {
5049+
if (dbNet* related_dbnet = modnet->findRelatedNet()) {
5050+
if (dbModNet* highest_modnet = related_dbnet->findModNetInHighestHier()) {
5051+
return dbToSta(highest_modnet); // Found the highest modnet
5052+
}
5053+
}
5054+
}
5055+
5056+
return net;
5057+
}
5058+
50275059
} // namespace sta

src/dbSta/test/cpp/TestDbSta.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,41 @@ TEST_F(TestDbSta, TestIsConnected)
5959

6060
bool_return = db_network_->isConnected(sta_net, sta_modnet);
6161
ASSERT_TRUE(bool_return);
62+
63+
// Check Network::highestNetAbove(Net* net)
64+
dbNet* dbnet_out2 = block_->findNet("out2");
65+
ASSERT_NE(dbnet_out2, nullptr);
66+
Net* sta_dbnet_out2 = db_network_->dbToSta(dbnet_out2);
67+
ASSERT_NE(sta_dbnet_out2, nullptr);
68+
Net* sta_highest_net = db_network_->highestNetAbove(sta_dbnet_out2);
69+
ASSERT_EQ(sta_highest_net, sta_dbnet_out2);
70+
71+
dbModNet* modnet_mod_out = block_->findModNet("sub_inst/mod_out");
72+
ASSERT_NE(modnet_mod_out, nullptr);
73+
Net* sta_modnet_mod_out = db_network_->dbToSta(modnet_mod_out);
74+
ASSERT_NE(sta_modnet_mod_out, nullptr);
75+
dbModNet* modnet_out2 = block_->findModNet("out2");
76+
ASSERT_NE(modnet_out2, nullptr);
77+
Net* sta_modnet_out2 = db_network_->dbToSta(modnet_out2);
78+
ASSERT_NE(sta_modnet_out2, nullptr);
79+
Net* sta_highest_modnet_out
80+
= db_network_->highestNetAbove(sta_modnet_mod_out);
81+
ASSERT_EQ(sta_highest_modnet_out, sta_modnet_out2);
82+
83+
// Check get_ports -of_object Net*
84+
NetTermIterator* term_iter = db_network_->termIterator(sta_dbnet_out2);
85+
while (term_iter->hasNext()) {
86+
Term* term = term_iter->next();
87+
Pin* pin = db_network_->pin(term);
88+
Port* port = db_network_->port(pin);
89+
ASSERT_EQ(db_network_->name(port), block_->findBTerm("out2")->getName());
90+
}
91+
92+
// Check dbBTerm::getITerm()
93+
dbBTerm* bterm_clk = block_->findBTerm("in1");
94+
ASSERT_NE(bterm_clk, nullptr);
95+
// There is no related dbITerm for a dbBTerm
96+
ASSERT_EQ(bterm_clk->getITerm(), nullptr);
6297
}
6398

6499
} // namespace sta

0 commit comments

Comments
 (0)