Skip to content

Commit

Permalink
Merge pull request #5395 from The-OpenROAD-Project-staging/odb-statics
Browse files Browse the repository at this point in the history
Odb statics
  • Loading branch information
maliberty authored Jul 18, 2024
2 parents 43268da + caa5dde commit 1cd00ee
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 447 deletions.
1 change: 0 additions & 1 deletion src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ ObjectId dbNetwork::id(const Pin* pin) const
dbModITerm* moditerm = nullptr;
dbModBTerm* modbterm = nullptr;

static std::map<ObjectId, void*> id_ptr_map;
staToDb(pin, iterm, bterm, moditerm, modbterm);

if (hierarchy_) {
Expand Down
1 change: 1 addition & 0 deletions src/dpl/include/dpl/Opendp.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class Opendp
int64_t displacement_max_ = 0;

std::unique_ptr<DplObserver> debug_observer_;
std::unique_ptr<Cell> dummy_cell_;

// Magic numbers
static constexpr int bin_search_width_ = 10;
Expand Down
2 changes: 0 additions & 2 deletions src/dpl/src/Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

namespace dpl {

Cell Cell::dummy_cell;

const char* Cell::name() const
{
return db_inst_->getConstName();
Expand Down
2 changes: 0 additions & 2 deletions src/dpl/src/Objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ struct Cell
bool hold_ = false;
Group* group_ = nullptr;
Rect* region_ = nullptr; // group rect

static Cell dummy_cell;
};

struct Group
Expand Down
7 changes: 4 additions & 3 deletions src/dpl/src/Opendp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ bool Opendp::isMultiRow(const Cell* cell) const

Opendp::Opendp()
{
Cell::dummy_cell.is_placed_ = true;
dummy_cell_ = std::make_unique<Cell>();
dummy_cell_->is_placed_ = true;
}

Opendp::~Opendp() = default;
Expand Down Expand Up @@ -378,7 +379,7 @@ void Opendp::groupInitPixels2()
for (Rect& rect : group.region_boundaries) {
if (!isInside(sub, rect) && checkOverlap(sub, rect)) {
pixel->util = 0.0;
pixel->cell = &Cell::dummy_cell;
pixel->cell = dummy_cell_.get();
pixel->is_valid = false;
}
}
Expand Down Expand Up @@ -472,7 +473,7 @@ void Opendp::groupInitPixels()
pixel->is_valid = true;
pixel->util = 1.0;
} else if (pixel->util > 0.0 && pixel->util < 1.0) {
pixel->cell = &Cell::dummy_cell;
pixel->cell = dummy_cell_.get();
pixel->util = 0.0;
pixel->is_valid = false;
}
Expand Down
27 changes: 11 additions & 16 deletions src/gpl/src/placerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ static std::pair<int, int> getMinMaxIdx(int ll,
int minIdx,
int maxIdx);

static utl::Logger* slog_;

static bool isCoreAreaOverlap(Die& die, Instance& inst);

static int64_t getOverlapWithCoreArea(Die& die, Instance& inst);
Expand Down Expand Up @@ -327,11 +325,11 @@ Pin::Pin(odb::dbITerm* iTerm) : Pin()
updateCoordi(iTerm);
}

Pin::Pin(odb::dbBTerm* bTerm) : Pin()
Pin::Pin(odb::dbBTerm* bTerm, utl::Logger* logger) : Pin()
{
setBTerm();
term_ = (void*) bTerm;
updateCoordi(bTerm);
updateCoordi(bTerm, logger);
}

std::string Pin::name() const
Expand Down Expand Up @@ -503,7 +501,7 @@ void Pin::updateCoordi(odb::dbITerm* iTerm)
//
// for BTerm, offset* will hold bbox info.
//
void Pin::updateCoordi(odb::dbBTerm* bTerm)
void Pin::updateCoordi(odb::dbBTerm* bTerm, utl::Logger* logger)
{
int lx = INT_MAX;
int ly = INT_MAX;
Expand All @@ -519,11 +517,12 @@ void Pin::updateCoordi(odb::dbBTerm* bTerm)
}

if (lx == INT_MAX || ly == INT_MAX || ux == INT_MIN || uy == INT_MIN) {
std::string msg = std::string(bTerm->getConstName())
+ " toplevel port is not placed!\n";
msg += " Replace will regard " + std::string(bTerm->getConstName())
+ " is placed in (0, 0)";
slog_->warn(GPL, 1, msg);
logger->warn(GPL,
1,
"{} toplevel port is not placed!\n"
" Replace will regard {} is placed in (0, 0)",
bTerm->getConstName(),
bTerm->getConstName());
}

