OpenSTA/graph/DelayFloat.cc

200 lines
4.1 KiB
C++
Raw Normal View History

2018-09-28 17:54:21 +02:00
// OpenSTA, Static Timing Analyzer
// 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
// 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
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// 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 "Delay.hh"
2020-04-05 20:35:51 +02:00
2020-04-05 23:53:44 +02:00
#include "StaConfig.hh"
#include "Fuzzy.hh"
#include "Units.hh"
#include "StaState.hh"
2018-09-28 17:54:21 +02:00
2018-12-05 23:18:41 +01:00
// Non-SSTA compilation.
#if !SSTA
2018-09-28 17:54:21 +02:00
namespace sta {
static Delay delay_init_values[MinMax::index_count];
void
initDelayConstants()
{
delay_init_values[MinMax::minIndex()] = MinMax::min()->initValue();
delay_init_values[MinMax::maxIndex()] = MinMax::max()->initValue();
}
2020-05-31 03:09:14 +02:00
const char *
delayAsString(const Delay &delay,
const StaState *sta)
{
return delayAsString(delay, sta, sta->units()->timeUnit()->digits());
}
const char *
delayAsString(const Delay &delay,
const StaState *sta,
int digits)
{
return sta->units()->timeUnit()->asString(delay, digits);
}
const char *
delayAsString(const Delay &delay,
const EarlyLate *,
const StaState *sta,
int digits)
{
const Unit *unit = sta->units()->timeUnit();
return unit->asString(delay, digits);
}
2020-07-12 01:24:48 +02:00
const Delay &
delayInitValue(const MinMax *min_max)
2020-05-31 03:09:14 +02:00
{
2020-07-12 01:24:48 +02:00
return delay_init_values[min_max->index()];
2020-05-31 03:09:14 +02:00
}
2020-07-12 01:24:48 +02:00
bool
delayIsInitValue(const Delay &delay,
const MinMax *min_max)
2020-05-31 03:09:14 +02:00
{
2020-07-12 01:24:48 +02:00
return fuzzyEqual(delay, min_max->initValue());
2020-05-31 03:09:14 +02:00
}
2018-09-28 17:54:21 +02:00
bool
2020-07-12 01:24:48 +02:00
delayZero(const Delay &delay)
2018-09-28 17:54:21 +02:00
{
2020-07-12 01:24:48 +02:00
return fuzzyZero(delay);
2018-09-28 17:54:21 +02:00
}
bool
2020-07-12 01:24:48 +02:00
delayInf(const Delay &delay)
2018-09-28 17:54:21 +02:00
{
2020-07-12 01:24:48 +02:00
return fuzzyInf(delay);
2018-09-28 17:54:21 +02:00
}
bool
2020-07-12 01:24:48 +02:00
delayEqual(const Delay &delay1,
const Delay &delay2)
{
return fuzzyEqual(delay1, delay2);
}
bool
delayLess(const Delay &delay1,
2020-07-12 02:43:30 +02:00
const Delay &delay2,
const StaState *)
2020-07-12 01:24:48 +02:00
{
return fuzzyLess(delay1, delay2);
}
bool
delayLess(const Delay &delay1,
2019-03-13 01:25:53 +01:00
const Delay &delay2,
2020-07-12 02:43:30 +02:00
const MinMax *min_max,
const StaState *)
2018-09-28 17:54:21 +02:00
{
if (min_max == MinMax::max())
2019-03-13 01:25:53 +01:00
return fuzzyLess(delay1, delay2);
2018-09-28 17:54:21 +02:00
else
2019-03-13 01:25:53 +01:00
return fuzzyGreater(delay1, delay2);
2018-09-28 17:54:21 +02:00
}
bool
2020-07-12 01:24:48 +02:00
delayLessEqual(const Delay &delay1,
2020-07-12 02:43:30 +02:00
const Delay &delay2,
const StaState *)
2020-07-12 01:24:48 +02:00
{
return fuzzyLessEqual(delay1, delay2);
}
bool
delayLessEqual(const Delay &delay1,
2018-09-28 17:54:21 +02:00
const Delay &delay2,
2020-07-12 02:43:30 +02:00
const MinMax *min_max,
const StaState *)
2018-09-28 17:54:21 +02:00
{
if (min_max == MinMax::max())
2019-03-13 01:25:53 +01:00
return fuzzyLessEqual(delay1, delay2);
2018-09-28 17:54:21 +02:00
else
2019-03-13 01:25:53 +01:00
return fuzzyGreaterEqual(delay1, delay2);
2018-09-28 17:54:21 +02:00
}
2020-07-12 01:24:48 +02:00
bool
delayGreater(const Delay &delay1,
2020-07-12 02:43:30 +02:00
const Delay &delay2,
const StaState *)
2020-07-12 01:24:48 +02:00
{
return fuzzyGreater(delay1, delay2);
}
bool
delayGreater(const Delay &delay1,
const Delay &delay2,
2020-07-12 02:43:30 +02:00
const MinMax *min_max,
const StaState *)
2020-07-12 01:24:48 +02:00
{
if (min_max == MinMax::max())
return fuzzyGreater(delay1, delay2);
else
return fuzzyLess(delay1, delay2);
}
bool
delayGreaterEqual(const Delay &delay1,
2020-07-12 02:43:30 +02:00
const Delay &delay2,
const StaState *)
2020-07-12 01:24:48 +02:00
{
return fuzzyGreaterEqual(delay1, delay2);
}
bool
delayGreaterEqual(const Delay &delay1,
const Delay &delay2,
2020-07-12 02:43:30 +02:00
const MinMax *min_max,
const StaState *)
2020-07-12 01:24:48 +02:00
{
if (min_max == MinMax::max())
return fuzzyGreaterEqual(delay1, delay2);
else
return fuzzyLessEqual(delay1, delay2);
}
2020-05-31 03:09:14 +02:00
Delay
delayRemove(const Delay &delay1,
const Delay &delay2)
2018-09-28 17:54:21 +02:00
{
2020-05-31 03:09:14 +02:00
return delay1 - delay2;
2019-01-27 08:03:01 +01:00
}
2018-12-11 19:47:04 +01:00
float
2020-05-31 03:09:14 +02:00
delayRatio(const Delay &delay1,
const Delay &delay2)
2018-12-11 19:47:04 +01:00
{
2020-05-31 03:09:14 +02:00
return delay1 / delay2;
2018-12-11 19:47:04 +01:00
}
2018-09-28 17:54:21 +02:00
} // namespace
2020-02-16 01:13:16 +01:00
#endif // !SSTA