Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair setup4 hier case 1 buffer #6048

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/dbSta/include/db_sta/dbNetwork.hh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class dbNetwork : public ConcreteNetwork
dbModule* getNetDriverParentModule(Net* net);
Instance* getOwningInstanceParent(Pin* pin);

bool ConnectionToModuleExists(dbITerm* source_pin,
dbModule* dest_module,
dbModBTerm*& dest_modbterm);

void hierarchicalConnect(dbITerm* source_pin,
dbITerm* dest_pin,
const char* connection_name);
Expand Down
74 changes: 74 additions & 0 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2814,6 +2814,70 @@ dbModule* dbNetwork::findHighestCommonModule(std::vector<dbModule*>& itree1,
return common_module; // default to top
}

class PinModuleConnection : public PinVisitor
{
public:
PinModuleConnection(const dbNetwork* nwk,
const Pin* drvr_pin,
const dbModule* target_module_);
virtual void operator()(const Pin* pin);
maliberty marked this conversation as resolved.
Show resolved Hide resolved

protected:
const dbNetwork* db_network_;
const Pin* drvr_pin_;
const dbModule* target_module_;
dbModBTerm* dest_modbterm_;
friend class dbNetwork;
};

PinModuleConnection::PinModuleConnection(const dbNetwork* nwk,
const Pin* drvr_pin,
const dbModule* target_module)
{
db_network_ = nwk;
drvr_pin_ = drvr_pin;
target_module_ = target_module;
dest_modbterm_ = nullptr;
}

