2020-06-02 20:08:48 +02:00
|
|
|
// OpenSTA, Static Timing Analyzer
|
2024-01-12 01:34:49 +01:00
|
|
|
// Copyright (c) 2024, Parallax Software, Inc.
|
2020-06-02 20:08:48 +02:00
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2022-01-04 18:17:08 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2020-06-02 20:08:48 +02:00
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2022-01-04 18:17:08 +01:00
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-06-02 20:08:48 +02:00
|
|
|
|
|
|
|
|
#include "CheckCapacitanceLimits.hh"
|
|
|
|
|
|
|
|
|
|
#include "Fuzzy.hh"
|
|
|
|
|
#include "Liberty.hh"
|
|
|
|
|
#include "Network.hh"
|
|
|
|
|
#include "Sdc.hh"
|
2021-10-22 21:05:45 +02:00
|
|
|
#include "InputDrive.hh"
|
2020-06-02 20:08:48 +02:00
|
|
|
#include "DcalcAnalysisPt.hh"
|
2020-06-10 01:03:44 +02:00
|
|
|
#include "GraphDelayCalc.hh"
|
2020-06-02 20:08:48 +02:00
|
|
|
#include "StaState.hh"
|
|
|
|
|
#include "Corner.hh"
|
|
|
|
|
#include "PortDirection.hh"
|
2020-06-15 03:09:51 +02:00
|
|
|
#include "Sim.hh"
|
2020-06-23 03:59:34 +02:00
|
|
|
#include "Graph.hh"
|
|
|
|
|
#include "GraphDelayCalc.hh"
|
2020-06-02 20:08:48 +02:00
|
|
|
|
|
|
|
|
namespace sta {
|
|
|
|
|
|
|
|
|
|
class PinCapacitanceLimitSlackLess
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PinCapacitanceLimitSlackLess(const Corner *corner,
|
|
|
|
|
const MinMax *min_max,
|
|
|
|
|
CheckCapacitanceLimits *check_capacitance_limit,
|
|
|
|
|
const StaState *sta);
|
2023-01-19 19:23:45 +01:00
|
|
|
bool operator()(const Pin *pin1,
|
|
|
|
|
const Pin *pin2) const;
|
2020-06-02 20:08:48 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const Corner *corner_;
|
|
|
|
|
const MinMax *min_max_;
|
|
|
|
|
CheckCapacitanceLimits *check_capacitance_limit_;
|
|
|
|
|
const StaState *sta_;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PinCapacitanceLimitSlackLess::PinCapacitanceLimitSlackLess(const Corner *corner,
|
|
|
|
|
const MinMax *min_max,
|
|
|
|
|
CheckCapacitanceLimits *check_capacitance_limit,
|
|
|
|
|
const StaState *sta) :
|
|
|
|
|
corner_(corner),
|
|
|
|
|
min_max_(min_max),
|
|
|
|
|
check_capacitance_limit_(check_capacitance_limit),
|
|
|
|
|
sta_(sta)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
2023-01-19 19:23:45 +01:00
|
|
|
PinCapacitanceLimitSlackLess::operator()(const Pin *pin1,
|
|
|
|
|
const Pin *pin2) const
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
|
|
|
|
const Corner *corner1, *corner2;
|
|
|
|
|
const RiseFall *rf1, *rf2;
|
|
|
|
|
float capacitance1, capacitance2;
|
|
|
|
|
float limit1, limit2, slack1, slack2;
|
|
|
|
|
check_capacitance_limit_->checkCapacitance(pin1, corner_, min_max_,
|
|
|
|
|
corner1, rf1, capacitance1,
|
|
|
|
|
limit1, slack1);
|
|
|
|
|
check_capacitance_limit_->checkCapacitance(pin2, corner_, min_max_,
|
|
|
|
|
corner2, rf2, capacitance2,
|
|
|
|
|
limit2, slack2);
|
|
|
|
|
return fuzzyLess(slack1, slack2)
|
|
|
|
|
|| (fuzzyEqual(slack1, slack2)
|
|
|
|
|
// Break ties for the sake of regression stability.
|
|
|
|
|
&& sta_->network()->pinLess(pin1, pin2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2020-06-25 16:35:07 +02:00
|
|
|
CheckCapacitanceLimits::CheckCapacitanceLimits(const Sta *sta) :
|
2020-06-02 20:08:48 +02:00
|
|
|
sta_(sta)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CheckCapacitanceLimits::checkCapacitance(const Pin *pin,
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *corner,
|
2020-06-02 20:08:48 +02:00
|
|
|
const MinMax *min_max,
|
|
|
|
|
// Return values.
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *&corner1,
|
|
|
|
|
const RiseFall *&rf1,
|
|
|
|
|
float &capacitance1,
|
|
|
|
|
float &limit1,
|
|
|
|
|
float &slack1) const
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
2021-04-16 20:09:43 +02:00
|
|
|
corner1 = nullptr;
|
|
|
|
|
rf1 = nullptr;
|
|
|
|
|
capacitance1 = 0.0;
|
|
|
|
|
limit1 = 0.0;
|
|
|
|
|
slack1 = MinMax::min()->initValue();
|
|
|
|
|
if (corner)
|
|
|
|
|
checkCapacitance1(pin, corner, min_max,
|
|
|
|
|
corner1, rf1, capacitance1, limit1, slack1);
|
2020-06-02 20:08:48 +02:00
|
|
|
else {
|
2021-04-16 20:09:43 +02:00
|
|
|
for (auto corner : *sta_->corners()) {
|
|
|
|
|
checkCapacitance1(pin, corner, min_max,
|
|
|
|
|
corner1, rf1, capacitance1, limit1, slack1);
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CheckCapacitanceLimits::checkCapacitance1(const Pin *pin,
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *corner,
|
2020-06-02 20:08:48 +02:00
|
|
|
const MinMax *min_max,
|
|
|
|
|
// Return values.
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *&corner1,
|
|
|
|
|
const RiseFall *&rf1,
|
|
|
|
|
float &capacitance1,
|
|
|
|
|
float &limit1,
|
|
|
|
|
float &slack1) const
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
2021-04-16 20:09:43 +02:00
|
|
|
float limit;
|
|
|
|
|
bool limit_exists;
|
|
|
|
|
findLimit(pin, corner, min_max, limit, limit_exists);
|
|
|
|
|
if (limit_exists) {
|
|
|
|
|
for (auto rf : RiseFall::range()) {
|
|
|
|
|
checkCapacitance(pin, corner, min_max, rf, limit,
|
|
|
|
|
corner1, rf1, capacitance1, slack1, limit1);
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-08 15:34:56 +01:00
|
|
|
// Return the tightest limit.
|
2020-06-02 20:08:48 +02:00
|
|
|
void
|
|
|
|
|
CheckCapacitanceLimits::findLimit(const Pin *pin,
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *corner,
|
2020-06-02 20:08:48 +02:00
|
|
|
const MinMax *min_max,
|
|
|
|
|
// Return values.
|
|
|
|
|
float &limit,
|
|
|
|
|
bool &exists) const
|
|
|
|
|
{
|
|
|
|
|
const Network *network = sta_->network();
|
|
|
|
|
Sdc *sdc = sta_->sdc();
|
2020-06-12 23:51:46 +02:00
|
|
|
|
|
|
|
|
// Default to top ("design") limit.
|
|
|
|
|
Cell *top_cell = network->cell(network->topInstance());
|
|
|
|
|
sdc->capacitanceLimit(top_cell, min_max,
|
|
|
|
|
limit, exists);
|
|
|
|
|
|
2020-06-09 05:11:15 +02:00
|
|
|
float limit1;
|
|
|
|
|
bool exists1;
|
2020-06-02 20:08:48 +02:00
|
|
|
if (network->isTopLevelPort(pin)) {
|
|
|
|
|
Port *port = network->port(pin);
|
2020-06-09 05:11:15 +02:00
|
|
|
sdc->capacitanceLimit(port, min_max, limit1, exists1);
|
|
|
|
|
if (exists1
|
|
|
|
|
&& (!exists
|
|
|
|
|
|| min_max->compare(limit, limit1))) {
|
|
|
|
|
limit = limit1;
|
|
|
|
|
exists = true;
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
2021-10-22 21:05:45 +02:00
|
|
|
InputDrive *drive = sdc->findInputDrive(port);
|
|
|
|
|
if (drive) {
|
2022-02-10 18:04:12 +01:00
|
|
|
for (auto rf : RiseFall::range()) {
|
2023-01-19 19:23:45 +01:00
|
|
|
const LibertyCell *cell;
|
|
|
|
|
const LibertyPort *from_port;
|
2022-02-10 18:04:12 +01:00
|
|
|
float *from_slews;
|
2023-01-19 19:23:45 +01:00
|
|
|
const LibertyPort *to_port;
|
2022-02-10 18:04:12 +01:00
|
|
|
drive->driveCell(rf, min_max, cell, from_port, from_slews, to_port);
|
|
|
|
|
if (to_port) {
|
2023-01-19 19:23:45 +01:00
|
|
|
const LibertyPort *corner_port = to_port->cornerPort(corner, min_max);
|
2022-02-10 18:04:12 +01:00
|
|
|
corner_port->capacitanceLimit(min_max, limit1, exists1);
|
|
|
|
|
if (!exists1
|
|
|
|
|
&& corner_port->direction()->isAnyOutput()
|
|
|
|
|
&& min_max == MinMax::max())
|
2023-12-08 15:34:56 +01:00
|
|
|
corner_port->libertyLibrary()->defaultMaxCapacitance(limit1, exists1);
|
2022-02-10 18:04:12 +01:00
|
|
|
if (exists1
|
|
|
|
|
&& (!exists
|
|
|
|
|
|| min_max->compare(limit, limit1))) {
|
|
|
|
|
limit = limit1;
|
|
|
|
|
exists = true;
|
2021-10-22 21:05:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Cell *cell = network->cell(network->instance(pin));
|
|
|
|
|
sdc->capacitanceLimit(cell, min_max,
|
2020-06-09 05:11:15 +02:00
|
|
|
limit1, exists1);
|
|
|
|
|
if (exists1
|
|
|
|
|
&& (!exists
|
|
|
|
|
|| min_max->compare(limit, limit1))) {
|
|
|
|
|
limit = limit1;
|
|
|
|
|
exists = true;
|
|
|
|
|
}
|
|
|
|
|
LibertyPort *port = network->libertyPort(pin);
|
|
|
|
|
if (port) {
|
2022-10-03 20:02:28 +02:00
|
|
|
LibertyPort *corner_port = port->cornerPort(corner, min_max);
|
2021-04-16 20:09:43 +02:00
|
|
|
corner_port->capacitanceLimit(min_max, limit1, exists1);
|
2020-06-09 05:11:15 +02:00
|
|
|
if (!exists1
|
|
|
|
|
&& port->direction()->isAnyOutput())
|
2021-04-16 20:09:43 +02:00
|
|
|
corner_port->libertyLibrary()->defaultMaxCapacitance(limit1, exists1);
|
2020-06-09 05:11:15 +02:00
|
|
|
if (exists1
|
|
|
|
|
&& (!exists
|
|
|
|
|
|| min_max->compare(limit, limit1))) {
|
|
|
|
|
limit = limit1;
|
|
|
|
|
exists = true;
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CheckCapacitanceLimits::checkCapacitance(const Pin *pin,
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *corner,
|
2020-06-02 20:08:48 +02:00
|
|
|
const MinMax *min_max,
|
2021-04-16 20:09:43 +02:00
|
|
|
const RiseFall *rf,
|
|
|
|
|
float limit,
|
2020-06-02 20:08:48 +02:00
|
|
|
// Return values.
|
2021-04-16 20:09:43 +02:00
|
|
|
const Corner *&corner1,
|
|
|
|
|
const RiseFall *&rf1,
|
|
|
|
|
float &capacitance1,
|
|
|
|
|
float &slack1,
|
|
|
|
|
float &limit1) const
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
2021-04-16 20:09:43 +02:00
|
|
|
const DcalcAnalysisPt *dcalc_ap = corner->findDcalcAnalysisPt(min_max);
|
2020-06-25 16:35:07 +02:00
|
|
|
GraphDelayCalc *dcalc = sta_->graphDelayCalc();
|
|
|
|
|
float cap = dcalc->loadCap(pin, dcalc_ap);
|
2020-06-02 20:08:48 +02:00
|
|
|
|
2021-04-16 20:09:43 +02:00
|
|
|
float slack = (min_max == MinMax::max())
|
|
|
|
|
? limit - cap : cap - limit;
|
|
|
|
|
if (slack < slack1
|
2020-12-20 01:27:29 +01:00
|
|
|
// Break ties for the sake of regression stability.
|
2021-04-16 20:09:43 +02:00
|
|
|
|| (fuzzyEqual(slack, slack1)
|
|
|
|
|
&& rf->index() < rf1->index())) {
|
|
|
|
|
corner1 = corner;
|
|
|
|
|
rf1 = rf;
|
|
|
|
|
capacitance1 = cap;
|
|
|
|
|
slack1 = slack;
|
|
|
|
|
limit1 = limit;
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 04:43:51 +01:00
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2023-01-19 19:23:45 +01:00
|
|
|
PinSeq
|
|
|
|
|
CheckCapacitanceLimits::checkCapacitanceLimits(const Net *net,
|
2021-03-07 18:21:53 +01:00
|
|
|
bool violators,
|
|
|
|
|
const Corner *corner,
|
|
|
|
|
const MinMax *min_max)
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
|
|
|
|
const Network *network = sta_->network();
|
2023-01-19 19:23:45 +01:00
|
|
|
PinSeq cap_pins;
|
2021-07-07 05:02:27 +02:00
|
|
|
float min_slack = MinMax::min()->initValue();
|
2021-03-07 18:21:53 +01:00
|
|
|
if (net) {
|
|
|
|
|
NetPinIterator *pin_iter = network->pinIterator(net);
|
|
|
|
|
while (pin_iter->hasNext()) {
|
2023-01-19 19:23:45 +01:00
|
|
|
const Pin *pin = pin_iter->next();
|
2021-03-07 18:21:53 +01:00
|
|
|
checkCapLimits(pin, violators, corner, min_max, cap_pins, min_slack);
|
|
|
|
|
}
|
|
|
|
|
delete pin_iter;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
LeafInstanceIterator *inst_iter = network->leafInstanceIterator();
|
|
|
|
|
while (inst_iter->hasNext()) {
|
|
|
|
|
Instance *inst = inst_iter->next();
|
|
|
|
|
checkCapLimits(inst, violators, corner, min_max, cap_pins, min_slack);
|
|
|
|
|
}
|
|
|
|
|
delete inst_iter;
|
|
|
|
|
// Check top level ports.
|
|
|
|
|
checkCapLimits(network->topInstance(), violators, corner, min_max,
|
|
|
|
|
cap_pins, min_slack);
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
2021-03-07 18:21:53 +01:00
|
|
|
sort(cap_pins, PinCapacitanceLimitSlackLess(corner, min_max, this, sta_));
|
|
|
|
|
// Keep the min slack pin unless all violators or net pins.
|
2023-01-19 19:23:45 +01:00
|
|
|
if (!cap_pins.empty() && !violators && net == nullptr)
|
|
|
|
|
cap_pins.resize(1);
|
2021-03-07 18:21:53 +01:00
|
|
|
return cap_pins;
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-01-19 19:23:45 +01:00
|
|
|
CheckCapacitanceLimits::checkCapLimits(const Instance *inst,
|
2021-03-07 18:21:53 +01:00
|
|
|
bool violators,
|
|
|
|
|
const Corner *corner,
|
|
|
|
|
const MinMax *min_max,
|
2023-01-19 19:23:45 +01:00
|
|
|
PinSeq &cap_pins,
|
2021-03-07 18:21:53 +01:00
|
|
|
float &min_slack)
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
|
|
|
|
const Network *network = sta_->network();
|
|
|
|
|
InstancePinIterator *pin_iter = network->pinIterator(inst);
|
|
|
|
|
while (pin_iter->hasNext()) {
|
|
|
|
|
Pin *pin = pin_iter->next();
|
2021-03-07 18:21:53 +01:00
|
|
|
checkCapLimits(pin, violators, corner, min_max, cap_pins, min_slack);
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
delete pin_iter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-01-19 19:23:45 +01:00
|
|
|
CheckCapacitanceLimits::checkCapLimits(const Pin *pin,
|
2021-03-07 18:21:53 +01:00
|
|
|
bool violators,
|
|
|
|
|
const Corner *corner,
|
|
|
|
|
const MinMax *min_max,
|
2023-01-19 19:23:45 +01:00
|
|
|
PinSeq &cap_pins,
|
2021-03-07 18:21:53 +01:00
|
|
|
float &min_slack)
|
2020-06-02 20:08:48 +02:00
|
|
|
{
|
2021-03-07 18:21:53 +01:00
|
|
|
if (checkPin(pin)) {
|
|
|
|
|
const Corner *corner1;
|
|
|
|
|
const RiseFall *rf;
|
|
|
|
|
float capacitance, limit, slack;
|
|
|
|
|
checkCapacitance(pin, corner, min_max, corner1, rf, capacitance, limit, slack);
|
|
|
|
|
if (!fuzzyInf(slack)) {
|
|
|
|
|
if (violators) {
|
|
|
|
|
if (slack < 0.0)
|
2023-01-19 19:23:45 +01:00
|
|
|
cap_pins.push_back(pin);
|
2021-03-07 18:21:53 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2023-01-19 19:23:45 +01:00
|
|
|
if (cap_pins.empty()
|
2021-03-07 18:21:53 +01:00
|
|
|
|| slack < min_slack) {
|
2023-01-19 19:23:45 +01:00
|
|
|
cap_pins.push_back(pin);
|
2021-03-07 18:21:53 +01:00
|
|
|
min_slack = slack;
|
|
|
|
|
}
|
2020-06-15 03:09:51 +02:00
|
|
|
}
|
2020-06-02 20:08:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-15 06:23:26 +02:00
|
|
|
bool
|
2023-01-19 19:23:45 +01:00
|
|
|
CheckCapacitanceLimits::checkPin(const Pin *pin)
|
2020-06-15 06:23:26 +02:00
|
|
|
{
|
|
|
|
|
const Network *network = sta_->network();
|
|
|
|
|
const Sim *sim = sta_->sim();
|
|
|
|
|
const Sdc *sdc = sta_->sdc();
|
2020-06-23 03:59:34 +02:00
|
|
|
const Graph *graph = sta_->graph();
|
|
|
|
|
Vertex *vertex = graph->pinLoadVertex(pin);
|
2021-10-22 21:05:45 +02:00
|
|
|
return network->isDriver(pin)
|
2020-06-15 06:23:26 +02:00
|
|
|
&& !sim->logicZeroOne(pin)
|
2020-06-23 03:59:34 +02:00
|
|
|
&& !sdc->isDisabled(pin)
|
2020-06-25 16:35:07 +02:00
|
|
|
&& !(vertex && sta_->isIdealClock(pin));
|
2020-06-15 06:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-02 20:08:48 +02:00
|
|
|
} // namespace
|