mirror of
https://github.com/The-OpenROAD-Project/OpenSTA.git
synced 2026-09-04 00:39:45 +02:00
commit 34f392b19f13b8a55371f0149de8fec3e76aeffa Author: James Cherry <[email protected]> Date: Thu Apr 17 13:21:45 2025 -0700 in_degree itr Signed-off-by: James Cherry <[email protected]> commit 745e11326d109dddf798843cbbefc4aac79a8bc8 Author: James Cherry <[email protected]> Date: Thu Apr 17 11:00:52 2025 -0700 levelize invalid cleanup Signed-off-by: James Cherry <[email protected]> commit 501cfc7ebbc601db7f87c4c1fe70224fca904ce7 Author: James Cherry <[email protected]> Date: Thu Apr 17 10:15:16 2025 -0700 refactor Signed-off-by: James Cherry <[email protected]> commit b1f0245f9ad7c7c140580e46a0e9c14742b6b448 Author: James Cherry <[email protected]> Date: Thu Apr 17 09:47:05 2025 -0700 Levelize use bit field for on_path Signed-off-by: James Cherry <[email protected]> commit 1ecb617bf0894a290d6240a6150f1d31653e56fb Author: James Cherry <[email protected]> Date: Wed Apr 16 19:17:56 2025 -0700 levelize static alloc Signed-off-by: James Cherry <[email protected]> commit 100c7c5a10581f52f6b5c7c2d4b5614d19549e23 Author: James Cherry <[email protected]> Date: Wed Apr 16 18:15:39 2025 -0700 levelize use visited flag Signed-off-by: James Cherry <[email protected]> commit a72bdc4322c3ea9f34d0144fdf1f74acfbed39fb Author: James Cherry <[email protected]> Date: Wed Apr 16 15:59:25 2025 -0700 findCycleBackEdges Signed-off-by: James Cherry <[email protected]> commit 21f5e9737cfd7c41a5444592920320cfe0de559c Author: James Cherry <[email protected]> Date: Wed Apr 16 15:51:17 2025 -0700 Levels find back edges from roots with fanout Signed-off-by: James Cherry <[email protected]> commit ca2fe71e506c61f05401a52f3b6df3153c2e2393 Author: James Cherry <[email protected]> Date: Tue Apr 15 19:26:50 2025 -0700 rm Vertex::color Signed-off-by: James Cherry <[email protected]> commit 628a973c69eab99929d32a2f5b1810dce71cbab1 Author: James Cherry <[email protected]> Date: Tue Apr 15 18:45:19 2025 -0700 set max_level in Levelize::setLevel Signed-off-by: James Cherry <[email protected]> commit 874c8e10691a47fff06a89c66d66dbb63def9682 Author: James Cherry <[email protected]> Date: Tue Apr 15 17:29:22 2025 -0700 levelize passes all regressions Signed-off-by: James Cherry <[email protected]> commit 790eae362a7423aa7e18432faaae7459a56976d7 Author: James Cherry <[email protected]> Date: Tue Apr 15 08:45:27 2025 -0700 levelize stats Signed-off-by: James Cherry <[email protected]> commit 26067a99a4fbc81d94dbc1022ea5d9ddd64780a0 Author: James Cherry <[email protected]> Date: Mon Apr 14 22:20:56 2025 -0700 pass fast Signed-off-by: James Cherry <[email protected]> commit 635bf478117014dd22d27c4f6bd65b260e51ec35 Author: James Cherry <[email protected]> Date: Mon Apr 14 18:00:03 2025 -0700 comment Signed-off-by: James Cherry <[email protected]> commit 5fd2e9d1dd3a00494d56d967d21251f20e3a1f2c Author: James Cherry <[email protected]> Date: Mon Apr 14 17:59:00 2025 -0700 rm levelizeFrom() Signed-off-by: James Cherry <[email protected]> commit 078205723e2ce1f9be2e1360be80e5f9d25e978b Author: James Cherry <[email protected]> Date: Mon Apr 14 14:46:48 2025 -0700 leak Signed-off-by: James Cherry <[email protected]> commit 412c9a8ead792ee01e46a545c065c174e8342abc Author: James Cherry <[email protected]> Date: Mon Apr 14 13:41:07 2025 -0700 levelize level init Signed-off-by: James Cherry <[email protected]> commit 7883e3b1bac990f33cf7fce24fe43a0614f43daa Author: James Cherry <[email protected]> Date: Mon Apr 14 12:59:45 2025 -0700 relevelize insert only after levelized Signed-off-by: James Cherry <[email protected]> commit 263da8dc56469f0408d1cfbc7c40a079bc90dc9f Author: James Cherry <[email protected]> Date: Mon Apr 14 11:58:55 2025 -0700 topo level init Signed-off-by: James Cherry <[email protected]> commit 9de2ae3128a9ae427653c13152aa796f76277419 Author: James Cherry <[email protected]> Date: Mon Apr 14 11:21:14 2025 -0700 levelize pass fast Signed-off-by: James Cherry <[email protected]> commit 8ba8310850ed1cdaf718b93bf44966043ab2042d Author: James Cherry <[email protected]> Date: Mon Apr 14 10:04:42 2025 -0700 constant latch en Signed-off-by: James Cherry <[email protected]> commit 8f543c3d5b261373d9b8f2da000322e529da7fb4 Author: James Cherry <[email protected]> Date: Sun Apr 13 19:36:23 2025 -0700 levelize topological sort Signed-off-by: James Cherry <[email protected]> commit 4c2ae84839edd9f6797b834d7fd4f644e77855f8 Author: James Cherry <[email protected]> Date: Sun Apr 13 16:14:36 2025 -0700 levelize bfs cleanup Signed-off-by: James Cherry <[email protected]> commit 186f50e8255fcae814f98cc7f253cfd3ba9a6c1d Author: James Cherry <[email protected]> Date: Sun Apr 13 15:25:00 2025 -0700 levelize bfs Signed-off-by: James Cherry <[email protected]> commit 1cefb185caaea64fc568c5d1ba4e7f5a961b0ba3 Author: James Cherry <[email protected]> Date: Sun Apr 13 12:16:49 2025 -0700 levelize with bfs Signed-off-by: James Cherry <[email protected]> commit 5181e6b13ff38b52d13460e6abfee3202d4935c0 Author: James Cherry <[email protected]> Date: Sat Apr 12 18:33:44 2025 -0700 findBackEdges use sorted roots Signed-off-by: James Cherry <[email protected]> commit b25ac1a7d0ec2e835cddbf53930fa5f9f2a5b299 Author: James Cherry <[email protected]> Date: Sat Apr 12 15:32:33 2025 -0700 find back edges Signed-off-by: James Cherry <[email protected]> Signed-off-by: James Cherry <[email protected]>
446 lines
12 KiB
C++
446 lines
12 KiB
C++
// OpenSTA, Static Timing Analyzer
|
|
// Copyright (c) 2025, Parallax Software, Inc.
|
|
//
|
|
// 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/>.
|
|
//
|
|
// 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.
|
|
|
|
#include "CheckTiming.hh"
|
|
|
|
#include "Error.hh"
|
|
#include "TimingRole.hh"
|
|
#include "Network.hh"
|
|
#include "NetworkCmp.hh"
|
|
#include "PortDirection.hh"
|
|
#include "Graph.hh"
|
|
#include "PortDelay.hh"
|
|
#include "ExceptionPath.hh"
|
|
#include "Sdc.hh"
|
|
#include "SearchPred.hh"
|
|
#include "Levelize.hh"
|
|
#include "Bfs.hh"
|
|
#include "Search.hh"
|
|
#include "Genclks.hh"
|
|
#include "Path.hh"
|
|
#include "Sim.hh"
|
|
|
|
namespace sta {
|
|
|
|
using std::string;
|
|
|
|
CheckTiming::CheckTiming(StaState *sta) :
|
|
StaState(sta)
|
|
{
|
|
}
|
|
|
|
CheckTiming::~CheckTiming()
|
|
{
|
|
deleteErrors();
|
|
}
|
|
|
|
void
|
|
CheckTiming::deleteErrors()
|
|
{
|
|
CheckErrorSeq::Iterator error_iter(errors_);
|
|
while (error_iter.hasNext()) {
|
|
CheckError *error = error_iter.next();
|
|
deleteContents(error);
|
|
delete error;
|
|
}
|
|
}
|
|
|
|
void
|
|
CheckTiming::clear()
|
|
{
|
|
deleteErrors();
|
|
errors_.clear();
|
|
}
|
|
|
|
CheckErrorSeq &
|
|
CheckTiming::check(bool no_input_delay,
|
|
bool no_output_delay,
|
|
bool reg_multiple_clks,
|
|
bool reg_no_clks,
|
|
bool unconstrained_endpoints,
|
|
bool loops,
|
|
bool generated_clks)
|
|
{
|
|
clear();
|
|
if (no_input_delay)
|
|
checkNoInputDelay();
|
|
if (no_output_delay)
|
|
checkNoOutputDelay();
|
|
if (reg_multiple_clks || reg_no_clks)
|
|
checkRegClks(reg_multiple_clks, reg_no_clks);
|
|
if (unconstrained_endpoints)
|
|
checkUnconstrainedEndpoints();
|
|
if (loops)
|
|
checkLoops();
|
|
if (generated_clks)
|
|
checkGeneratedClocks();
|
|
return errors_;
|
|
}
|
|
|
|
// Make sure there is a set_input_delay for each input/bidirect.
|
|
void
|
|
CheckTiming::checkNoInputDelay()
|
|
{
|
|
PinSet no_arrival(network_);
|
|
Instance *top_inst = network_->topInstance();
|
|
InstancePinIterator *pin_iter = network_->pinIterator(top_inst);
|
|
while (pin_iter->hasNext()) {
|
|
const Pin *pin = pin_iter->next();
|
|
if (!sdc_->isClock(pin)) {
|
|
PortDirection *dir = network_->direction(pin);
|
|
if (dir->isAnyInput()
|
|
&& !sdc_->hasInputDelay(pin)
|
|
&& !sim_->logicZeroOne(pin))
|
|
no_arrival.insert(pin);
|
|
}
|
|
}
|
|
delete pin_iter;
|
|
pushPinErrors("Warning: There %is %d input port%s missing set_input_delay.",
|
|
no_arrival);
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkNoOutputDelay()
|
|
{
|
|
PinSet no_departure(network_);
|
|
checkNoOutputDelay(no_departure);
|
|
pushPinErrors("Warning: There %is %d output port%s missing set_output_delay.",
|
|
no_departure);
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkNoOutputDelay(PinSet &no_departure)
|
|
{
|
|
Instance *top_inst = network_->topInstance();
|
|
InstancePinIterator *pin_iter = network_->pinIterator(top_inst);
|
|
while (pin_iter->hasNext()) {
|
|
const Pin *pin = pin_iter->next();
|
|
PortDirection *dir = network_->direction(pin);
|
|
if (dir->isAnyOutput()
|
|
&& !sdc_->hasOutputDelay(pin)
|
|
&& !sim_->logicZeroOne(pin))
|
|
no_departure.insert(pin);
|
|
}
|
|
delete pin_iter;
|
|
}
|
|
|
|
bool
|
|
CheckTiming::hasClkedCheck(Vertex *vertex)
|
|
{
|
|
VertexInEdgeIterator edge_iter(vertex, graph_);
|
|
while (edge_iter.hasNext()) {
|
|
Edge *edge = edge_iter.next();
|
|
if (edge->role() == TimingRole::setup()
|
|
&& search_->isClock(edge->from(graph_)))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Search incrementally maintains register/latch clock pins, so use it.
|
|
void
|
|
CheckTiming::checkRegClks(bool reg_multiple_clks,
|
|
bool reg_no_clks)
|
|
{
|
|
PinSet no_clk_pins(network_);
|
|
PinSet multiple_clk_pins(network_);
|
|
for (Vertex *vertex : *graph_->regClkVertices()) {
|
|
const Pin *pin = vertex->pin();
|
|
ClockSet clks = search_->clocks(vertex);
|
|
if (reg_no_clks && clks.empty())
|
|
no_clk_pins.insert(pin);
|
|
if (reg_multiple_clks && clks.size() > 1)
|
|
multiple_clk_pins.insert(pin);
|
|
}
|
|
pushPinErrors("Warning: There %is %d unclocked register/latch pin%s.",
|
|
no_clk_pins);
|
|
pushPinErrors("Warning: There %is %d register/latch pin%s with multiple clocks.",
|
|
multiple_clk_pins);
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkLoops()
|
|
{
|
|
// These may not need to be sorted because the graph roots are
|
|
// sorted during levelization so the discovery should be consistent.
|
|
GraphLoopSeq &loops = levelize_->loops();
|
|
// Count the combinational loops.
|
|
int loop_count = 0;
|
|
for (GraphLoop *loop : loops) {
|
|
if (loop->isCombinational())
|
|
loop_count++;
|
|
}
|
|
if (loop_count > 0) {
|
|
string error_msg;
|
|
errorMsgSubst("Warning: There %is %d combinational loop%s in the design.",
|
|
loop_count, error_msg);
|
|
CheckError *error = new CheckError;
|
|
error->push_back(stringCopy(error_msg.c_str()));
|
|
|
|
GraphLoopSeq::Iterator loop_iter2(loops);
|
|
while (loop_iter2.hasNext()) {
|
|
GraphLoop *loop = loop_iter2.next();
|
|
if (loop->isCombinational()) {
|
|
EdgeSeq::Iterator edge_iter(loop->edges());
|
|
Edge *last_edge = nullptr;
|
|
while (edge_iter.hasNext()) {
|
|
Edge *edge = edge_iter.next();
|
|
Pin *pin = edge->from(graph_)->pin();
|
|
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
|
|
error->push_back(pin_name);
|
|
last_edge = edge;
|
|
}
|
|
if (last_edge) {
|
|
error->push_back(stringCopy("| loop cut point"));
|
|
const Pin *pin = last_edge->to(graph_)->pin();
|
|
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
|
|
error->push_back(pin_name);
|
|
|
|
// Separator between loops.
|
|
error->push_back(stringCopy("--------------------------------"));
|
|
}
|
|
}
|
|
}
|
|
errors_.push_back(error);
|
|
}
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkUnconstrainedEndpoints()
|
|
{
|
|
PinSet unconstrained_ends(network_);
|
|
checkUnconstraintedOutputs(unconstrained_ends);
|
|
checkUnconstrainedSetups(unconstrained_ends);
|
|
pushPinErrors("Warning: There %is %d unconstrained endpoint%s.",
|
|
unconstrained_ends);
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkUnconstraintedOutputs(PinSet &unconstrained_ends)
|
|
{
|
|
Instance *top_inst = network_->topInstance();
|
|
InstancePinIterator *pin_iter = network_->pinIterator(top_inst);
|
|
while (pin_iter->hasNext()) {
|
|
Pin *pin = pin_iter->next();
|
|
PortDirection *dir = network_->direction(pin);
|
|
Vertex *vertex = graph_->pinLoadVertex(pin);
|
|
if (dir->isAnyOutput()
|
|
&& !vertex->isConstant()
|
|
&& !((hasClkedDepature(pin)
|
|
&& hasClkedArrival(vertex))
|
|
|| hasMaxDelay(pin)))
|
|
unconstrained_ends.insert(pin);
|
|
}
|
|
delete pin_iter;
|
|
}
|
|
|
|
bool
|
|
CheckTiming::hasClkedDepature(Pin *pin)
|
|
{
|
|
OutputDelaySet *output_delays = sdc_->outputDelaysLeafPin(pin);
|
|
if (output_delays) {
|
|
for (OutputDelay *output_delay : *output_delays) {
|
|
if (output_delay->clkEdge() != nullptr
|
|
|| output_delay->refPin() != nullptr)
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Check for max delay exception that ends at pin.
|
|
bool
|
|
CheckTiming::hasMaxDelay(Pin *pin)
|
|
{
|
|
ExceptionPathSet *exceptions = sdc_->exceptions();
|
|
ExceptionPathSet::Iterator exception_iter(exceptions);
|
|
while (exception_iter.hasNext()) {
|
|
ExceptionPath *exception = exception_iter.next();
|
|
ExceptionTo *to = exception->to();
|
|
if (exception->isPathDelay()
|
|
&& exception->minMax() == MinMaxAll::max()
|
|
&& to
|
|
&& to->hasPins()
|
|
&& to->pins()->hasKey(pin))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkUnconstrainedSetups(PinSet &unconstrained_ends)
|
|
{
|
|
VertexIterator vertex_iter(graph_);
|
|
while (vertex_iter.hasNext()) {
|
|
Vertex *vertex = vertex_iter.next();
|
|
if (!vertex->isConstant()) {
|
|
VertexInEdgeIterator edge_iter(vertex, graph_);
|
|
while (edge_iter.hasNext()) {
|
|
Edge *edge = edge_iter.next();
|
|
if (edge->role() == TimingRole::setup()
|
|
&& (!search_->isClock(edge->from(graph_))
|
|
|| !hasClkedArrival(edge->to(graph_)))) {
|
|
unconstrained_ends.insert(vertex->pin());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool
|
|
CheckTiming::hasClkedArrival(Vertex *vertex)
|
|
{
|
|
VertexPathIterator path_iter(vertex, this);
|
|
while (path_iter.hasNext()) {
|
|
Path *path = path_iter.next();
|
|
if (path->clock(this))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void
|
|
CheckTiming::checkGeneratedClocks()
|
|
{
|
|
ClockSet gen_clk_errors;
|
|
for (auto clk : sdc_->clks()) {
|
|
if (clk->isGenerated()) {
|
|
search_->genclks()->checkMaster(clk);
|
|
bool found_clk = false;
|
|
VertexSet src_vertices(graph_);
|
|
clk->srcPinVertices(src_vertices, network_, graph_);
|
|
VertexSet::Iterator vertex_iter(src_vertices);
|
|
while (vertex_iter.hasNext()) {
|
|
Vertex *vertex = vertex_iter.next();
|
|
if (search_->isClock(vertex)) {
|
|
found_clk = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found_clk)
|
|
gen_clk_errors.insert(clk);
|
|
}
|
|
}
|
|
pushClkErrors("Warning: There %is %d generated clock%s that %is not connected to a clock source.",
|
|
gen_clk_errors);
|
|
}
|
|
|
|
// Report the "msg" error for each pin in "pins".
|
|
//
|
|
// Substitutions in msg are done as follows if the pin count is one
|
|
// or greater than one.
|
|
// %is - is/are
|
|
// %d - pin count
|
|
// %s - s/""
|
|
// %a - a/""
|
|
void
|
|
CheckTiming::pushPinErrors(const char *msg,
|
|
PinSet &pins)
|
|
{
|
|
if (!pins.empty()) {
|
|
CheckError *error = new CheckError;
|
|
string error_msg;
|
|
errorMsgSubst(msg, pins.size(), error_msg);
|
|
// Copy the error strings because the error deletes them when it
|
|
// is deleted.
|
|
error->push_back(stringCopy(error_msg.c_str()));
|
|
// Sort the error pins so the output is independent of the order
|
|
// the the errors are discovered.
|
|
PinSeq pins1 = sortByPathName(&pins, network_);
|
|
for (const Pin *pin : pins1) {
|
|
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
|
|
error->push_back(pin_name);
|
|
}
|
|
errors_.push_back(error);
|
|
}
|
|
}
|
|
|
|
void
|
|
CheckTiming::pushClkErrors(const char *msg,
|
|
ClockSet &clks)
|
|
{
|
|
if (!clks.empty()) {
|
|
CheckError *error = new CheckError;
|
|
string error_msg;
|
|
errorMsgSubst(msg, clks.size(), error_msg);
|
|
// Copy the error strings because the error deletes them when it
|
|
// is deleted.
|
|
error->push_back(stringCopy(error_msg.c_str()));
|
|
// Sort the error clks so the output is independent of the order
|
|
// the the errors are discovered.
|
|
ClockSeq clks1 = sortByName(&clks);
|
|
for (const Clock *clk : clks1) {
|
|
const char *clk_name = stringCopy(clk->name());
|
|
error->push_back(clk_name);
|
|
}
|
|
errors_.push_back(error);
|
|
}
|
|
}
|
|
|
|
// Copy msg making substitutions for singular/plurals.
|
|
void
|
|
CheckTiming::errorMsgSubst(const char *msg,
|
|
int obj_count,
|
|
string &error_msg)
|
|
{
|
|
for (const char *s = msg; *s; s++) {
|
|
char ch = *s;
|
|
if (ch == '%') {
|
|
char flag = s[1];
|
|
if (flag == 'i') {
|
|
if (obj_count > 1)
|
|
error_msg += "are";
|
|
else
|
|
error_msg += "is";
|
|
s += 2;
|
|
}
|
|
else if (flag == 'a') {
|
|
if (obj_count == 1) {
|
|
error_msg += 'a';
|
|
s++;
|
|
}
|
|
else
|
|
// Skip space after %a.
|
|
s += 2;
|
|
}
|
|
else if (flag == 's') {
|
|
if (obj_count > 1)
|
|
error_msg += 's';
|
|
s++;
|
|
}
|
|
else if (flag == 'd') {
|
|
error_msg += std::to_string(obj_count);
|
|
s++;
|
|
}
|
|
else
|
|
criticalError(245, "unknown print flag");
|
|
}
|
|
else
|
|
error_msg += ch;
|
|
}
|
|
}
|
|
|
|
} // namespace
|