Files
OpenSTA/sdc/InputDrive.cc
T

241 lines
6.6 KiB
C++
Raw Normal View History

2018-09-28 08:54:21 -07:00
// OpenSTA, Static Timing Analyzer
2026-03-10 13:21:17 -07:00
// Copyright (c) 2026, Parallax Software, Inc.
2018-09-28 08:54:21 -07: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 10:17:08 -07:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2018-09-28 08:54:21 -07:00
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
2022-01-04 10:17:08 -07:00
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2025-01-21 18:54:33 -07:00
//
// The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software.
//
// Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// This notice may not be removed or altered from any source distribution.
2018-09-28 08:54:21 -07:00
2020-04-05 14:53:44 -07:00
#include "InputDrive.hh"
2018-09-28 08:54:21 -07:00
2026-04-15 09:38:10 -07:00
#include "SdcClass.hh"
2018-09-28 08:54:21 -07:00
namespace sta {
2019-03-12 17:25:53 -07:00
InputDrive::InputDrive()
2018-09-28 08:54:21 -07:00
{
2024-06-27 13:57:58 -07:00
for (auto rf_index : RiseFall::rangeIndex()) {
2019-07-18 06:19:00 -07:00
for (auto mm_index : MinMax::rangeIndex())
2024-06-27 13:57:58 -07:00
drive_cells_[rf_index][mm_index] = nullptr;
2018-09-28 08:54:21 -07:00
}
}
InputDrive::~InputDrive()
{
2024-06-27 13:57:58 -07:00
for (auto rf_index : RiseFall::rangeIndex()) {
2019-07-18 06:19:00 -07:00
for (auto mm_index : MinMax::rangeIndex()) {
2024-06-27 13:57:58 -07:00
InputDriveCell *drive_cell = drive_cells_[rf_index][mm_index];
2018-09-28 08:54:21 -07:00
delete drive_cell;
}
}
}
void
2019-11-11 15:30:19 -07:00
InputDrive::setSlew(const RiseFallBoth *rf,
2026-01-03 16:59:35 -08:00
const MinMaxAll *min_max,
float slew)
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
slews_.setValue(rf, min_max, slew);
2018-09-28 08:54:21 -07:00
}
void
2019-11-11 15:30:19 -07:00
InputDrive::setDriveResistance(const RiseFallBoth *rf,
2026-01-03 16:59:35 -08:00
const MinMaxAll *min_max,
float res)
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
drive_resistances_.setValue(rf, min_max, res);
2018-09-28 08:54:21 -07:00
}
void
2019-11-11 15:30:19 -07:00
InputDrive::driveResistance(const RiseFall *rf,
2026-01-03 16:59:35 -08:00
const MinMax *min_max,
float &res,
bool &exists) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
drive_resistances_.value(rf, min_max, res, exists);
2018-09-28 08:54:21 -07:00
}
bool
2025-02-01 14:53:28 -08:00
InputDrive::hasDriveResistance(const RiseFall *rf,
const MinMax *min_max) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
return drive_resistances_.hasValue(rf, min_max);
2018-09-28 08:54:21 -07:00
}
bool
2025-02-01 14:53:28 -08:00
InputDrive::driveResistanceMinMaxEqual(const RiseFall *rf) const
2018-09-28 08:54:21 -07:00
{
float min_res, max_res;
bool min_exists, max_exists;
2019-11-11 15:30:19 -07:00
drive_resistances_.value(rf, MinMax::min(), min_res, min_exists);
drive_resistances_.value(rf, MinMax::max(), max_res, max_exists);
2018-09-28 08:54:21 -07:00
return min_exists && max_exists && min_res == max_res;
}
void
2023-01-19 11:23:45 -07:00
InputDrive::setDriveCell(const LibertyLibrary *library,
2026-01-03 16:59:35 -08:00
const LibertyCell *cell,
const LibertyPort *from_port,
2026-04-15 09:38:10 -07:00
const DriveCellSlews &from_slews,
2026-01-03 16:59:35 -08:00
const LibertyPort *to_port,
const RiseFallBoth *rf,
const MinMaxAll *min_max)
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
for (auto rf_index : rf->rangeIndex()) {
2019-07-18 06:19:00 -07:00
for (auto mm_index : min_max->rangeIndex()) {
2019-11-11 15:30:19 -07:00
InputDriveCell *drive = drive_cells_[rf_index][mm_index];
2018-09-28 08:54:21 -07:00
if (drive) {
2026-01-03 16:59:35 -08:00
drive->setLibrary(library);
drive->setCell(cell);
drive->setFromPort(from_port);
drive->setFromSlews(from_slews);
drive->setToPort(to_port);
2018-09-28 08:54:21 -07:00
}
else {
2026-01-03 16:59:35 -08:00
drive = new InputDriveCell(library, cell, from_port,
from_slews, to_port);
drive_cells_[rf_index][mm_index] = drive;
2018-09-28 08:54:21 -07:00
}
}
}
}
void
2019-11-11 15:30:19 -07:00
InputDrive::driveCell(const RiseFall *rf,
2026-01-03 16:59:35 -08:00
const MinMax *min_max,
// Return values.
2026-01-03 16:59:35 -08:00
const LibertyCell *&cell,
const LibertyPort *&from_port,
2026-04-15 09:38:10 -07:00
const DriveCellSlews *&from_slews,
2026-01-03 16:59:35 -08:00
const LibertyPort *&to_port) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
InputDriveCell *drive = drive_cells_[rf->index()][min_max->index()];
2018-09-28 08:54:21 -07:00
if (drive) {
cell = drive->cell();
from_port = drive->fromPort();
2026-04-15 09:38:10 -07:00
from_slews = &drive->fromSlews();
2018-09-28 08:54:21 -07:00
to_port = drive->toPort();
}
else {
2019-03-12 17:25:53 -07:00
cell = nullptr;
from_port = nullptr;
2026-04-15 09:38:10 -07:00
static constexpr DriveCellSlews slews_zero{0.0, 0.0};
from_slews = &slews_zero;
to_port = nullptr;
}
2018-09-28 08:54:21 -07:00
}
InputDriveCell *
2019-11-11 15:30:19 -07:00
InputDrive::driveCell(const RiseFall *rf,
2026-01-03 16:59:35 -08:00
const MinMax *min_max) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
return drive_cells_[rf->index()][min_max->index()];
2018-09-28 08:54:21 -07:00
}
bool
2019-11-11 15:30:19 -07:00
InputDrive::hasDriveCell(const RiseFall *rf,
2026-01-03 16:59:35 -08:00
const MinMax *min_max) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
return drive_cells_[rf->index()][min_max->index()] != nullptr;
2018-09-28 08:54:21 -07:00
}
bool
2025-02-01 14:53:28 -08:00
InputDrive::driveCellsEqual() const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
int rise_index = RiseFall::riseIndex();
int fall_index = RiseFall::fallIndex();
2018-09-28 08:54:21 -07: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 15:30:19 -07:00
InputDrive::slew(const RiseFall *rf,
2026-01-03 16:59:35 -08:00
const MinMax *min_max,
float &slew,
bool &exists) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
slews_.value(rf, min_max, slew, exists);
2018-09-28 08:54:21 -07:00
}
////////////////////////////////////////////////////////////////
2023-01-19 11:23:45 -07:00
InputDriveCell::InputDriveCell(const LibertyLibrary *library,
2026-01-03 16:59:35 -08:00
const LibertyCell *cell,
const LibertyPort *from_port,
2026-04-15 09:38:10 -07:00
const DriveCellSlews &from_slews,
2026-01-03 16:59:35 -08:00
const LibertyPort *to_port) :
2019-02-16 12:07:59 -08:00
library_(library),
2018-09-28 08:54:21 -07:00
cell_(cell),
from_port_(from_port),
2026-04-15 09:38:10 -07:00
from_slews_(from_slews),
2018-09-28 08:54:21 -07:00
to_port_(to_port)
{
}
2019-02-16 12:07:59 -08:00
void
2023-01-19 11:23:45 -07:00
InputDriveCell::setLibrary(const LibertyLibrary *library)
2019-02-16 12:07:59 -08:00
{
library_ = library;
}
2018-09-28 08:54:21 -07:00
void
2023-01-19 11:23:45 -07:00
InputDriveCell::setCell(const LibertyCell *cell)
2018-09-28 08:54:21 -07:00
{
cell_ = cell;
}
void
2023-01-19 11:23:45 -07:00
InputDriveCell::setFromPort(const LibertyPort *from_port)
2018-09-28 08:54:21 -07:00
{
from_port_ = from_port;
}
void
2023-01-19 11:23:45 -07:00
InputDriveCell::setToPort(const LibertyPort *to_port)
2018-09-28 08:54:21 -07:00
{
to_port_ = to_port;
}
void
2026-04-15 09:38:10 -07:00
InputDriveCell::setFromSlews(const DriveCellSlews &from_slews)
2018-09-28 08:54:21 -07:00
{
2026-04-15 09:38:10 -07:00
from_slews_ = from_slews;
2018-09-28 08:54:21 -07:00
}
bool
2023-01-19 11:23:45 -07:00
InputDriveCell::equal(const InputDriveCell *drive) const
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
int rise_index = RiseFall::riseIndex();
int fall_index = RiseFall::fallIndex();
2018-09-28 08:54:21 -07: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_;
}
2026-04-13 14:58:16 -07:00
} // namespace sta