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

Rsz clone swap #6124

Merged
merged 17 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion src/dbSta/include/db_sta/dbNetwork.hh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class dbNetwork : public ConcreteNetwork

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

void hierarchicalConnect(dbITerm* source_pin,
dbITerm* dest_pin,
Expand Down Expand Up @@ -268,6 +269,7 @@ class dbNetwork : public ConcreteNetwork

////////////////////////////////////////////////////////////////
// Port functions

Cell* cell(const Port* port) const override;
void registerConcretePort(const Port*);

Expand Down
40 changes: 36 additions & 4 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,7 @@ class PinModuleConnection : public PinVisitor
const Pin* drvr_pin_;
const dbModule* target_module_;
dbModBTerm* dest_modbterm_;
dbModITerm* dest_moditerm_;
friend class dbNetwork;
};

Expand All @@ -2907,6 +2908,7 @@ PinModuleConnection::PinModuleConnection(const dbNetwork* nwk,
drvr_pin_ = drvr_pin;
target_module_ = target_module;
dest_modbterm_ = nullptr;
dest_moditerm_ = nullptr;
}

void PinModuleConnection::operator()(const Pin* pin)
Expand All @@ -2915,6 +2917,7 @@ void PinModuleConnection::operator()(const Pin* pin)
dbBTerm* bterm;
dbModBTerm* modbterm;
dbModITerm* moditerm;

db_network_->staToDb(pin, iterm, bterm, moditerm, modbterm);
(void) (iterm);
(void) (bterm);
Expand All @@ -2924,19 +2927,32 @@ void PinModuleConnection::operator()(const Pin* pin)
if (modbterm->getParent() == target_module_) {
dest_modbterm_ = modbterm;
}
} else if (modbterm) {
if (modbterm->getParent() == target_module_) {
dest_modbterm_ = modbterm;
}
dbModITerm* moditerm = modbterm->getParentModITerm();
if (moditerm->getParent()->getParent() == target_module_) {
dest_moditerm_ = moditerm;
}
}
}

bool dbNetwork::ConnectionToModuleExists(dbITerm* source_pin,
dbModule* dest_module,
dbModBTerm*& dest_modbterm)
dbModBTerm*& dest_modbterm,
dbModITerm*& dest_moditerm)
{
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;
}
if (visitor.dest_moditerm_ != nullptr) {
dest_moditerm = visitor.dest_moditerm_;
return true;
}
return false;
}

