Skip to content

Commit dd7a99f

Browse files
authored
Merge pull request #8753 from The-OpenROAD-Project-staging/secure-fix-bus-port-io-type
dbSta: Fixed wrong dbModBTerm direction for bus port
2 parents 4534556 + cc542cd commit dd7a99f

File tree

11 files changed

+315
-100
lines changed

11 files changed

+315
-100
lines changed

src/dbSta/src/dbNetwork.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4544,6 +4544,7 @@ void dbNetwork::checkSanityNetConnectivity(odb::dbObject* obj) const
45444544
// Check for hier net and flat net connectivity
45454545
dbSet<dbModNet> mod_nets = block()->getModNets();
45464546
for (dbModNet* mod_net : mod_nets) {
4547+
mod_net->checkSanity();
45474548
findRelatedDbNet(mod_net);
45484549
}
45494550

src/dbSta/src/dbReadVerilog.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ void Verilog2db::makeModBTerms(Cell* cell, dbModule* module)
438438
std::unique_ptr<CellPortIterator> cp_iter{network_->portIterator(cell)};
439439
while (cp_iter->hasNext()) {
440440
Port* port = cp_iter->next();
441+
const dbIoType io_type = staToDb(network_->direction(port));
441442
if (network_->isBus(port)) {
442443
// make the bus port as part of the port set for the cell.
443444
const char* port_name = network_->name(port);
@@ -447,7 +448,6 @@ void Verilog2db::makeModBTerms(Cell* cell, dbModule* module)
447448
network_->fromIndex(port),
448449
network_->toIndex(port));
449450
bmodterm->setBusPort(dbbusport);
450-
const dbIoType io_type = staToDb(network_->direction(port));
451451
bmodterm->setIoType(io_type);
452452

453453
//
@@ -475,12 +475,11 @@ void Verilog2db::makeModBTerms(Cell* cell, dbModule* module)
475475
dbbusport->setLast(modbterm);
476476
}
477477
dbIoType io_type = staToDb(network_->direction(port));
478-
bmodterm->setIoType(io_type);
478+
modbterm->setIoType(io_type);
479479
}
480480
} else {
481481
const std::string port_name = network_->name(port);
482482
dbModBTerm* bmodterm = dbModBTerm::create(module, port_name.c_str());
483-
const dbIoType io_type = staToDb(network_->direction(port));
484483
bmodterm->setIoType(io_type);
485484
debugPrint(logger_,
486485
utl::ODB,

src/dbSta/test/check_axioms.ok

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
22
[WARNING ORD-0011] Hierarchical flow (-hier) is currently in development and may cause multiple issues. Do not use in production environments.
3+
[WARNING ODB-0482] SanityCheck: dbModNet 'u1/Z' has no driver.
4+
[WARNING ODB-0483] SanityCheck: dbModNet 'u1/Z' is dangling. It has less than 2 connections (# of ITerms = 0, # of BTerms = 0, # of ModITerms = 0, # of ModBTerms = 1).
5+
[WARNING ODB-0482] SanityCheck: dbModNet 'single_conn_wire' has no driver.
6+
[WARNING ODB-0483] SanityCheck: dbModNet 'single_conn_wire' is dangling. It has less than 2 connections (# of ITerms = 0, # of BTerms = 0, # of ModITerms = 1, # of ModBTerms = 0).
37
[WARNING ODB-0050] SanityCheck: dbNet 'out_unconnected' has no driver.
48
[WARNING ODB-0051] SanityCheck: dbNet 'out_unconnected' is dangling. It has less than 2 connections (# of ITerms = 0, # of BTerms = 1).
59
[WARNING ODB-0051] SanityCheck: dbNet 'single_conn_wire' is dangling. It has less than 2 connections (# of ITerms = 0, # of BTerms = 0).

src/dbSta/test/hierclock_out.vok

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ module counter (clk_i,
238238
.Q(counter_q[3]),
239239
.QN(_38_));
240240
assign count_valid_o = count_valid_q;
241+
assign count_value_o[0] = counter_q[0];
242+
assign count_value_o[1] = counter_q[1];
243+
assign count_value_o[2] = counter_q[2];
244+
assign count_value_o[3] = counter_q[3];
241245
endmodule
242246
module counter_U3 (clk_i,
243247
rst_n_i,
@@ -352,4 +356,8 @@ module counter_U3 (clk_i,
352356
.Q(counter_q[3]),
353357
.QN(_38_));
354358
assign count_valid_o = count_valid_q;
359+
assign count_value_o[0] = counter_q[0];
360+
assign count_value_o[1] = counter_q[1];
361+
assign count_value_o[2] = counter_q[2];
362+
assign count_value_o[3] = counter_q[3];
355363
endmodule

src/odb/include/odb/db.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8291,6 +8291,7 @@ class dbModBTerm : public dbObject
82918291
dbModule* getParent() const;
82928292

82938293
// User Code Begin dbModBTerm
8294+
std::string getHierarchicalName() const;
82948295
void setParentModITerm(dbModITerm* parent_pin);
82958296
dbModITerm* getParentModITerm() const;
82968297
void setModNet(dbModNet* modNet);
@@ -8366,6 +8367,7 @@ class dbModITerm : public dbObject
83668367
dbModInst* getParent() const;
83678368

83688369
// User Code Begin dbModITerm
8370+
std::string getHierarchicalName() const;
83698371
void setModNet(dbModNet* modNet);
83708372
dbModNet* getModNet() const;
83718373
void setChildModBTerm(dbModBTerm* child_port);
@@ -8391,7 +8393,7 @@ class dbModNet : public dbObject
83918393
dbSet<dbModBTerm> getModBTerms() const;
83928394
dbSet<dbITerm> getITerms() const;
83938395
dbSet<dbBTerm> getBTerms() const;
8394-
unsigned connectionCount();
8396+
unsigned connectionCount() const;
83958397
std::string getName() const;
83968398
const char* getConstName() const;
83978399
std::string getHierarchicalName() const;
@@ -8404,6 +8406,7 @@ class dbModNet : public dbObject
84048406
// This function traverses the terminals connected to this dbModNet
84058407
// and returns the first dbNet it finds.
84068408
dbNet* findRelatedNet() const;
8409+
void checkSanity() const;
84078410

84088411
static dbModNet* getModNet(dbBlock* block, uint id);
84098412
static dbModNet* create(dbModule* parentModule, const char* base_name);

src/odb/src/db/dbModBTerm.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "dbTable.hpp"
1717
#include "odb/db.h"
1818
// User Code Begin Includes
19+
#include <string>
20+
1921
#include "odb/dbBlockCallBackObj.h"
2022
// User Code End Includes
2123
namespace odb {
@@ -168,6 +170,23 @@ dbModule* dbModBTerm::getParent() const
168170
}
169171

170172
// User Code Begin dbModBTermPublicMethods
173+
std::string dbModBTerm::getHierarchicalName() const
174+
{
175+
dbModule* parent = getParent();
176+
if (parent == nullptr) {
177+
return getName();
178+
}
179+
180+
dbBlock* block = parent->getOwner();
181+
if (parent == block->getTopModule()) {
182+
return getName();
183+
}
184+
185+
return fmt::format("{}{}{}", // NOLINT(misc-include-cleaner)
186+
parent->getModInst()->getHierarchicalName(),
187+
block->getHierarchyDelimiter(),
188+
getName());
189+
}
171190

172191
void dbModBTerm::setModNet(dbModNet* modNet)
173192
{

src/odb/src/db/dbModITerm.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "dbTable.hpp"
1616
#include "odb/db.h"
1717
// User Code Begin Includes
18+
#include <string>
19+
1820
#include "odb/dbBlockCallBackObj.h"
1921
// User Code End Includes
2022
namespace odb {
@@ -154,6 +156,28 @@ dbModInst* dbModITerm::getParent() const
154156
}
155157

156158
// User Code Begin dbModITermPublicMethods
159+
std::string dbModITerm::getHierarchicalName() const
160+
{
161+
dbModInst* modinst = getParent();
162+
if (modinst == nullptr) {
163+
return getName();
164+
}
165+
166+
dbModule* module = modinst->getParent();
167+
if (module == nullptr) {
168+
return getName();
169+
}
170+
171+
dbBlock* block = module->getOwner();
172+
if (module == block->getTopModule()) {
173+
return getName();
174+
}
175+
176+
return fmt::format("{}{}{}", // NOLINT(misc-include-cleaner)
177+
modinst->getHierarchicalName(),
178+
block->getHierarchyDelimiter(),
179+
getName());
180+
}
157181

158182
void dbModITerm::setModNet(dbModNet* modNet)
159183
{

src/odb/src/db/dbModNet.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "dbModuleModNetITermItr.h"
2626
#include "dbModuleModNetModBTermItr.h"
2727
#include "dbModuleModNetModITermItr.h"
28+
#include "dbUtil.h"
2829
#include "odb/dbBlockCallBackObj.h"
2930
#include "utl/Logger.h"
3031
// User Code End Includes
@@ -413,9 +414,10 @@ dbSet<dbITerm> dbModNet::getITerms() const
413414
return dbSet<dbITerm>(_mod_net, _block->_module_modnet_iterm_itr);
414415
}
415416

416-
unsigned dbModNet::connectionCount()
417+
unsigned dbModNet::connectionCount() const
417418
{
418-
return (getITerms().size() + getBTerms().size() + getModITerms().size());
419+
return (getITerms().size() + getBTerms().size() + getModITerms().size()
420+
+ getModBTerms().size());
419421
}
420422

421423
dbNet* dbModNet::findRelatedNet() const
@@ -490,6 +492,17 @@ dbNet* dbModNet::findRelatedNet() const
490492
return nullptr;
491493
}
492494

495+
void dbModNet::checkSanity() const
496+
{
497+
std::vector<std::string> drvr_info_list;
498+
dbUtil::findBTermDrivers(this, drvr_info_list);
499+
dbUtil::findITermDrivers(this, drvr_info_list);
500+
dbUtil::findModBTermDrivers(this, drvr_info_list);
501+
dbUtil::findModITermDrivers(this, drvr_info_list);
502+
503+
dbUtil::checkNetSanity(this, drvr_info_list);
504+
}
505+
493506
// User Code End dbModNetPublicMethods
494507
} // namespace odb
495508
// Generator Code End Cpp

src/odb/src/db/dbNet.cpp

Lines changed: 4 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "dbTable.hpp"
4141
#include "dbTech.h"
4242
#include "dbTechNonDefaultRule.h"
43+
#include "dbUtil.h"
4344
#include "dbWire.h"
4445
#include "odb/db.h"
4546
#include "odb/dbBlockCallBackObj.h"
@@ -2348,100 +2349,11 @@ void dbNet::setJumpers(bool has_jumpers)
23482349

23492350
void dbNet::checkSanity() const
23502351
{
2351-
_dbNet* net = (_dbNet*) this;
2352-
utl::Logger* logger = net->getImpl()->getLogger();
23532352
std::vector<std::string> drvr_info_list;
2353+
dbUtil::findBTermDrivers(this, drvr_info_list);
2354+
dbUtil::findITermDrivers(this, drvr_info_list);
23542355

2355-
// Find BTerm drivers
2356-
for (dbBTerm* bterm : getBTerms()) {
2357-
if (bterm->getIoType() == dbIoType::INPUT
2358-
|| bterm->getIoType() == dbIoType::INOUT) {
2359-
dbBlock* block = bterm->getBlock();
2360-
dbModule* parent_module = block->getTopModule();
2361-
drvr_info_list.push_back(
2362-
// NOLINTNEXTLINE(misc-include-cleaner)
2363-
fmt::format("\n - bterm: '{}' (parent_module: '{}', block: '{}')",
2364-
bterm->getName(),
2365-
parent_module->getName(),
2366-
block->getName()));
2367-
}
2368-
}
2369-
2370-
// Find ITerm drivers
2371-
for (dbITerm* iterm : getITerms()) {
2372-
if (iterm->getIoType() == dbIoType::OUTPUT
2373-
|| iterm->getIoType() == dbIoType::INOUT) {
2374-
dbInst* inst = iterm->getInst();
2375-
dbMaster* master = inst->getMaster();
2376-
dbModule* parent_module = inst->getModule();
2377-
dbBlock* block = inst->getBlock();
2378-
2379-
std::string parent_module_name = "null";
2380-
if (parent_module) {
2381-
parent_module_name = parent_module->getName();
2382-
}
2383-
2384-
std::string master_name = "null";
2385-
if (master) {
2386-
master_name = master->getName();
2387-
}
2388-
2389-
std::string block_name = "null";
2390-
if (block) {
2391-
block_name = block->getName();
2392-
}
2393-
2394-
drvr_info_list.push_back(fmt::format( // NOLINT(misc-include-cleaner)
2395-
"\n - iterm: '{}' (block: '{}', parent_module: '{}', master: '{}')",
2396-
iterm->getName('/'),
2397-
block_name,
2398-
parent_module_name,
2399-
master_name));
2400-
}
2401-
}
2402-
2403-
size_t drvr_count = drvr_info_list.size();
2404-
if (drvr_count > 1) {
2405-
// Multiple drivers found.
2406-
logger->error(
2407-
utl::ODB,
2408-
49,
2409-
"SanityCheck: dbNet '{}' has multiple drivers: {}",
2410-
getName(),
2411-
fmt::join(drvr_info_list, "")); // NOLINT(misc-include-cleaner)
2412-
}
2413-
2414-
const uint iterm_count = getITerms().size();
2415-
const uint bterm_count = getBTerms().size();
2416-
2417-
if (drvr_count == 0 && (iterm_count + bterm_count > 0)) {
2418-
logger->warn(
2419-
utl::ODB, 50, "SanityCheck: dbNet '{}' has no driver.", getName());
2420-
}
2421-
2422-
if (iterm_count + bterm_count < 2) {
2423-
// Skip power/ground net
2424-
if (getSigType().isSupply()) {
2425-
return; // OK: Unconnected power/ground net
2426-
}
2427-
2428-
// A net connected to 1 terminal
2429-
if (iterm_count == 1
2430-
&& (*(getITerms().begin()))->getIoType() == dbIoType::OUTPUT) {
2431-
return; // OK: Unconnected output pin
2432-
}
2433-
if (bterm_count == 1
2434-
&& (*(getBTerms().begin()))->getIoType() == dbIoType::INPUT) {
2435-
return; // OK: Unconnected input port
2436-
}
2437-
logger->warn(utl::ODB,
2438-
51,
2439-
"SanityCheck: dbNet '{}' is dangling. It has less than 2 "
2440-
"connections (# of ITerms = {}, # of BTerms = {}).",
2441-
getName(),
2442-
iterm_count,
2443-
bterm_count);
2444-
}
2356+
dbUtil::checkNetSanity(this, drvr_info_list);
24452357
}
24462358

24472359
dbModInst* dbNet::findMainParentModInst() const

0 commit comments

Comments
 (0)