void PinModuleConnection::operator()(const Pin* pin)
{
dbITerm* iterm;
dbBTerm* bterm;
dbModBTerm* modbterm;
dbModITerm* moditerm;
db_network_->staToDb(pin, iterm, bterm, moditerm, modbterm);
(void) (iterm);
(void) (bterm);
(void) (modbterm);
if (moditerm) {
std::string port_name_str = moditerm->getName();
size_t last_idx = port_name_str.find_last_of('/');
if (last_idx != string::npos) {
port_name_str = port_name_str.substr(last_idx + 1);
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this done by string manipulation? Is this different from getChildModBTerm()->getName()? Why does moditerm even need to store its name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I have put in the getChildModBTerm and remove the string manipulation.
I am sure not sure why but in the opensta both pins and port names are stored. So we do indeed store names in the modIterm and modBterm. I have updated the code and put in a comment about this in the dbSta/dbReadVerilog.cc. We can always get the ModBTerm for a modIterm using the getChildModBTerm api.

const char* port_name = port_name_str.c_str();
dbModInst* mod_inst = moditerm->getParent();
dbModule* module = mod_inst->getMaster();
if (module == target_module_) {
dest_modbterm_ = module->findModBTerm(port_name);
}
}
}

bool dbNetwork::ConnectionToModuleExists(dbITerm* source_pin,
dbModule* dest_module,
dbModBTerm*& dest_modbterm)
{
PinModuleConnection visitor(this, dbToSta(source_pin), dest_module);
network_->visitConnectedPins(dbToSta(source_pin), visitor);
if (visitor.dest_modbterm_ != nullptr) {
dest_modbterm = visitor.dest_modbterm_;
return true;
}
return false;
}

/*
Connect any two leaf instance pins anywhere in hierarchy
adding pins/nets/ports on the hierarchical objects
Expand All @@ -2837,6 +2901,16 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
}
dest_pin->connect(source_db_mod_net);
} else {
// Attempt to factor connection (minimize punch through)
dbModBTerm* dest_modbterm;
if (ConnectionToModuleExists(source_pin, dest_db_module, dest_modbterm)) {
dbModNet* dest_mod_net = dest_modbterm->getModNet();
if (dest_mod_net) {
dest_pin->connect(dest_mod_net);
return;
}
}

// case 2: source/dest in different modules. Find highest
// common module, traverse up adding pins/nets and make
// connection in highest common module
Expand Down
3 changes: 3 additions & 0 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -8152,8 +8152,11 @@ class dbModNet : public dbObject
dbSet<dbBTerm> getBTerms();

const char* getName() const;
void reName(const char* new_name);
static dbModNet* getModNet(dbBlock* block, uint id);
static dbModNet* create(dbModule* parentModule, const char* name);
static void destroy(dbModNet*);

// User Code End dbModNet
};

Expand Down
40 changes: 39 additions & 1 deletion src/odb/src/db/dbITerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ void dbITerm::connect(dbNet* net_)
block->_journal->pushParam(dbITermObj);
block->_journal->pushParam(getId());
block->_journal->pushParam(net_->getId());
// put in a fake modnet here
block->_journal->pushParam(0);
block->_journal->endAction();
}

Expand Down Expand Up @@ -500,6 +502,22 @@ void dbITerm::connect(dbModNet* mod_net)
inst->_name);
}

if (block->_journal) {
debugPrint(iterm->getImpl()->getLogger(),
utl::ODB,
"DB_ECO",
1,
"ECO: connect Iterm {} to modnet {}",
getId(),
_mod_net->getId());
block->_journal->beginAction(dbJournal::CONNECT_OBJECT);
block->_journal->pushParam(dbITermObj);
block->_journal->pushParam(getId());
block->_journal->pushParam(0);
block->_journal->pushParam(_mod_net->getId());
block->_journal->endAction();
}

if (_mod_net->_iterms != 0) {
_dbITerm* head = block->_iterm_tbl->getPtr(_mod_net->_iterms);
iterm->_next_modnet_iterm = _mod_net->_iterms;
Expand Down Expand Up @@ -552,7 +570,6 @@ void dbITerm::disconnect()
block->_journal->pushParam(dbITermObj);
block->_journal->pushParam(getId());
block->_journal->pushParam(net->getOID());
block->_journal->endAction();
}

uint id = iterm->getOID();
Expand Down Expand Up @@ -580,9 +597,30 @@ void dbITerm::disconnect()

// the modnet part
if (iterm->_mnet == 0) {
if (block->_journal) {
debugPrint(iterm->getImpl()->getLogger(),
utl::ODB,
"DB_ECO",
1,
"ECO: disconnect modnet from Iterm {}",
getId());
block->_journal->pushParam(0);
block->_journal->endAction();
}
return;
}

_dbModNet* mod_net = block->_modnet_tbl->getPtr(iterm->_mnet);
if (block->_journal) {
debugPrint(iterm->getImpl()->getLogger(),
utl::ODB,
"DB_ECO",
1,
"ECO: disconnect Iterm -- modnet part {}",
getId());
block->_journal->pushParam(mod_net->getOID());
block->_journal->endAction();
}

if (mod_net->_iterms == id) {
mod_net->_iterms = iterm->_next_modnet_iterm;
Expand Down
48 changes: 37 additions & 11 deletions src/odb/src/db/dbJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,30 @@ void dbJournal::redo_connectObject()
dbITerm* iterm = dbITerm::getITerm(_block, iterm_id);
uint net_id;
_log.pop(net_id);
dbNet* net = dbNet::getNet(_block, net_id);
debugPrint(_logger,
utl::ODB,
"DB_ECO",
2,
"REDO ECO: connect dbITermObj, iterm_id {}, net_id {}",
iterm_id,
net_id);
iterm->connect(net);
if (net_id != 0) {
dbNet* net = dbNet::getNet(_block, net_id);
debugPrint(_logger,
utl::ODB,
"DB_ECO",
2,
"REDO ECO: connect dbITermObj, iterm_id {}, net_id {}",
iterm_id,
net_id);
iterm->connect(net);
}
uint mod_net_id;
_log.pop(mod_net_id);
if (mod_net_id != 0) {
dbModNet* mod_net = dbModNet::getModNet(_block, mod_net_id);
debugPrint(_logger,
utl::ODB,
"DB_ECO",
2,
"REDO ECO: connect dbITermObj, iterm_id {}, mod_net_id {}",
iterm_id,
mod_net_id);
iterm->connect(mod_net);
}
break;
}

Expand Down Expand Up @@ -622,6 +637,7 @@ void dbJournal::redo_disconnectObject()
2,
"REDO ECO: disconnect dbITermObj, iterm_id {}",
iterm_id);
// note: this will disconnect the modnet and the dbNet
iterm->disconnect();
break;
}
Expand Down Expand Up @@ -1618,6 +1634,7 @@ void dbJournal::undo_connectObject()
dbITerm* iterm = dbITerm::getITerm(_block, iterm_id);
uint net_id;
_log.pop(net_id);
// disconnects everything modnet and bnet)
Copy link
Member

Choose a reason for hiding this comment

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

stray )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Poor comment, cleaned up.

iterm->disconnect();
break;
}
Expand Down Expand Up @@ -1653,8 +1670,17 @@ void dbJournal::undo_disconnectObject()
dbITerm* iterm = dbITerm::getITerm(_block, iterm_id);
uint net_id;
_log.pop(net_id);
dbNet* net = dbNet::getNet(_block, net_id);
iterm->connect(net);
if (net_id != 0) {
dbNet* net = dbNet::getNet(_block, net_id);
iterm->connect(net);
}
uint mnet_id;
_log.pop(mnet_id);
if (mnet_id != 0) {
dbModNet* mod_net = dbModNet::getModNet(_block, mnet_id);
iterm->connect(mod_net);
}

break;
}

Expand Down
20 changes: 20 additions & 0 deletions src/odb/src/db/dbModNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,26 @@ const char* dbModNet::getName() const
return obj->_name;
}

//
// Support for renaming hierarchical nets
//
void dbModNet::reName(const char* new_name)
Copy link
Member

Choose a reason for hiding this comment

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

rename is one word so no need a capital in reName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, done

{
_dbModNet* obj = (_dbModNet*) this;
delete (obj->_name);
obj->_name = strdup(new_name);
Copy link
Member

Choose a reason for hiding this comment

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

free is the opposite of strdup not delete.

I also don't see a free call in dbModNet::destroy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.
Note the tbldestroy goes off and calls the destructor ~_dbModNet which inturn calls free on the name .
block->_modnet_tbl->destroy(_modnet);

_dbBlock* block = (_dbBlock*) obj->getOwner();
_dbModule* parent = block->_module_tbl->getPtr(obj->_parent);
parent->_modnet_hash[new_name] = obj->getOID();
Copy link
Member

Choose a reason for hiding this comment

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

You haven't removed the old name from the hash.

}

dbModNet* dbModNet::getModNet(dbBlock* block, uint id)
{
_dbBlock* block_ = (_dbBlock*) block;
_dbModNet* ret = block_->_modnet_tbl->getPtr(id);
return (dbModNet*) ret;
}

dbModNet* dbModNet::create(dbModule* parentModule, const char* name)
{
// give illusion of scoping.
Expand Down
8 changes: 8 additions & 0 deletions src/rsz/src/EstimateWireParasitics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ bool Resizer::isPad(const Instance* inst) const

void Resizer::parasiticsInvalid(const Net* net)
{
odb::dbNet* db_net = nullptr;
odb::dbModNet* db_modnet = nullptr;
db_network_->staToDb(net, db_net, db_modnet);
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose? Nothing seems to use the results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

redundant code, removed.

if (db_modnet) {
printf("Error -- cannot update parastics from a db modnet\n");
exit(0);
}

if (haveEstimatedParasitics()) {
debugPrint(logger_,
RSZ,
Expand Down
6 changes: 5 additions & 1 deletion src/rsz/src/OdbCallBack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ void OdbCallBack::inDbInstSwapMasterAfter(dbInst* inst)
while (pin_iter->hasNext()) {
Pin* pin = pin_iter->next();
Net* net = network_->net(pin);
resizer_->parasiticsInvalid(net);
// we can only update parasitics for low level net
Copy link
Member

Choose a reason for hiding this comment

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

I don't follow the comment. There is only one dbNet attached to the pin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another poor comment I am afraid. Cleaned up to call the new flatNet api, so it is clear that the parasiticsInvalid is applied to the dbNet only

odb::dbNet* db_net = nullptr;
odb::dbModNet* db_modnet = nullptr;
db_network_->staToDb(net, db_net, db_modnet);
resizer_->parasiticsInvalid(db_network_->dbToSta(db_net));
}
}

Expand Down
Loading
Loading