Liberty:cornerCell, cornerPort use corner/min_max arg

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2022-10-03 11:02:28 -07:00
parent eb705fab1a
commit 9d6bad01cc
7 changed files with 58 additions and 36 deletions

View File

@ -46,6 +46,7 @@ class TimingArcAttrs;
class InternalPowerAttrs; class InternalPowerAttrs;
class LibertyPgPort; class LibertyPgPort;
class StaState; class StaState;
class Corner;
typedef Set<Library*> LibrarySet; typedef Set<Library*> LibrarySet;
typedef Map<const char*, TableTemplate*, CharPtrLess> TableTemplateMap; typedef Map<const char*, TableTemplate*, CharPtrLess> TableTemplateMap;
@ -443,7 +444,10 @@ public:
RiseFall *&enable_rf) const; RiseFall *&enable_rf) const;
RiseFall *latchCheckEnableEdge(TimingArcSet *check_set); RiseFall *latchCheckEnableEdge(TimingArcSet *check_set);
bool isDisabledConstraint() const { return is_disabled_constraint_; } bool isDisabledConstraint() const { return is_disabled_constraint_; }
LibertyCell *cornerCell(int ap_index); LibertyCell *cornerCell(const Corner *corner,
const MinMax *min_max);
const LibertyCell *cornerCell(const Corner *corner,
const MinMax *min_max) const;
// AOCV // AOCV
float ocvArcDepth() const; float ocvArcDepth() const;
@ -712,8 +716,10 @@ public:
RiseFall *sense); RiseFall *sense);
bool isDisabledConstraint() const { return is_disabled_constraint_; } bool isDisabledConstraint() const { return is_disabled_constraint_; }
void setIsDisabledConstraint(bool is_disabled); void setIsDisabledConstraint(bool is_disabled);
LibertyPort *cornerPort(int ap_index); LibertyPort *cornerPort(const Corner *corner,
const LibertyPort *cornerPort(int ap_index) const; const MinMax *min_max);
const LibertyPort *cornerPort(const Corner *corner,
const MinMax *min_max) const;
void setCornerPort(LibertyPort *corner_port, void setCornerPort(LibertyPort *corner_port,
int ap_index); int ap_index);
const char *relatedGroundPin() const { return related_ground_pin_; } const char *relatedGroundPin() const { return related_ground_pin_; }

View File

@ -36,6 +36,7 @@
#include "EquivCells.hh" #include "EquivCells.hh"
#include "Network.hh" #include "Network.hh"
#include "PortDirection.hh" #include "PortDirection.hh"
#include "Corner.hh"
namespace sta { namespace sta {
@ -1498,12 +1499,28 @@ LibertyCell::setIsDisabledConstraint(bool is_disabled)
} }
LibertyCell * LibertyCell *
LibertyCell::cornerCell(int ap_index) LibertyCell::cornerCell(const Corner *corner,
const MinMax *min_max)
{ {
if (ap_index < static_cast<int>(corner_cells_.size())) if (corner_cells_.empty())
return this;
else {
int ap_index = corner->libertyIndex(min_max);
return corner_cells_[ap_index]; return corner_cells_[ap_index];
else }
return nullptr; }
const LibertyCell *
LibertyCell::cornerCell(const Corner *corner,
const MinMax *min_max) const
{
if (corner_cells_.empty())
return this;
else {
int ap_index = corner->libertyIndex(min_max);
return corner_cells_[ap_index];
}
} }
void void
@ -2324,25 +2341,27 @@ LibertyPort::setIsDisabledConstraint(bool is_disabled)
} }
LibertyPort * LibertyPort *
LibertyPort::cornerPort(int ap_index) LibertyPort::cornerPort(const Corner *corner,
const MinMax *min_max)
{ {
if (ap_index < static_cast<int>(corner_ports_.size())) { if (corner_ports_.empty())
LibertyPort *corner_port = corner_ports_[ap_index]; return this;
if (corner_port) else {
return corner_port; int ap_index = corner->libertyIndex(min_max);
return corner_ports_[ap_index];
} }
return this;
} }
const LibertyPort * const LibertyPort *
LibertyPort::cornerPort(int ap_index) const LibertyPort::cornerPort(const Corner *corner,
const MinMax *min_max) const
{ {
if (ap_index < static_cast<int>(corner_ports_.size())) { if (corner_ports_.empty())
LibertyPort *corner_port = corner_ports_[ap_index]; return this;
if (corner_port) else {
return corner_port; int ap_index = corner->libertyIndex(min_max);
return corner_ports_[ap_index];
} }
return this;
} }
void void

