Files
OpenSTA/sdc/DataCheck.cc
T

124 lines
3.5 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 "DataCheck.hh"
2020-04-05 11:35:51 -07:00
2020-04-05 14:53:44 -07:00
#include "Clock.hh"
2023-01-19 11:23:45 -07:00
#include "Network.hh"
2018-09-28 08:54:21 -07:00
namespace sta {
DataCheck::DataCheck(Pin *from,
2026-01-03 16:59:35 -08:00
Pin *to,
Clock *clk) :
2018-09-28 08:54:21 -07:00
from_(from),
to_(to),
clk_(clk)
{
}
void
2019-11-11 15:30:19 -07:00
DataCheck::margin(const RiseFall *from_rf,
2026-01-03 16:59:35 -08:00
const RiseFall *to_rf,
const SetupHold *setup_hold,
// Return values.
float &margin,
bool &exists) const
2018-09-28 08:54:21 -07:00
{
2026-04-15 09:38:10 -07:00
margins_[from_rf->index()].value(to_rf, setup_hold,
margin, exists);
2018-09-28 08:54:21 -07:00
}
void
2019-11-11 15:30:19 -07:00
DataCheck::setMargin(const RiseFallBoth *from_rf,
2026-01-03 16:59:35 -08:00
const RiseFallBoth *to_rf,
const SetupHoldAll *setup_hold,
float margin)
2018-09-28 08:54:21 -07:00
{
2019-11-11 15:30:19 -07:00
for (auto from_rf_index : from_rf->rangeIndex())
margins_[from_rf_index].setValue(to_rf, setup_hold, margin);
2018-09-28 08:54:21 -07:00
}
void
2019-11-11 15:30:19 -07:00
DataCheck::removeMargin(const RiseFallBoth *from_rf,
2026-01-03 16:59:35 -08:00
const RiseFallBoth *to_rf,
const SetupHoldAll *setup_hold)
2018-09-28 08:54:21 -07:00
{
2023-01-19 11:23:45 -07:00
for (int from_rf_index : from_rf->rangeIndex())
2019-11-11 15:30:19 -07:00
margins_[from_rf_index].removeValue(to_rf, setup_hold);
2018-09-28 08:54:21 -07:00
}
bool
DataCheck::empty() const
{
2023-01-19 11:23:45 -07:00
for (int tr_index : RiseFall::rangeIndex()) {
2019-07-18 06:19:00 -07:00
if (!margins_[tr_index].empty())
2018-09-28 08:54:21 -07:00
return false;
}
return true;
}
void
2025-03-30 15:27:53 -07:00
DataCheck::marginIsOneValue(const SetupHold *setup_hold,
2026-01-03 16:59:35 -08:00
// Return values.
float &value,
bool &one_value) const
2018-09-28 08:54:21 -07:00
{
float value1, value2;
2019-11-11 15:30:19 -07:00
if (margins_[RiseFall::riseIndex()].isOneValue(setup_hold, value1)
&& margins_[RiseFall::fallIndex()].isOneValue(setup_hold, value2)
2018-09-28 08:54:21 -07:00
&& value1 == value2) {
value = value1;
one_value = true;
}
else
one_value = false;
}
////////////////////////////////////////////////////////////////
DataCheckLess::DataCheckLess(const Network *network) :
2023-01-19 11:23:45 -07:00
network_(network)
2018-09-28 08:54:21 -07:00
{
}
bool
DataCheckLess::operator()(const DataCheck *check1,
2026-01-03 16:59:35 -08:00
const DataCheck *check2) const
2018-09-28 08:54:21 -07:00
{
const Pin *from1 = check1->from();
const Pin *from2 = check2->from();
const Pin *to1 = check1->to();
const Pin *to2 = check2->to();
const Clock *clk1 = check1->clk();
const Clock *clk2 = check2->clk();
2023-01-19 11:23:45 -07:00
return network_->id(from1) < network_->id(from2)
2018-09-28 08:54:21 -07:00
|| (from1 == from2
2026-01-03 16:59:35 -08:00
&& (network_->id(to1) < network_->id(to2)
|| (to1 == to2
&& clkCmp(clk1, clk2) < 0)));
2018-09-28 08:54:21 -07:00
}
2026-04-13 14:58:16 -07:00
} // namespace sta