OpenSTA/sdc/InputDrive.cc

225 lines
5.4 KiB
C++
Raw Normal View History

2018-09-28 17:54:21 +02:00
// OpenSTA, Static Timing Analyzer
2020-03-07 03:50:37 +01:00
// Copyright (c) 2020, Parallax Software, Inc.
2018-09-28 17:54:21 +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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2020-04-05 23:53:44 +02:00
#include "InputDrive.hh"
2018-09-28 17:54:21 +02:00
namespace sta {
2019-03-13 01:25:53 +01:00
InputDrive::InputDrive()
2018-09-28 17:54:21 +02:00
{
2019-11-11 23:30:19 +01:00
for (auto tr_index : RiseFall::rangeIndex()) {
2019-07-18 15:19:00 +02:00
for (auto mm_index : MinMax::rangeIndex())
drive_cells_[tr_index][mm_index] = nullptr;
2018-09-28 17:54:21 +02:00
}
}
InputDrive::~InputDrive()
{
2019-11-11 23:30:19 +01:00
for (auto tr_index : RiseFall::rangeIndex()) {
2019-07-18 15:19:00 +02:00
for (auto mm_index : MinMax::rangeIndex()) {
InputDriveCell *drive_cell = drive_cells_[tr_index][mm_index];
2018-09-28 17:54:21 +02:00
delete drive_cell;
}
}
}
void
2019-11-11 23:30:19 +01:00
InputDrive::setSlew(const RiseFallBoth *rf,
2018-09-28 17:54:21 +02:00
const MinMaxAll *min_max,
float slew)
{
2019-11-11 23:30:19 +01:00
slews_.setValue(rf, min_max, slew);
2018-09-28 17:54:21 +02:00
}
void
2019-11-11 23:30:19 +01:00
InputDrive::setDriveResistance(const RiseFallBoth *rf,
2018-09-28 17:54:21 +02:00
const MinMaxAll *min_max,
float res)
{
2019-11-11 23:30:19 +01:00
drive_resistances_.setValue(rf, min_max, res);
2018-09-28 17:54:21 +02:00
}
void
2019-11-11 23:30:19 +01:00
InputDrive::driveResistance(const RiseFall *rf,
2018-09-28 17:54:21 +02:00
const MinMax *min_max,
float &res,
bool &exists)
{
2019-11-11 23:30:19 +01:00
drive_resistances_.value(rf, min_max, res, exists);
2018-09-28 17:54:21 +02:00
}
bool
2019-11-11 23:30:19 +01:00
InputDrive::hasDriveResistance(const RiseFall *rf, const MinMax *min_max)
2018-09-28 17:54:21 +02:00
{
2019-11-11 23:30:19 +01:00
return drive_resistances_.hasValue(rf, min_max);
2018-09-28 17:54:21 +02:00
}
bool
2019-11-11 23:30:19 +01:00
InputDrive::driveResistanceMinMaxEqual(const RiseFall *rf)
2018-09-28 17:54:21 +02:00
{
float min_res, max_res;
bool min_exists, max_exists;
2019-11-11 23:30:19 +01:00
drive_resistances_.value(rf, MinMax::min(), min_res, min_exists);
drive_resistances_.value(rf, MinMax::max(), max_res, max_exists);
2018-09-28 17:54:21 +02:00
return min_exists && max_exists && min_res == max_res;
}
void
2019-02-16 21:07:59 +01:00
InputDrive::setDriveCell(LibertyLibrary *library,
LibertyCell *cell,
2018-09-28 17:54:21 +02:00
LibertyPort *from_port,
float *from_slews,
LibertyPort *to_port,
2019-11-11 23:30:19 +01:00
const RiseFallBoth *rf,
2018-09-28 17:54:21 +02:00
const MinMaxAll *min_max)
{
2019-11-11 23:30:19 +01:00
for (auto rf_index : rf->rangeIndex()) {
2019-07-18 15:19:00 +02:00
for (auto mm_index : min_max->rangeIndex()) {
2019-11-11 23:30:19 +01:00
InputDriveCell *drive = drive_cells_[rf_index][mm_index];
2018-09-28 17:54:21 +02:00
if (drive) {
2019-02-16 21:07:59 +01:00
drive->setLibrary(library);
2018-09-28 17:54:21 +02:00
drive->setCell(cell);
drive->setFromPort(from_port);
drive->setFromSlews(from_slews);
drive->setToPort(to_port);
}
else {
2019-02-16 21:07:59 +01:00
drive = new InputDriveCell(library, cell, from_port,
from_slews, to_port);
2019-11-11 23:30:19 +01:00
drive_cells_[rf_index][mm_index] = drive;
2018-09-28 17:54:21 +02:00
}
}
}
}
void
2019-11-11 23:30:19 +01:00
InputDrive::driveCell(const RiseFall *rf,
2018-09-28 17:54:21 +02:00
const MinMax *min_max,
LibertyCell *&cell,
LibertyPort *&from_port,
float *&from_slews,
LibertyPort *&to_port)
{
2019-11-11 23:30:19 +01:00
InputDriveCell *drive = drive_cells_[rf->index()][min_max->index()];
2018-09-28 17:54:21 +02:00
if (drive) {
cell = drive->cell();
from_port = drive->fromPort();
from_slews = drive->fromSlews();
to_port = drive->toPort();
}
else
2019-03-13 01:25:53 +01:00
cell = nullptr;
2018-09-28 17:54:21 +02:00
}
InputDriveCell *
2019-11-11 23:30:19 +01:00
InputDrive::driveCell(const RiseFall *rf,
2018-09-28 17:54:21 +02:00
const MinMax *min_max)
{
2019-11-11 23:30:19 +01:00
return drive_cells_[rf->index()][min_max->index()];
2018-09-28 17:54:21 +02:00
}
bool
2019-11-11 23:30:19 +01:00
InputDrive::hasDriveCell(const RiseFall *rf,
2018-09-28 17:54:21 +02:00
const MinMax *min_max)
{
2019-11-11 23:30:19 +01:00
return drive_cells_[rf->index()][min_max->index()] != nullptr;
2018-09-28 17:54:21 +02:00
}
bool
InputDrive::driveCellsEqual()
{
2019-11-11 23:30:19 +01:00
int rise_index = RiseFall::riseIndex();
int fall_index = RiseFall::fallIndex();
2018-09-28 17:54:21 +02:00
int min_index = MinMax::minIndex();
int max_index = MinMax::maxIndex();
InputDriveCell *drive1 = drive_cells_[rise_index][min_index];
InputDriveCell *drive2 = drive_cells_[rise_index][max_index];
InputDriveCell *drive3 = drive_cells_[fall_index][min_index];
InputDriveCell *drive4 = drive_cells_[fall_index][max_index];
return drive1->equal(drive2)
&& drive1->equal(drive3)
&& drive1->equal(drive4);
}
void
2019-11-11 23:30:19 +01:00
InputDrive::slew(const RiseFall *rf,
2018-09-28 17:54:21 +02:00
const MinMax *min_max,
float &slew,
bool &exists)
{
2019-11-11 23:30:19 +01:00
slews_.value(rf, min_max, slew, exists);
2018-09-28 17:54:21 +02:00
}
////////////////////////////////////////////////////////////////
2019-02-16 21:07:59 +01:00
InputDriveCell::InputDriveCell(LibertyLibrary *library,
LibertyCell *cell,
2018-09-28 17:54:21 +02:00
LibertyPort *from_port,
float *from_slews,
LibertyPort *to_port) :
2019-02-16 21:07:59 +01:00
library_(library),
2018-09-28 17:54:21 +02:00
cell_(cell),
from_port_(from_port),
to_port_(to_port)
{
setFromSlews(from_slews);
}
2019-02-16 21:07:59 +01:00
void
InputDriveCell::setLibrary(LibertyLibrary *library)
{
library_ = library;
}
2018-09-28 17:54:21 +02:00
void
InputDriveCell::setCell(LibertyCell *cell)
{
cell_ = cell;
}
void
InputDriveCell::setFromPort(LibertyPort *from_port)
{
from_port_ = from_port;
}
void
InputDriveCell::setToPort(LibertyPort *to_port)
{
to_port_ = to_port;
}
void
InputDriveCell::setFromSlews(float *from_slews)
{
2019-11-11 23:30:19 +01:00
for (auto tr_index : RiseFall::rangeIndex())
2019-07-18 15:19:00 +02:00
from_slews_[tr_index] = from_slews[tr_index];
2018-09-28 17:54:21 +02:00
}
bool
InputDriveCell::equal(InputDriveCell *drive) const
{
2019-11-11 23:30:19 +01:00
int rise_index = RiseFall::riseIndex();
int fall_index = RiseFall::fallIndex();
2018-09-28 17:54:21 +02:00
return cell_ == drive->cell_
&& from_port_ == drive->from_port_
&& from_slews_[rise_index] == drive->from_slews_[rise_index]
&& from_slews_[fall_index] == drive->from_slews_[fall_index]
&& to_port_ == drive->to_port_;
}
} // namespace