Expand Down Expand Up @@ -2964,9 +2980,17 @@ 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();
//
dbModBTerm* dest_modbterm = nullptr;
dbModITerm* dest_moditerm = nullptr;
if (ConnectionToModuleExists(
source_pin, dest_db_module, dest_modbterm, dest_moditerm)) {
dbModNet* dest_mod_net = nullptr;
if (dest_modbterm) {
dest_mod_net = dest_modbterm->getModNet();
} else if (dest_moditerm) {
dest_mod_net = dest_moditerm->getModNet();
}
if (dest_mod_net) {
dest_pin->connect(dest_mod_net);
return;
Expand All @@ -2992,6 +3016,11 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
= std::string(connection_name) + std::string("_o");
dbModBTerm* mod_bterm
= dbModBTerm::create(cur_module, connection_name_o.c_str());
if (!source_db_mod_net) {
source_db_mod_net
= dbModNet::create(source_db_module, connection_name_o.c_str());
}
source_pin->connect(source_db_mod_net);
mod_bterm->connect(source_db_mod_net);
mod_bterm->setIoType(dbIoType::OUTPUT);
mod_bterm->setSigType(dbSigType::SIGNAL);
Expand All @@ -3000,10 +3029,12 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
dbModITerm* mod_iterm
= dbModITerm::create(parent_inst, connection_name_o.c_str());
mod_iterm->setChildModBTerm(mod_bterm);
mod_bterm->setParentModITerm(mod_iterm);
source_db_mod_net = dbModNet::create(cur_module, connection_name);
mod_iterm->connect(source_db_mod_net);
top_net = source_db_mod_net;
}

// make dest hierarchy
cur_module = dest_db_module;
while (cur_module != highest_common_module) {
Expand All @@ -3028,6 +3059,7 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
dbModITerm* mod_iterm
= dbModITerm::create(parent_inst, connection_name_i.c_str());
mod_iterm->setChildModBTerm(mod_bterm);
mod_bterm->setParentModITerm(mod_iterm);
if (cur_module != highest_common_module) {
dest_db_mod_net = dbModNet::create(cur_module, connection_name);
mod_iterm->connect(dest_db_mod_net);
Expand Down
31 changes: 28 additions & 3 deletions src/dbSta/src/dbReadVerilog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ void Verilog2db::makeDbModule(
dbModule* module = modinst->getMaster();
modbterm = module->findModBTerm(port_name_str.c_str());
moditerm->setChildModBTerm(modbterm);
modbterm->setParentModITerm(moditerm);

(void) moditerm;
debugPrint(logger_,
Expand Down Expand Up @@ -644,9 +645,9 @@ void Verilog2db::makeDbNets(const Instance* inst)
while (net_iter->hasNext()) {
Net* net = net_iter->next();
const char* net_name = network_->pathName(net);

if (is_top || !hasTerminals(net)) {
dbNet* db_net = dbNet::create(block_, net_name);

if (network_->isPower(net)) {
db_net->setSigType(odb::dbSigType::POWER);
}
Expand Down Expand Up @@ -716,14 +717,38 @@ void Verilog2db::makeVModNets(const Instance* inst, dbModInst* mod_inst)
std::unique_ptr<InstancePinIterator> pinIter{network_->pinIterator(inst)};
while (pinIter->hasNext()) {
Pin* inst_pin = pinIter->next();

Net* inst_pin_net = network_->net(inst_pin);

if (!inst_pin_net) {
continue;
}

dbModNet* upper_mod_net = constructModNet(inst_pin_net, parent_module);
(void) upper_mod_net;

dbModITerm* mod_iterm = nullptr;
dbModBTerm* mod_bterm = nullptr;
dbBTerm* bterm = nullptr;
dbITerm* iterm = nullptr;
staToDb(child_module, inst_pin, bterm, iterm, mod_bterm, mod_iterm);
if (mod_bterm) {
mod_iterm = mod_bterm->getParentModITerm();
if (mod_iterm) {
mod_iterm->connect(upper_mod_net);
}
}

// make sure any top level bterms are connected to this net too...
if (parent_module == block_->getTopModule()) {
NetConnectedPinIterator* pin_iter
= network_->connectedPinIterator(inst_pin_net);
while (pin_iter->hasNext()) {
const Pin* pin = pin_iter->next();
staToDb(parent_module, pin, bterm, iterm, mod_bterm, mod_iterm);
if (bterm) {
bterm->connect(upper_mod_net);
}
}
}

// push down inside the hierarchical instance to find any
// modnets connected on the inside of the instance
Expand Down
2 changes: 2 additions & 0 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -8085,6 +8085,7 @@ class dbModBTerm : public dbObject
dbBusPort* getBusPort() const;
static dbModBTerm* create(dbModule* parentModule, const char* name);
static void destroy(dbModBTerm*);
static dbModBTerm* getModBTerm(dbBlock* block, uint dbid);

private:
// User Code End dbModBTerm
Expand Down Expand Up @@ -8140,6 +8141,7 @@ class dbModITerm : public dbObject
void disconnect();
static dbModITerm* create(dbModInst* parentInstance, const char* name);
static void destroy(dbModITerm*);
static dbModITerm* getModITerm(dbBlock* block, uint dbid);
// User Code End dbModITerm
};

Expand Down
2 changes: 1 addition & 1 deletion src/odb/src/codeGenerator/schema/chip/dbModBterm.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@
}
],
"constructors":[],
"cpp_includes":["dbBlock.h","dbModule.h","dbModNet.h","dbHashTable.hpp","dbModITerm.h","dbBusPort.h"]
"cpp_includes":["dbBlock.h","dbModule.h","dbModNet.h","dbHashTable.hpp","dbModITerm.h","dbBusPort.h","dbJournal.h"]
}
2 changes: 1 addition & 1 deletion src/odb/src/codeGenerator/schema/chip/dbModIterm.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@

],
"constructors":[],
"cpp_includes":["dbBlock.h","dbModInst.h","dbModNet.h","dbHashTable.hpp","dbModBTerm.h"]
"cpp_includes":["dbBlock.h","dbModInst.h","dbModNet.h","dbHashTable.hpp","dbModBTerm.h", "dbJournal.h"]
}
36 changes: 36 additions & 0 deletions src/odb/src/db/dbJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,22 @@ void dbJournal::undo_createObject()
break;
}

case dbModBTermObj: {
uint modbterm_id;
_log.pop(modbterm_id);
dbModBTerm* modbterm = dbModBTerm::getModBTerm(_block, modbterm_id);
dbModBTerm::destroy(modbterm);
break;
}

case dbModITermObj: {
uint moditerm_id;
_log.pop(moditerm_id);
dbModITerm* moditerm = dbModITerm::getModITerm(_block, moditerm_id);
dbModITerm::destroy(moditerm);
break;
}

default: {
_logger->critical(utl::ODB,
441,
Expand Down Expand Up @@ -1631,6 +1647,26 @@ void dbJournal::undo_connectObject()
auto obj_type = popObjectType();

switch (obj_type) {
case dbModITermObj: {
uint moditerm_id;
_log.pop(moditerm_id);
dbModITerm* moditerm = dbModITerm::getModITerm(_block, moditerm_id);
uint net_id;
_log.pop(net_id);
moditerm->disconnect();
break;
}

case dbModBTermObj: {
uint modbterm_id;
_log.pop(modbterm_id);
dbModBTerm* modbterm = dbModBTerm::getModBTerm(_block, modbterm_id);
uint net_id;
_log.pop(net_id);
modbterm->disconnect();
break;
}

case dbITermObj: {
uint iterm_id;
_log.pop(iterm_id);
Expand Down
23 changes: 23 additions & 0 deletions src/odb/src/db/dbModBTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "dbDatabase.h"
#include "dbDiff.hpp"
#include "dbHashTable.hpp"
#include "dbJournal.h"
#include "dbModITerm.h"
#include "dbModNet.h"
#include "dbModule.h"
Expand Down Expand Up @@ -365,6 +366,14 @@ dbModBTerm* dbModBTerm::create(dbModule* parentModule, const char* name)
}
module->_modbterms = modbterm->getOID();
module->_modbterm_hash[name] = dbId<_dbModBTerm>(modbterm->getOID());

if (block->_journal) {
block->_journal->beginAction(dbJournal::CREATE_OBJECT);
block->_journal->pushParam(dbModBTermObj);
block->_journal->pushParam(modbterm->getId());
block->_journal->endAction();
}

return (dbModBTerm*) modbterm;
}

Expand All @@ -391,6 +400,14 @@ void dbModBTerm::connect(dbModNet* net)
}
_modbterm->_prev_net_modbterm = 0; // previous of head always zero
_modnet->_modbterms = getId(); // set new head

if (_block->_journal) {
_block->_journal->beginAction(dbJournal::CONNECT_OBJECT);
_block->_journal->pushParam(dbModBTermObj);
_block->_journal->pushParam(getId());
_block->_journal->pushParam(net->getId());
_block->_journal->endAction();
}
}

void dbModBTerm::disconnect()
Expand Down Expand Up @@ -448,6 +465,12 @@ void dbModBTerm::setBusPort(dbBusPort* bus_port)
_modbterm->_busPort = bus_port->getId();
}

