Skip to content

Commit

Permalink
folded in latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfox-rushc committed Jan 8, 2024
2 parents 1a835b2 + 78d7151 commit 257003b
Show file tree
Hide file tree
Showing 60 changed files with 22,725 additions and 18,160 deletions.
12 changes: 0 additions & 12 deletions include/ord/Design.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ class ICeWall;

namespace sta {
class dbSta;
class Corner;
class MinMax;
class LibertyCell;
} // namespace sta

Expand Down Expand Up @@ -165,22 +163,13 @@ class Design

Tech* getTech();

// Timing related methods
enum MinMax
{
Min,
Max
};
float getNetCap(odb::dbNet* net, sta::Corner* corner, MinMax minmax);
bool isSequential(odb::dbMaster* master);
bool isBuffer(odb::dbMaster* master);
bool isInverter(odb::dbMaster* master);
bool isInSupply(odb::dbITerm* pin);
std::string getITermName(odb::dbITerm* pin);
bool isInClock(odb::dbInst* inst);
std::uint64_t getNetRoutedLength(odb::dbNet* net);
float staticPower(odb::dbInst* inst, sta::Corner* corner);
float dynamicPower(odb::dbInst* inst, sta::Corner* corner);

// Services
ifp::InitFloorplan* getFloorplan();
Expand All @@ -205,7 +194,6 @@ class Design

private:
sta::dbSta* getSta();
sta::MinMax* getMinMax(MinMax type);
sta::LibertyCell* getLibertyCell(odb::dbMaster* master);

Tech* tech_;
Expand Down
22 changes: 17 additions & 5 deletions include/ord/Timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class dbMaster;
class dbMTerm;
class dbITerm;
class dbBTerm;
class dbInst;
class dbNet;
} // namespace odb

namespace sta {
Expand Down Expand Up @@ -91,20 +93,30 @@ class Timing
float getPinSlew(odb::dbITerm* db_pin, MinMax minmax = Max);
float getPinSlew(odb::dbBTerm* db_pin, MinMax minmax = Max);

float getPinSlack(odb::dbITerm* db_pin, RiseFall rf, MinMax minmax = Max);
float getPinSlack(odb::dbBTerm* db_pin, RiseFall rf, MinMax minmax = Max);

bool isEndpoint(odb::dbITerm* db_pin);
bool isEndpoint(odb::dbBTerm* db_pin);

float getNetCap(odb::dbNet* net, sta::Corner* corner, MinMax minmax);
float getPortCap(odb::dbITerm* pin, sta::Corner* corner, MinMax minmax);
float staticPower(odb::dbInst* inst, sta::Corner* corner);
float dynamicPower(odb::dbInst* inst, sta::Corner* corner);

std::vector<odb::dbMTerm*> getTimingFanoutFrom(odb::dbMTerm* input);
std::vector<sta::Corner*> getCorners();

private:
sta::LibertyCell* getLibertyCell(odb::dbMaster* master);
sta::dbSta* getSta();
sta::MinMax* getMinMax(MinMax type);
sta::LibertyCell* getLibertyCell(odb::dbMaster* master);
std::array<sta::Vertex*, 2> vertices(const sta::Pin* pin);
bool isEndpoint_(sta::Pin* sta_pin);
float getPinSlew_(sta::Pin* sta_pin, MinMax minmax);
float getPinArrival_(sta::Pin* sta_pin, RiseFall rf, MinMax minmax);
float slew_all_corners(sta::Vertex* vertex, sta::MinMax* minmax);
bool isEndpoint(sta::Pin* sta_pin);
float getPinSlew(sta::Pin* sta_pin, MinMax minmax);
float getPinArrival(sta::Pin* sta_pin, RiseFall rf, MinMax minmax);
float getPinSlack(sta::Pin* sta_pin, RiseFall rf, MinMax minmax);
float slewAllCorners(sta::Vertex* vertex, sta::MinMax* minmax);
std::vector<float> arrivalsClk(const sta::RiseFall* rf,
sta::Clock* clk,
const sta::RiseFall* clk_rf,
Expand Down
42 changes: 0 additions & 42 deletions src/Design.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,6 @@ sta::dbSta* Design::getSta()
return app->getSta();
}

sta::MinMax* Design::getMinMax(MinMax type)
{
return type == Max ? sta::MinMax::max() : sta::MinMax::min();
}

float Design::getNetCap(odb::dbNet* net, sta::Corner* corner, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Net* sta_net = sta->getDbNetwork()->dbToSta(net);

float pin_cap;
float wire_cap;
sta->connectedCap(sta_net, corner, getMinMax(minmax), pin_cap, wire_cap);
return pin_cap + wire_cap;
}

sta::LibertyCell* Design::getLibertyCell(odb::dbMaster* master)
{
sta::dbSta* sta = getSta();
Expand Down Expand Up @@ -220,32 +204,6 @@ bool Design::isSequential(odb::dbMaster* master)
return lib_cell->hasSequentials();
}

float Design::staticPower(odb::dbInst* inst, sta::Corner* corner)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();

sta::Instance* sta_inst = network->dbToSta(inst);
if (!sta_inst) {
return 0.0;
}
sta::PowerResult power = sta->power(sta_inst, corner);
return power.leakage();
}

