2018-09-28 17:54:21 +02:00
|
|
|
// OpenSTA, Static Timing Analyzer
|
2025-01-22 02:54:33 +01:00
|
|
|
// Copyright (c) 2025, 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
|
2022-01-04 18:17:08 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-09-28 17:54:21 +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/>.
|
2025-01-22 02:54:33 +01: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 17:54:21 +02:00
|
|
|
|
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
|
|
|
{
|
2024-06-27 22:57:58 +02:00
|
|
|
for (auto rf_index : RiseFall::rangeIndex()) {
|
2019-07-18 15:19:00 +02:00
|
|
|
for (auto mm_index : MinMax::rangeIndex())
|
2024-06-27 22:57:58 +02:00
|
|
|
drive_cells_[rf_index][mm_index] = nullptr;
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputDrive::~InputDrive()
|
|
|
|
|
{
|
2024-06-27 22:57:58 +02:00
|
|
|
for (auto rf_index : RiseFall::rangeIndex()) {
|
2019-07-18 15:19:00 +02:00
|
|
|
for (auto mm_index : MinMax::rangeIndex()) {
|
2024-06-27 22:57:58 +02:00
|
|
|
InputDriveCell *drive_cell = drive_cells_[rf_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,
|
2025-02-01 23:53:28 +01:00
|
|
|
bool &exists) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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
|
2025-02-01 23:53:28 +01:00
|
|
|
InputDrive::hasDriveResistance(const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max) const
|
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
|
2025-02-01 23:53:28 +01:00
|
|
|
InputDrive::driveResistanceMinMaxEqual(const RiseFall *rf) const
|
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
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDrive::setDriveCell(const LibertyLibrary *library,
|
|
|
|
|
const LibertyCell *cell,
|
|
|
|
|
const LibertyPort *from_port,
|
2018-09-28 17:54:21 +02:00
|
|
|
float *from_slews,
|
2023-01-19 19:23:45 +01:00
|
|
|
const 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,
|
2021-10-23 00:45:18 +02:00
|
|
|
// Return values.
|
2023-01-19 19:23:45 +01:00
|
|
|
const LibertyCell *&cell,
|
|
|
|
|
const LibertyPort *&from_port,
|
2018-09-28 17:54:21 +02:00
|
|
|
float *&from_slews,
|
2025-02-01 23:53:28 +01:00
|
|
|
const LibertyPort *&to_port) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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();
|
|
|
|
|
}
|
2021-10-23 00:45:18 +02:00
|
|
|
else {
|
2019-03-13 01:25:53 +01:00
|
|
|
cell = nullptr;
|
2021-10-23 00:45:18 +02:00
|
|
|
from_port = nullptr;
|
|
|
|
|
from_slews = nullptr;
|
|
|
|
|
to_port = nullptr;
|
|
|
|
|
}
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InputDriveCell *
|
2019-11-11 23:30:19 +01:00
|
|
|
InputDrive::driveCell(const RiseFall *rf,
|
2025-02-01 23:53:28 +01:00
|
|
|
const MinMax *min_max) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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,
|
2025-02-01 23:53:28 +01:00
|
|
|
const MinMax *min_max) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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
|
2025-02-01 23:53:28 +01:00
|
|
|
InputDrive::driveCellsEqual() const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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,
|
2025-02-01 23:53:28 +01:00
|
|
|
bool &exists) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
2019-11-11 23:30:19 +01:00
|
|
|
slews_.value(rf, min_max, slew, exists);
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::InputDriveCell(const LibertyLibrary *library,
|
|
|
|
|
const LibertyCell *cell,
|
|
|
|
|
const LibertyPort *from_port,
|
2018-09-28 17:54:21 +02:00
|
|
|
float *from_slews,
|
2023-01-19 19:23:45 +01:00
|
|
|
const 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
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::setLibrary(const LibertyLibrary *library)
|
2019-02-16 21:07:59 +01:00
|
|
|
{
|
|
|
|
|
library_ = library;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 17:54:21 +02:00
|
|
|
void
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::setCell(const LibertyCell *cell)
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
|
|
|
|
cell_ = cell;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::setFromPort(const LibertyPort *from_port)
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
|
|
|
|
from_port_ = from_port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::setToPort(const LibertyPort *to_port)
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
|
|
|
|
to_port_ = to_port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
InputDriveCell::setFromSlews(float *from_slews)
|
|
|
|
|
{
|
2024-06-27 22:57:58 +02:00
|
|
|
for (auto rf_index : RiseFall::rangeIndex())
|
|
|
|
|
from_slews_[rf_index] = from_slews[rf_index];
|
2018-09-28 17:54:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
2023-01-19 19:23:45 +01:00
|
|
|
InputDriveCell::equal(const InputDriveCell *drive) const
|
2018-09-28 17:54:21 +02:00
|
|
|
{
|
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
|