dbModBTerm* dbModBTerm::getModBTerm(dbBlock* block, uint dbid)
{
_dbBlock* owner = (_dbBlock*) block;
return (dbModBTerm*) (owner->_modbterm_tbl->getPtr(dbid));
}

void dbModBTerm::destroy(dbModBTerm* val)
{
_dbModBTerm* _modbterm = (_dbModBTerm*) val;
Expand Down
23 changes: 23 additions & 0 deletions src/odb/src/db/dbModITerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "dbDatabase.h"
#include "dbDiff.hpp"
#include "dbHashTable.hpp"
#include "dbJournal.h"
#include "dbModBTerm.h"
#include "dbModInst.h"
#include "dbModNet.h"
Expand Down Expand Up @@ -282,6 +283,14 @@ dbModITerm* dbModITerm::create(dbModInst* parentInstance, const char* name)
}
parent->_moditerms = moditerm->getOID();
parent->_moditerm_hash[name] = dbId<_dbModITerm>(moditerm->getOID());

if (block->_journal) {
block->_journal->beginAction(dbJournal::CREATE_OBJECT);
block->_journal->pushParam(dbModITermObj);
block->_journal->pushParam(moditerm->getId());
block->_journal->endAction();
}

return (dbModITerm*) moditerm;
}

Expand All @@ -307,6 +316,14 @@ void dbModITerm::connect(dbModNet* net)
// set up new head
_moditerm->_prev_net_moditerm = 0;
_modnet->_moditerms = getId();

if (_block->_journal) {
_block->_journal->beginAction(dbJournal::CONNECT_OBJECT);
_block->_journal->pushParam(dbModITermObj);
_block->_journal->pushParam(getId());
_block->_journal->pushParam(_modnet->getId());
_block->_journal->endAction();
}
}

void dbModITerm::disconnect()
Expand Down Expand Up @@ -336,6 +353,12 @@ void dbModITerm::disconnect()
}
}

dbModITerm* dbModITerm::getModITerm(dbBlock* block, uint dbid)
{
_dbBlock* owner = (_dbBlock*) block;
return (dbModITerm*) (owner->_moditerm_tbl->getPtr(dbid));
}

void dbModITerm::destroy(dbModITerm* val)
{
_dbModITerm* _moditerm = (_dbModITerm*) val;
Expand Down
Loading
Loading