Files
OpenSTA/include/sta/SearchPred.hh
T

162 lines
5.1 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-02-15 17:13:16 -07:00
#pragma once
2018-09-28 08:54:21 -07:00
2020-04-05 14:53:44 -07:00
#include "GraphClass.hh"
#include "LibertyClass.hh"
2026-04-15 09:38:10 -07:00
#include "NetworkClass.hh"
2020-04-05 14:53:44 -07:00
#include "StaState.hh"
2018-09-28 08:54:21 -07:00
namespace sta {
// Class hierarchy:
// SearchPred
2026-01-03 16:59:35 -08:00
// SearchAdj (unless loop disabled, latch D->Q, timing check, dynamic loop)
2026-01-15 16:14:42 -07:00
// SearchPred0 (unless timing check, disabled or constant)
// EvalPred (unless dynamic loop breaking)
2026-01-03 16:59:35 -08:00
// SearchThru (unless latch D->Q)
2026-01-15 16:14:42 -07:00
// GenClkInsertionSearchPred
2018-09-28 08:54:21 -07:00
// SearchPred1 (unless loop disabled)
2026-01-15 16:14:42 -07:00
// FanOutSrchPred
2026-01-03 16:59:35 -08:00
// ClkTreeSearchPred (only wire or combinational)
2018-09-28 08:54:21 -07:00
// Virtual base class for search predicates.
class SearchPred
{
public:
2026-01-03 16:59:35 -08:00
SearchPred(const StaState *sta);
2026-04-13 14:58:16 -07:00
virtual ~SearchPred() = default;
2018-09-28 08:54:21 -07:00
// Search is allowed from from_vertex.
2026-01-03 16:59:35 -08:00
virtual bool searchFrom(const Vertex *from_vertex,
const Mode *mode) const = 0;
2026-06-24 16:55:51 -07:00
virtual bool searchFrom(const Vertex *from_vertex) const;
2018-09-28 08:54:21 -07:00
// Search is allowed through edge.
// from/to pins are NOT checked.
// inst can be either the from_pin or to_pin instance because it
// is only referenced when they are the same (non-wire edge).
2026-01-03 16:59:35 -08:00
virtual bool searchThru(Edge *edge,
const Mode *mode) const = 0;
2026-06-24 16:55:51 -07:00
virtual bool searchThru(Edge *edge) const;
2018-09-28 08:54:21 -07:00
// Search is allowed to to_pin.
2026-01-03 16:59:35 -08:00
virtual bool searchTo(const Vertex *to_vertex,
const Mode *mode) const = 0;
2026-06-24 16:55:51 -07:00
virtual bool searchTo(const Vertex *to_vertex) const;
virtual void copyState(const StaState *sta);
2026-01-03 16:59:35 -08:00
protected:
const StaState *sta_;
2018-09-28 08:54:21 -07:00
};
class SearchPred0 : public SearchPred
{
public:
2026-01-03 16:59:35 -08:00
SearchPred0(const StaState *sta);
2018-09-28 08:54:21 -07:00
// Search from a vertex unless
// disabled by constraint
// constant logic zero/one
2026-01-03 16:59:35 -08:00
bool searchFrom(const Vertex *from_vertex,
const Mode *mode) const override;
2018-09-28 08:54:21 -07:00
// Search thru an edge unless
// traverses disabled from/to pin pair
// disabled by condition expression
// wire that traverses a disabled hierarchical pin
// register set/reset edge (and search thru them is disabled)
// cond expression is disabled
// non-controlling constant values on other pins that disable the
// edge (such as a mux select)
2026-01-03 16:59:35 -08:00
bool searchThru(Edge *edge,
const Mode *mode) const override;
2018-09-28 08:54:21 -07:00
// Search to a vertex unless
// constant logic zero/one
2026-01-03 16:59:35 -08:00
bool searchTo(const Vertex *to_vertex,
const Mode *mode) const override;
2018-09-28 08:54:21 -07:00
};
// SearchPred0 unless
// disabled to break combinational loop
class SearchPred1 : public SearchPred0
{
public:
2026-01-03 16:59:35 -08:00
SearchPred1(const StaState *sta);
bool searchThru(Edge *edge,
const Mode *mode) const override;
2018-09-28 08:54:21 -07:00
2026-01-03 16:59:35 -08:00
using SearchPred::searchFrom;
using SearchPred::searchThru;
using SearchPred::searchTo;
2018-09-28 08:54:21 -07:00
};
// Predicate for BFS search to stop at the end of the clock tree.
// Search only thru combinational gates and wires.
2026-01-03 16:59:35 -08:00
class ClkTreeSearchPred : public SearchPred
2018-09-28 08:54:21 -07:00
{
public:
2026-01-03 16:59:35 -08:00
ClkTreeSearchPred(const StaState *sta);
bool searchFrom(const Vertex *from_vertex,
const Mode *mode) const override;
bool searchThru(Edge *edge,
const Mode *mode) const override;
// The variable part of searchThru used by descendents.
virtual bool searchThruAllow(const TimingRole *role) const;
bool searchTo(const Vertex *to_vertex,
const Mode *mode) const override;
2018-09-28 08:54:21 -07:00
};
bool
2026-01-03 16:59:35 -08:00
isClkEnd(Vertex *vertex,
const Mode *mode);
2018-09-28 08:54:21 -07:00
// Predicate to see if arc/edge is disabled by constants on other pins
// that effect the unateness of the edge.
bool
searchThru(const Edge *edge,
2026-01-03 16:59:35 -08:00
const TimingArc *arc,
const Mode *mode);
2018-09-28 08:54:21 -07:00
bool
searchThru(Vertex *from_vertex,
2026-01-03 16:59:35 -08:00
const RiseFall *from_rf,
const Edge *edge,
Vertex *to_vertex,
const RiseFall *to_rf,
const Mode *mode);
2018-09-28 08:54:21 -07:00
////////////////////////////////////////////////////////////////
bool
hasFanin(Vertex *vertex,
2026-01-03 16:59:35 -08:00
SearchPred *pred,
const Graph *graph,
const Mode *mode);
2018-09-28 08:54:21 -07:00
// Vertices with no fanout have at no enabled (non-disabled) edges
// leaving them.
bool
hasFanout(Vertex *vertex,
2026-01-03 16:59:35 -08:00
SearchPred *pred,
const Graph *graph,
const Mode *mode);
2018-09-28 08:54:21 -07:00
2026-04-13 14:58:16 -07:00
} // namespace sta