View File

@ -3296,7 +3296,7 @@ Sdc::portCapacitance(Instance *inst,
Pvt *inst_pvt = nullptr; Pvt *inst_pvt = nullptr;
if (inst) if (inst)
inst_pvt = pvt(inst, min_max); inst_pvt = pvt(inst, min_max);
LibertyPort *corner_port = port->cornerPort(corner->libertyIndex(min_max)); LibertyPort *corner_port = port->cornerPort(corner, min_max);
return corner_port->capacitance(rf, min_max, op_cond, inst_pvt); return corner_port->capacitance(rf, min_max, op_cond, inst_pvt);
} }

View File

@ -174,7 +174,7 @@ CheckCapacitanceLimits::findLimit(const Pin *pin,
LibertyPort *to_port; LibertyPort *to_port;
drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port);
if (to_port) { if (to_port) {
LibertyPort *corner_port = to_port->cornerPort(corner->libertyIndex(min_max)); LibertyPort *corner_port = to_port->cornerPort(corner, min_max);
corner_port->capacitanceLimit(min_max, limit1, exists1); corner_port->capacitanceLimit(min_max, limit1, exists1);
if (!exists1 if (!exists1
&& corner_port->direction()->isAnyOutput() && corner_port->direction()->isAnyOutput()
@ -202,7 +202,7 @@ CheckCapacitanceLimits::findLimit(const Pin *pin,
} }
LibertyPort *port = network->libertyPort(pin); LibertyPort *port = network->libertyPort(pin);
if (port) { if (port) {
LibertyPort *corner_port = port->cornerPort(corner->libertyIndex(min_max)); LibertyPort *corner_port = port->cornerPort(corner, min_max);
corner_port->capacitanceLimit(min_max, limit1, exists1); corner_port->capacitanceLimit(min_max, limit1, exists1);
if (!exists1 if (!exists1
&& port->direction()->isAnyOutput()) && port->direction()->isAnyOutput())

View File

@ -224,7 +224,7 @@ CheckSlewLimits::findLimit(const Pin *pin,
LibertyPort *to_port; LibertyPort *to_port;
drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port); drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port);
if (to_port) { if (to_port) {
LibertyPort *corner_port = to_port->cornerPort(corner->libertyIndex(min_max)); LibertyPort *corner_port = to_port->cornerPort(corner, min_max);
corner_port->slewLimit(min_max, limit1, exists1); corner_port->slewLimit(min_max, limit1, exists1);
if (!exists1 if (!exists1
&& corner_port->direction()->isAnyOutput() && corner_port->direction()->isAnyOutput()
@ -268,7 +268,7 @@ CheckSlewLimits::findLimit(const LibertyPort *port,
} }
if (port) { if (port) {
const LibertyPort *corner_port = port->cornerPort(corner->libertyIndex(min_max)); const LibertyPort *corner_port = port->cornerPort(corner, min_max);
corner_port->slewLimit(min_max, limit1, exists1); corner_port->slewLimit(min_max, limit1, exists1);
if (!exists1 if (!exists1
// default_max_transition only applies to outputs. // default_max_transition only applies to outputs.

View File

@ -641,9 +641,9 @@ Power::findInputInternalPower(const Pin *pin,
// Return values. // Return values.
PowerResult &result) PowerResult &result)
{ {
int lib_ap_index = corner->libertyIndex(MinMax::max()); const MinMax *min_max = MinMax::max();
LibertyCell *corner_cell = cell->cornerCell(lib_ap_index); LibertyCell *corner_cell = cell->cornerCell(corner, min_max);
const LibertyPort *corner_port = port->cornerPort(lib_ap_index); const LibertyPort *corner_port = port->cornerPort(corner, min_max);
if (corner_cell && corner_port) { if (corner_cell && corner_port) {
const InternalPowerSeq &internal_pwrs = corner_cell->internalPowers(corner_port); const InternalPowerSeq &internal_pwrs = corner_cell->internalPowers(corner_port);
if (!internal_pwrs.empty()) { if (!internal_pwrs.empty()) {
@ -784,9 +784,9 @@ Power::findOutputInternalPower(const Pin *to_pin,
cell->name()); cell->name());
const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(MinMax::max()); const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(MinMax::max());
const Pvt *pvt = dcalc_ap->operatingConditions(); const Pvt *pvt = dcalc_ap->operatingConditions();
int lib_ap_index = corner->libertyIndex(MinMax::max()); const MinMax *min_max = MinMax::max();
LibertyCell *corner_cell = cell->cornerCell(lib_ap_index); LibertyCell *corner_cell = cell->cornerCell(corner, min_max);
const LibertyPort *to_corner_port = to_port->cornerPort(lib_ap_index); const LibertyPort *to_corner_port = to_port->cornerPort(corner, min_max);
debugPrint(debug_, "power", 2, " cap = %s", debugPrint(debug_, "power", 2, " cap = %s",
units_->capacitanceUnit()->asString(load_cap)); units_->capacitanceUnit()->asString(load_cap));
FuncExpr *func = to_port->function(); FuncExpr *func = to_port->function();
@ -936,8 +936,7 @@ Power::findLeakagePower(const Instance *,
// Return values. // Return values.
PowerResult &result) PowerResult &result)
{ {
int lib_ap_index = corner->libertyIndex(MinMax::max()); LibertyCell *corner_cell = cell->cornerCell(corner, MinMax::max());
LibertyCell *corner_cell = cell->cornerCell(lib_ap_index);
float cond_leakage = 0.0; float cond_leakage = 0.0;
bool found_cond = false; bool found_cond = false;
float default_leakage = 0.0; float default_leakage = 0.0;
@ -1000,8 +999,7 @@ Power::findSwitchingPower(LibertyCell *cell,
{ {
MinMax *mm = MinMax::max(); MinMax *mm = MinMax::max();
const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(mm); const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(mm);
int lib_ap_index = corner->libertyIndex(MinMax::max()); LibertyCell *corner_cell = cell->cornerCell(corner, MinMax::max());
LibertyCell *corner_cell = cell->cornerCell(lib_ap_index);
float volt = portVoltage(corner_cell, to_port, dcalc_ap); float volt = portVoltage(corner_cell, to_port, dcalc_ap);
float switching = .5 * load_cap * volt * volt * activity.activity(); float switching = .5 * load_cap * volt * volt * activity.activity();
debugPrint(debug_, "power", 2, "switching %s/%s activity = %.2e volt = %.2f %.3e", debugPrint(debug_, "power", 2, "switching %s/%s activity = %.2e volt = %.2f %.3e",

View File

@ -3775,8 +3775,7 @@ Sta::capacitance(const LibertyPort *port,
OperatingConditions *op_cond = operatingConditions(min_max); OperatingConditions *op_cond = operatingConditions(min_max);
float cap = min_max->initValue(); float cap = min_max->initValue();
for (const Corner *corner : makeCornerSeq(corner)) { for (const Corner *corner : makeCornerSeq(corner)) {
int lib_ap = corner->libertyIndex(min_max); const LibertyPort *corner_port = port->cornerPort(corner, min_max);
const LibertyPort *corner_port = port->cornerPort(lib_ap);
for (RiseFall *rf : RiseFall::range()) for (RiseFall *rf : RiseFall::range())
cap = min_max->minMax(cap, corner_port->capacitance(rf, min_max, op_cond, op_cond)); cap = min_max->minMax(cap, corner_port->capacitance(rf, min_max, op_cond, op_cond));
} }