// Just center
Expand Down Expand Up @@ -773,8 +772,6 @@ PlacerBaseCommon::~PlacerBaseCommon()

void PlacerBaseCommon::init()
{
slog_ = log_;

log_->info(GPL, 2, "DBU: {}", db_->getTech()->getDbUnitsPerMicron());

dbBlock* block = db_->getChip()->getBlock();
Expand Down Expand Up @@ -890,7 +887,7 @@ void PlacerBaseCommon::init()

if (pbVars_.skipIoMode == false) {
for (dbBTerm* bTerm : net->getBTerms()) {
Pin myPin(bTerm);
Pin myPin(bTerm, log_);
myPin.setNet(myNetPtr);
pinStor_.push_back(myPin);
}
Expand Down Expand Up @@ -1029,8 +1026,6 @@ PlacerBase::~PlacerBase()

void PlacerBase::init()
{
slog_ = log_;

die_ = pbCommon_->die();

// siteSize update
Expand Down Expand Up @@ -1161,7 +1156,7 @@ void PlacerBase::initInstsForUnusableSites()
= "Blockages associated with moveable instances "
" are unsupported and ignored [inst: "
+ inst->getName() + "]\n";
slog_->error(GPL, 3, msg);
log_->error(GPL, 3, msg);
continue;
}
dbBox* bbox = blockage->getBBox();
Expand Down
4 changes: 2 additions & 2 deletions src/gpl/src/placerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Pin
public:
Pin();
Pin(odb::dbITerm* iTerm);
Pin(odb::dbBTerm* bTerm);
Pin(odb::dbBTerm* bTerm, utl::Logger* logger);
~Pin();

odb::dbITerm* dbITerm() const;
Expand Down Expand Up @@ -211,7 +211,7 @@ class Pin
unsigned char maxPinYField_ : 1;

void updateCoordi(odb::dbITerm* iTerm);
void updateCoordi(odb::dbBTerm* bTerm);
void updateCoordi(odb::dbBTerm* bTerm, utl::Logger* logger);
};

class Net
Expand Down
194 changes: 0 additions & 194 deletions src/odb/src/db/dbBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3502,200 +3502,6 @@ void dbBlock::keepOldParasitics(std::vector<dbNet*>& nets,
}
}

#if 0
//
// Utility to create a net comprising a single SWire and two BTerms
// Returns pointer to net (nullptr iff not successful)
//
dbNet *
dbBlock::createNetSingleSWire(const char *innm, int x1, int y1, int x2, int y2, uint rlevel)
{
if (!innm)
return nullptr;

dbTech *intech = ((dbDatabase *) (getChip())->getOwner())->getTech();
dbTechLayer *inly = nullptr;
if (!intech || ((inly = intech->findRoutingLayer(rlevel)) == nullptr))
return nullptr;

if (x2 < x1)
std::swap(x1,x2);
if (y2 < y1)
std::swap(y1, y2);

dbNet *nwnet = dbNet::create(this,innm);
if (!nwnet)
return nullptr;

nwnet->setSigType(dbSigType::SIGNAL);

dbSWire *nwsw = dbSWire::create(nwnet, dbWireType::ROUTED);
if (!nwsw)
return nullptr;
dbSBox *nwsbx = dbSBox::create(nwsw, inly, x1, y1, x2, y2, dbWireShapeType::NONE);
if (!nwsbx)
return nullptr;

std::pair<dbBTerm *, dbBTerm *> cktrms = nwnet->createTerms4SingleNet(x1, y1, x2, y2, inly);
if ((cktrms.first == nullptr) || (cktrms.second == nullptr))
return nullptr;

return nwnet;
}

