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-02-16 01:13:16 +01:00
|
|
|
#pragma once
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
#include <queue>
|
2019-03-13 01:25:53 +01:00
|
|
|
#include <mutex>
|
2020-04-05 20:35:51 +02:00
|
|
|
|
2020-04-05 23:53:44 +02:00
|
|
|
#include "StaConfig.hh" // CUDD
|
|
|
|
|
#include "Map.hh"
|
|
|
|
|
#include "NetworkClass.hh"
|
|
|
|
|
#include "GraphClass.hh"
|
|
|
|
|
#include "SdcClass.hh"
|
|
|
|
|
#include "StaState.hh"
|
2024-02-27 18:00:48 +01:00
|
|
|
#include "Bdd.hh"
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
namespace sta {
|
|
|
|
|
|
|
|
|
|
class SimObserver;
|
|
|
|
|
|
|
|
|
|
typedef Map<const Pin*, LogicValue> PinValueMap;
|
|
|
|
|
typedef std::queue<const Instance*> EvalQueue;
|
|
|
|
|
|
|
|
|
|
// Propagate constants from constraints and netlist tie high/low
|
|
|
|
|
// connections thru gates.
|
|
|
|
|
class Sim : public StaState
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit Sim(StaState *sta);
|
|
|
|
|
virtual ~Sim();
|
|
|
|
|
void clear();
|
|
|
|
|
// Set the observer for simulation value changes.
|
|
|
|
|
void setObserver(SimObserver *observer);
|
|
|
|
|
void ensureConstantsPropagated();
|
|
|
|
|
void constantsInvalid();
|
|
|
|
|
LogicValue evalExpr(const FuncExpr *expr,
|
2024-02-27 18:00:48 +01:00
|
|
|
const Instance *inst);
|
2018-09-28 17:54:21 +02:00
|
|
|
LogicValue logicValue(const Pin *pin) const;
|
|
|
|
|
bool logicZeroOne(const Pin *pin) const;
|
2019-08-13 07:56:32 +02:00
|
|
|
bool logicZeroOne(const Vertex *vertex) const;
|
2018-09-28 17:54:21 +02:00
|
|
|
// Timing sense for the function between from_pin and to_pin
|
|
|
|
|
// after simplifying the function based constants on the pins.
|
|
|
|
|
virtual TimingSense functionSense(const Instance *inst,
|
|
|
|
|
const Pin *from_pin,
|
|
|
|
|
const Pin *to_pin);
|
2021-06-22 02:49:46 +02:00
|
|
|
void findLogicConstants();
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
// Network edits.
|
2023-01-19 19:23:45 +01:00
|
|
|
void deleteInstanceBefore(const Instance *inst);
|
|
|
|
|
void makePinAfter(const Pin *pin);
|
|
|
|
|
void deletePinBefore(const Pin *pin);
|
|
|
|
|
void connectPinAfter(const Pin *pin);
|
|
|
|
|
void disconnectPinBefore(const Pin *pin);
|
|
|
|
|
void pinSetFuncAfter(const Pin *pin);
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void ensureConstantFuncPins();
|
2023-01-19 19:23:45 +01:00
|
|
|
void recordConstPinFunc(const Pin *pin);
|
2018-09-28 17:54:21 +02:00
|
|
|
virtual void seedConstants();
|
|
|
|
|
void seedInvalidConstants();
|
2021-06-22 02:49:46 +02:00
|
|
|
void propagateConstants(bool thru_sequentials);
|
2023-01-19 19:23:45 +01:00
|
|
|
void setConstraintConstPins(LogicValueMap &pin_value_map);
|
2021-06-22 02:49:46 +02:00
|
|
|
void setConstFuncPins();
|
2023-01-19 19:23:45 +01:00
|
|
|
LogicValue pinConstFuncValue(const Pin *pin);
|
2021-06-22 02:49:46 +02:00
|
|
|
void enqueueConstantPinInputs();
|
2018-09-28 17:54:21 +02:00
|
|
|
virtual void setPinValue(const Pin *pin,
|
2021-06-22 02:49:46 +02:00
|
|
|
LogicValue value);
|
2018-09-28 17:54:21 +02:00
|
|
|
void enqueue(const Instance *inst);
|
2021-06-22 02:49:46 +02:00
|
|
|
void evalInstance(const Instance *inst,
|
|
|
|
|
bool thru_sequentials);
|
2020-11-17 18:59:19 +01:00
|
|
|
LogicValue clockGateOutValue(const Instance *inst);
|
2018-09-28 17:54:21 +02:00
|
|
|
TimingSense functionSense(const FuncExpr *expr,
|
|
|
|
|
const Pin *input_pin,
|
|
|
|
|
const Instance *inst);
|
|
|
|
|
void functionSense(const FuncExpr *expr,
|
|
|
|
|
const Pin *input_pin,
|
|
|
|
|
const Instance *inst,
|
|
|
|
|
// return values
|
|
|
|
|
TimingSense &sense,
|
|
|
|
|
LogicValue &value) const;
|
|
|
|
|
void clearSimValues();
|
|
|
|
|
virtual void clearInstSimValues(const Instance *inst);
|
|
|
|
|
void annotateGraphEdges();
|
|
|
|
|
void annotateVertexEdges(const Instance *inst,
|
|
|
|
|
const Pin *pin,
|
|
|
|
|
Vertex *vertex,
|
|
|
|
|
bool annotate);
|
|
|
|
|
void annotateVertexEdges(const Instance *inst,
|
|
|
|
|
bool annotate);
|
|
|
|
|
void removePropagatedValue(const Pin *pin);
|
|
|
|
|
void propagateFromInvalidDrvrsToLoads();
|
|
|
|
|
void propagateToInvalidLoads();
|
2023-01-19 19:23:45 +01:00
|
|
|
void propagateDrvrToLoad(const Pin *drvr_pin,
|
|
|
|
|
const Pin *load_pin);
|
2018-09-28 17:54:21 +02:00
|
|
|
void setSimValue(Vertex *vertex,
|
|
|
|
|
LogicValue value);
|
2024-02-27 18:00:48 +01:00
|
|
|
DdNode *funcBddSim(const FuncExpr *expr,
|
|
|
|
|
const Instance *inst);
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
SimObserver *observer_;
|
|
|
|
|
bool valid_;
|
|
|
|
|
bool incremental_;
|
|
|
|
|
// Cache of pins that have constant functions (tie high and tie low
|
|
|
|
|
// cell instances).
|
|
|
|
|
PinSet const_func_pins_;
|
|
|
|
|
bool const_func_pins_valid_;
|
|
|
|
|
// Instances that require incremental constant propagation.
|
|
|
|
|
InstanceSet invalid_insts_;
|
|
|
|
|
// Driver pins waiting to propagate constant to loads.
|
|
|
|
|
PinSet invalid_drvr_pins_;
|
|
|
|
|
// Load pins that waiting for the driver constant to propagate.
|
|
|
|
|
PinSet invalid_load_pins_;
|
|
|
|
|
EvalQueue eval_queue_;
|
|
|
|
|
// Instances with constant pin values for annotateVertexEdges.
|
|
|
|
|
InstanceSet instances_with_const_pins_;
|
|
|
|
|
InstanceSet instances_to_annotate_;
|
2024-02-27 18:00:48 +01:00
|
|
|
Bdd bdd_;
|
|
|
|
|
mutable std::mutex bdd_lock_;
|
2018-09-28 17:54:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Abstract base class for Sim value change observer.
|
|
|
|
|
class SimObserver
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SimObserver() {}
|
|
|
|
|
virtual ~SimObserver() {}
|
|
|
|
|
virtual void valueChangeAfter(Vertex *vertex) = 0;
|
|
|
|
|
virtual void faninEdgesChangeAfter(Vertex *vertex) = 0;
|
|
|
|
|
virtual void fanoutEdgesChangeAfter(Vertex *vertex) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
logicValueZeroOne(LogicValue value);
|
|
|
|
|
|
|
|
|
|
// Edge cond (liberty "when") function is disabled (evals to zero).
|
|
|
|
|
bool
|
|
|
|
|
isCondDisabled(Edge *edge,
|
|
|
|
|
const Instance *inst,
|
|
|
|
|
const Pin *from_pin,
|
|
|
|
|
const Pin *to_pin,
|
|
|
|
|
const Network *network,
|
2024-02-27 18:00:48 +01:00
|
|
|
Sim *sim);
|
2018-09-28 17:54:21 +02:00
|
|
|
|
|
|
|
|
// isCondDisabled but also return the cond expression that causes
|
|
|
|
|
// the disable. This can differ from the edge cond expression
|
|
|
|
|
// when the default timing edge is disabled by another edge between
|
|
|
|
|
// the same pins that is enabled.
|
|
|
|
|
void
|
|
|
|
|
isCondDisabled(Edge *edge,
|
|
|
|
|
const Instance *inst,
|
|
|
|
|
const Pin *from_pin,
|
|
|
|
|
const Pin *to_pin,
|
|
|
|
|
const Network *network,
|
2024-02-27 18:00:48 +01:00
|
|
|
Sim *sim,
|
2018-09-28 17:54:21 +02:00
|
|
|
bool &is_disabled,
|
|
|
|
|
FuncExpr *&disable_cond);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Edge mode function is disabled (evals to zero).
|
|
|
|
|
bool
|
|
|
|
|
isModeDisabled(Edge *edge,
|
|
|
|
|
const Instance *inst,
|
|
|
|
|
const Network *network,
|
2024-02-27 18:00:48 +01:00
|
|
|
Sim *sim);
|
2018-09-28 17:54:21 +02:00
|
|
|
void
|
|
|
|
|
isModeDisabled(Edge *edge,
|
|
|
|
|
const Instance *inst,
|
|
|
|
|
const Network *network,
|
2024-02-27 18:00:48 +01:00
|
|
|
Sim *sim,
|
2018-09-28 17:54:21 +02:00
|
|
|
bool &is_disabled,
|
|
|
|
|
FuncExpr *&disable_cond);
|
|
|
|
|
|
|
|
|
|
} // namespace
|