float Design::dynamicPower(odb::dbInst* inst, sta::Corner* corner)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();

sta::Instance* sta_inst = network->dbToSta(inst);
if (!sta_inst) {
return 0.0;
}
sta::PowerResult power = sta->power(sta_inst, corner);
return (power.internal() + power.switching());
}

bool Design::isInClock(odb::dbInst* inst)
{
for (auto* iterm : inst->getITerms()) {
Expand Down
95 changes: 83 additions & 12 deletions src/Timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ std::pair<odb::dbITerm*, odb::dbBTerm*> Timing::staToDBPin(const sta::Pin* pin)
bool Timing::isEndpoint(odb::dbITerm* db_pin)
{
sta::Pin* sta_pin = getSta()->getDbNetwork()->dbToSta(db_pin);
return isEndpoint_(sta_pin);
return isEndpoint(sta_pin);
}

bool Timing::isEndpoint(odb::dbBTerm* db_pin)
{
sta::Pin* sta_pin = getSta()->getDbNetwork()->dbToSta(db_pin);
return isEndpoint_(sta_pin);
return isEndpoint(sta_pin);
}

bool Timing::isEndpoint_(sta::Pin* sta_pin)
bool Timing::isEndpoint(sta::Pin* sta_pin)
{
auto search = getSta()->search();
auto vertex_array = vertices(sta_pin);
Expand All @@ -98,7 +98,7 @@ bool Timing::isEndpoint_(sta::Pin* sta_pin)
return false;
}

float Timing::slew_all_corners(sta::Vertex* vertex, sta::MinMax* minmax)
float Timing::slewAllCorners(sta::Vertex* vertex, sta::MinMax* minmax)
{
auto sta = getSta();
bool max = (minmax == sta::MinMax::max());
Expand All @@ -116,24 +116,23 @@ float Timing::getPinSlew(odb::dbITerm* db_pin, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinSlew_(sta_pin, minmax);
return getPinSlew(sta_pin, minmax);
}

float Timing::getPinSlew(odb::dbBTerm* db_pin, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinSlew_(sta_pin, minmax);
return getPinSlew(sta_pin, minmax);
}

float Timing::getPinSlew_(sta::Pin* sta_pin, MinMax minmax)
float Timing::getPinSlew(sta::Pin* sta_pin, MinMax minmax)
{
auto vertex_array = vertices(sta_pin);
float pinSlew = (minmax == Max) ? -sta::INF : sta::INF;
auto sta_minmax = (minmax == Max) ? sta::MinMax::max() : sta::MinMax::min();
for (auto vertex : vertex_array) {
if (vertex != nullptr) {
float pinSlewTemp = slew_all_corners(vertex, sta_minmax);
float pinSlewTemp = slewAllCorners(vertex, getMinMax(minmax));
pinSlew = (minmax == Max) ? std::max(pinSlew, pinSlewTemp)
: std::min(pinSlew, pinSlewTemp);
}
Expand Down Expand Up @@ -220,17 +219,17 @@ float Timing::getPinArrival(odb::dbITerm* db_pin, RiseFall rf, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinArrival_(sta_pin, rf, minmax);
return getPinArrival(sta_pin, rf, minmax);
}

float Timing::getPinArrival(odb::dbBTerm* db_pin, RiseFall rf, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinArrival_(sta_pin, rf, minmax);
return getPinArrival(sta_pin, rf, minmax);
}

float Timing::getPinArrival_(sta::Pin* sta_pin, RiseFall rf, MinMax minmax)
float Timing::getPinArrival(sta::Pin* sta_pin, RiseFall rf, MinMax minmax)
{
auto vertex_array = vertices(sta_pin);
float delay = (minmax == Max) ? -sta::INF : sta::INF;
Expand Down Expand Up @@ -263,6 +262,27 @@ std::vector<sta::Corner*> Timing::getCorners()
return {corners->begin(), corners->end()};
}

float Timing::getPinSlack(odb::dbITerm* db_pin, RiseFall rf, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinSlack(sta_pin, rf, minmax);
}

float Timing::getPinSlack(odb::dbBTerm* db_pin, RiseFall rf, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Pin* sta_pin = sta->getDbNetwork()->dbToSta(db_pin);
return getPinSlack(sta_pin, rf, minmax);
}

float Timing::getPinSlack(sta::Pin* sta_pin, RiseFall rf, MinMax minmax)
{
sta::dbSta* sta = getSta();
auto sta_rf = (rf == Rise) ? sta::RiseFall::rise() : sta::RiseFall::fall();
return sta->pinSlack(sta_pin, sta_rf, getMinMax(minmax));
}

// I'd like to return a std::set but swig gave me way too much grief
// so I just copy the set to a vector.
std::vector<odb::dbMTerm*> Timing::getTimingFanoutFrom(odb::dbMTerm* input)
Expand Down Expand Up @@ -300,4 +320,55 @@ std::vector<odb::dbMTerm*> Timing::getTimingFanoutFrom(odb::dbMTerm* input)
return {outputs.begin(), outputs.end()};
}

sta::MinMax* Timing::getMinMax(MinMax type)
{
return type == Max ? sta::MinMax::max() : sta::MinMax::min();
}

float Timing::getNetCap(odb::dbNet* net, sta::Corner* corner, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::Net* sta_net = sta->getDbNetwork()->dbToSta(net);

float pin_cap;
float wire_cap;
sta->connectedCap(sta_net, corner, getMinMax(minmax), pin_cap, wire_cap);
return pin_cap + wire_cap;
}

float Timing::getPortCap(odb::dbITerm* pin, sta::Corner* corner, MinMax minmax)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();
sta::Pin* sta_pin = network->dbToSta(pin);
sta::LibertyPort* lib_port = network->libertyPort(sta_pin);
return sta->capacitance(lib_port, corner, getMinMax(minmax));
}

float Timing::staticPower(odb::dbInst* inst, sta::Corner* corner)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();

sta::Instance* sta_inst = network->dbToSta(inst);
if (!sta_inst) {
return 0.0;
}
sta::PowerResult power = sta->power(sta_inst, corner);
return power.leakage();
}

float Timing::dynamicPower(odb::dbInst* inst, sta::Corner* corner)
{
sta::dbSta* sta = getSta();
sta::dbNetwork* network = sta->getDbNetwork();

sta::Instance* sta_inst = network->dbToSta(inst);
if (!sta_inst) {
return 0.0;
}
sta::PowerResult power = sta->power(sta_inst, corner);
return (power.internal() + power.switching());
}

} // namespace ord
4 changes: 2 additions & 2 deletions src/grt/src/fastroute/include/DataType.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ struct TreeEdge

struct StTree
{
int num_nodes = 0;
int num_terminals = 0;
// The nodes (pin and Steiner nodes) in the tree.
std::vector<TreeNode> nodes;
std::vector<TreeEdge> edges;

int num_edges() const { return num_nodes - 1; }
int num_edges() const { return edges.size(); }
int num_nodes() const { return nodes.size(); }
};

struct OrderNetPin
Expand Down
5 changes: 5 additions & 0 deletions src/grt/src/fastroute/include/FastRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ class FastRouteCore
const int L,
float& slack_th);
void convertToMazeroute();
int splitEdge(std::vector<TreeEdge>& treeedges,
std::vector<TreeNode>& treenodes,
int n1,
int n2,
int edge_n1n2);
void updateCongestionHistory(const int upType, bool stopDEC, int& max_adj);
int getOverflow2D(int* maxOverflow);
int getOverflow2Dmaze(int* maxOverflow, int* tUsage);
Expand Down
1 change: 0 additions & 1 deletion src/grt/src/fastroute/src/RSMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ void FastRouteCore::copyStTree(const int ind, const Tree& rsmt)
const int d = rsmt.deg;
const int numnodes = rsmt.branchCount();
const int numedges = numnodes - 1;
sttrees_[ind].num_nodes = numnodes;
sttrees_[ind].num_terminals = d;
sttrees_[ind].nodes.resize(numnodes);
sttrees_[ind].edges.resize(numedges);
Expand Down
Loading

0 comments on commit 257003b

Please sign in to comment.