//
// Utility to create a net comprising a single Wire and two BTerms
// Requires creating a suitable non-default rule for the wire if none exists.
// Returns pointer to net (nullptr iff not successful)
//
dbNet *
dbBlock::createNetSingleWire(const char *innm, int x1, int y1, int x2, int y2, uint rlevel, bool skipBterms, dbTechLayerDir indir)
{
static int opendx = -1;

if (!innm)
return nullptr;

dbTech *intech = ((dbDatabase *) (getChip())->getOwner())->getTech();
dbTechLayer *inly = nullptr;
if (!intech || ((inly = intech->findRoutingLayer(rlevel)) == nullptr))
return nullptr;

if (x2 < x1)
std::swap(x1,x2);
if (y2 < y1)
std::swap(y1, y2);

dbNet *nwnet = dbNet::create(this,innm);
if (!nwnet)
return nullptr;

nwnet->setSigType(dbSigType::SIGNAL);

std::pair<dbBTerm *, dbBTerm *> blutrms;
if (! skipBterms ) {
blutrms = nwnet->createTerms4SingleNet(x1, y1, x2, y2, inly);

if ((blutrms.first == nullptr) || (blutrms.second == nullptr))
return nullptr;
}

dbWireEncoder ncdr;
ncdr.begin(dbWire::create(nwnet));

int fwidth;
if (indir == dbTechLayerDir::NONE)
fwidth = std::min(x2 - x1, y2 - y1);
else
fwidth = (indir == dbTechLayerDir::VERTICAL) ? x2 - x1 : y2 - y1;

uint hwidth = fwidth/2;

if (inly->getWidth()==fwidth) {
ncdr.newPath(inly, dbWireType::ROUTED);
}
else {
dbSet<dbTechNonDefaultRule> nd_rules = intech->getNonDefaultRules();
dbSet<dbTechNonDefaultRule>::iterator nditr;
dbTechLayerRule *tst_rule;
dbTechNonDefaultRule *wdth_rule = nullptr;
for (nditr = nd_rules.begin(); nditr != nd_rules.end(); ++nditr)
{
tst_rule = (*nditr)->getLayerRule(inly);
if (tst_rule && (tst_rule->getWidth() == fwidth))
{
wdth_rule = (*nditr);
break;
}
}

char rule_name[14];
dbTechLayer *curly;
if (!wdth_rule)
{
// Find first open slot, opendx static so only search once
if (opendx == -1)
{
for (opendx = 1; opendx <= 300000; ++opendx)
{
snprintf(rule_name, 14, "ADS_ND_%d", opendx);
if ((wdth_rule = dbTechNonDefaultRule::create(intech, rule_name)) != nullptr)
break;
}
}
else
{
snprintf(rule_name, 14, "ADS_ND_%d", ++opendx);
assert(wdth_rule = dbTechNonDefaultRule::create(intech, rule_name));
}

if (!wdth_rule)
{

getImpl()->getLogger()->warn(utl::ODB, 14, "Failed to generate non-default rule for single wire net {}", innm);
return nullptr;
}

dbTechLayerRule *curly_rule;
int i;
for (i = 1; i <= 12; i++) // Twelve routing layers??
{
if ((curly = intech->findRoutingLayer(i)) != nullptr)
{
curly_rule = dbTechLayerRule::create(wdth_rule, curly);
curly_rule->setWidth(MAX(fwidth,curly->getWidth()));
curly_rule->setSpacing(curly->getSpacing());
}
}

dbTechVia *curly_via;
dbSet<dbTechVia> all_vias = intech->getVias();
dbSet<dbTechVia>::iterator viter;
std::string nd_via_name("");
for (viter = all_vias.begin(); viter != all_vias.end(); ++viter)
{
if (((*viter)->getNonDefaultRule() == nullptr) && ((*viter)->isDefault()))
{
nd_via_name = std::string(rule_name) + std::string("_") + std::string((*viter)->getName().c_str());
curly_via = dbTechVia::clone(wdth_rule, (*viter), nd_via_name.c_str());
}
}
}

ncdr.newPath(inly, dbWireType::ROUTED, wdth_rule->getLayerRule(inly));
}
if (((x2-x1) == fwidth) || (indir == dbTechLayerDir::VERTICAL)) {
if ((y2-y1) == fwidth)
ncdr.addPoint(x1+hwidth, y1+hwidth);
else
ncdr.addPoint(x1+hwidth, y1, 0);
//ncdr.addPoint(x1+hwidth, y2);
}
else
ncdr.addPoint(x1, y1+hwidth, 0);

if (! skipBterms )
ncdr.addBTerm(blutrms.first);

if (((x2-x1) == fwidth) || (indir == dbTechLayerDir::VERTICAL)) {
if ((y2-y1) == fwidth)
ncdr.addPoint(x1+hwidth, y2-hwidth+1);
else
ncdr.addPoint(x1+hwidth, y2, 0);
//ncdr.addPoint(x1+hwidth, y2);
}
else
ncdr.addPoint(x2, y1+hwidth, 0);

if (! skipBterms )
ncdr.addBTerm(blutrms.second);

ncdr.end();

return nwnet;
}
#endif

//
// Utility to write db file
//
Expand Down
Loading

0 comments on commit 1cd00ee

Please sign in to comment.