Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#5134 from bingyuew/cad_contest
Browse files Browse the repository at this point in the history
Adding Timing::equivCells and Timing::makeEquivCells python APIs
  • Loading branch information
maliberty authored May 18, 2024
2 parents a6a172b + 2f7865f commit dac8235
Show file tree
Hide file tree
Showing 7 changed files with 1,950 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/ord/Timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class Timing
sta::Corner* cmdCorner();
sta::Corner* findCorner(const char* name);

void makeEquivCells();
std::vector<odb::dbMaster*> equivCells(odb::dbMaster* master);

private:
sta::dbSta* getSta();
sta::MinMax* getMinMax(MinMax type);
Expand Down
1 change: 1 addition & 0 deletions src/OpenRoad-py.i
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ get_db_block();

%template(Corners) std::vector<sta::Corner*>;
%template(MTerms) std::vector<odb::dbMTerm*>;
%template(Masters) std::vector<odb::dbMaster*>;

%include "Exception-py.i"
%include "ord/Tech.h"
Expand Down
30 changes: 29 additions & 1 deletion src/Timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
#include "odb/db.h"
#include "ord/OpenRoad.hh"
#include "sta/Search.hh"
//#include "ord/Tech.h"
// #include "ord/Tech.h"
#include "ord/Design.h"
#include "rsz/Resizer.hh"
#include "sta/Corner.hh"
#include "sta/Liberty.hh"
#include "sta/TimingArc.hh"
Expand Down Expand Up @@ -385,4 +386,31 @@ float Timing::dynamicPower(odb::dbInst* inst, sta::Corner* corner)
return (power.internal() + power.switching());
}

void Timing::makeEquivCells()
{
auto app = OpenRoad::openRoad();
rsz::Resizer* resizer = app->getResizer();
resizer->makeEquivCells();
}

std::vector<odb::dbMaster*> Timing::equivCells(odb::dbMaster* master)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();
sta::Cell* cell = network->dbToSta(master);
std::vector<odb::dbMaster*> masterSeq;
if (cell) {
sta::LibertyCell* libcell = network->libertyCell(cell);
sta::LibertyCellSeq* equiv_cells = sta->equivCells(libcell);
if (equiv_cells) {
for (sta::LibertyCell* equiv_cell : *equiv_cells) {
odb::dbMaster* equiv_master = network->staToDb(equiv_cell);
masterSeq.emplace_back(equiv_master);
}
} else {
masterSeq.emplace_back(master);
}
}
return masterSeq;
}
} // namespace ord
2 changes: 1 addition & 1 deletion src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ class Resizer : public dbStaState
dbBlock* getDbBlock() { return block_; };
double dbuToMeters(int dist) const;
int metersToDbu(double dist) const;
void makeEquivCells();

protected:
void init();
Expand All @@ -390,7 +391,6 @@ class Resizer : public dbStaState
void bufferOutput(const Pin* top_pin, LibertyCell* buffer_cell);
bool hasTristateOrDontTouchDriver(const Net* net);
bool isTristateDriver(const Pin* pin);
void makeEquivCells();
void checkLibertyForAllCorners();
void findBuffers();
bool isLinkCell(LibertyCell* cell);
Expand Down
1 change: 1 addition & 0 deletions test/regression_tests.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ record_tests {
timing_api
timing_api_2
timing_api_3
timing_api_4
upf_test
upf_aes
two_designs
Expand Down
Loading

0 comments on commit dac8235

Please sign in to comment.