2018-12-26 20:03:31 +01:00
|
|
|
// OpenSTA, Static Timing Analyzer
|
2025-01-22 02:54:33 +01:00
|
|
|
// Copyright (c) 2025, Parallax Software, Inc.
|
2018-12-26 20:03:31 +01: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-12-26 20:03:31 +01: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-12-26 20:03:31 +01:00
|
|
|
|
2020-02-16 01:13:16 +01:00
|
|
|
#pragma once
|
2018-12-26 20:03:31 +01:00
|
|
|
|
2025-05-27 00:33:51 +02:00
|
|
|
#include <map>
|
2019-01-17 00:37:31 +01:00
|
|
|
#include <string>
|
2025-06-04 06:39:33 +02:00
|
|
|
#include <functional>
|
2020-04-05 20:35:51 +02:00
|
|
|
|
2020-04-05 23:53:44 +02:00
|
|
|
#include "LibertyClass.hh"
|
|
|
|
|
#include "NetworkClass.hh"
|
|
|
|
|
#include "SearchClass.hh"
|
|
|
|
|
#include "SdcClass.hh"
|
2020-07-31 18:42:24 +02:00
|
|
|
#include "PowerClass.hh"
|
2018-12-26 20:03:31 +01:00
|
|
|
|
|
|
|
|
namespace sta {
|
|
|
|
|
|
|
|
|
|
class Sta;
|
2025-05-27 00:33:51 +02:00
|
|
|
class PropertyValue;
|
|
|
|
|
|
2025-06-03 06:36:33 +02:00
|
|
|
class Sta;
|
|
|
|
|
class PropertyValue;
|
|
|
|
|
|
2025-05-27 00:33:51 +02:00
|
|
|
template<class TYPE>
|
|
|
|
|
class PropertyRegistry
|
|
|
|
|
{
|
|
|
|
|
public:
|
2025-06-20 19:29:12 +02:00
|
|
|
typedef std::function<PropertyValue (TYPE object, Sta *sta)> PropertyHandler;
|
|
|
|
|
void defineProperty(const std::string &property,
|
|
|
|
|
PropertyHandler handler);
|
2025-06-03 06:36:33 +02:00
|
|
|
PropertyValue getProperty(TYPE object,
|
2025-06-20 19:29:12 +02:00
|
|
|
const std::string &property,
|
2025-06-03 06:36:33 +02:00
|
|
|
const char *type_name,
|
|
|
|
|
Sta *sta);
|
2025-05-27 00:33:51 +02:00
|
|
|
|
|
|
|
|
private:
|
2025-06-20 19:29:12 +02:00
|
|
|
std::map<std::string, PropertyHandler> registry_;
|
2025-05-27 00:33:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Properties
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Properties(Sta *sta);
|
2025-06-03 06:36:33 +02:00
|
|
|
virtual ~Properties() {}
|
2025-05-27 00:33:51 +02:00
|
|
|
|
|
|
|
|
PropertyValue getProperty(const Library *lib,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const LibertyLibrary *lib,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Cell *cell,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const LibertyCell *cell,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Port *port,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const LibertyPort *port,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Instance *inst,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Pin *pin,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Net *net,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(Edge *edge,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(const Clock *clk,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(PathEnd *end,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(Path *path,
|
|
|
|
|
const std::string property);
|
|
|
|
|
PropertyValue getProperty(TimingArcSet *arc_set,
|
|
|
|
|
const std::string property);
|
|
|
|
|
|
2025-06-03 06:36:33 +02:00
|
|
|
// Define handler for external property.
|
2025-09-17 23:19:22 +02:00
|
|
|
// properties->defineProperty("foo",
|
|
|
|
|
// [] (const Instance *, Sta *) -> PropertyValue {
|
|
|
|
|
// return PropertyValue("bar");
|
|
|
|
|
// });
|
2025-06-21 23:27:05 +02:00
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Library *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const LibertyLibrary *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Cell *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const LibertyCell *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Port *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const LibertyPort *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Instance *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Pin *>::PropertyHandler handler);
|
|
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Net *>::PropertyHandler handler);
|
2025-09-17 23:19:22 +02:00
|
|
|
void defineProperty(std::string &property,
|
|
|
|
|
PropertyRegistry<const Clock *>::PropertyHandler handler);
|
2025-06-03 06:36:33 +02:00
|
|
|
|
|
|
|
|
protected:
|
2025-05-27 00:33:51 +02:00
|
|
|
PropertyValue portSlew(const Port *port,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue portSlew(const Port *port,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue portSlack(const Port *port,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue portSlack(const Port *port,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue pinArrival(const Pin *pin,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
|
|
|
|
|
PropertyValue pinSlack(const Pin *pin,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue pinSlack(const Pin *pin,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue pinSlew(const Pin *pin,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
PropertyValue pinSlew(const Pin *pin,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
|
|
|
|
|
PropertyValue delayPropertyValue(Delay delay);
|
|
|
|
|
PropertyValue resistancePropertyValue(float res);
|
|
|
|
|
PropertyValue capacitancePropertyValue(float cap);
|
|
|
|
|
PropertyValue edgeDelay(Edge *edge,
|
|
|
|
|
const RiseFall *rf,
|
|
|
|
|
const MinMax *min_max);
|
|
|
|
|
|
2025-06-03 06:36:33 +02:00
|
|
|
PropertyRegistry<const Library*> registry_library_;
|
|
|
|
|
PropertyRegistry<const LibertyLibrary*> registry_liberty_library_;
|
2025-05-27 00:33:51 +02:00
|
|
|
PropertyRegistry<const Cell*> registry_cell_;
|
|
|
|
|
PropertyRegistry<const LibertyCell*> registry_liberty_cell_;
|
|
|
|
|
PropertyRegistry<const Port*> registry_port_;
|
|
|
|
|
PropertyRegistry<const LibertyPort*> registry_liberty_port_;
|
2025-06-03 06:36:33 +02:00
|
|
|
PropertyRegistry<const Instance*> registry_instance_;
|
2025-05-27 00:33:51 +02:00
|
|
|
PropertyRegistry<const Pin*> registry_pin_;
|
|
|
|
|
PropertyRegistry<const Net*> registry_net_;
|
2025-09-17 23:19:22 +02:00
|
|
|
PropertyRegistry<const Clock*> registry_clock_;
|
2025-06-03 06:36:33 +02:00
|
|
|
|
2025-05-27 00:33:51 +02:00
|
|
|
Sta *sta_;
|
|
|
|
|
};
|
2018-12-26 20:03:31 +01:00
|
|
|
|
2019-07-02 16:07:34 +02:00
|
|
|
// Adding a new property type
|
|
|
|
|
// value union
|
|
|
|
|
// enum Type
|
|
|
|
|
// constructor
|
|
|
|
|
// copy constructor switch clause
|
|
|
|
|
// move constructor switch clause
|
|
|
|
|
// operator= & switch clause
|
|
|
|
|
// operator= && switch clause
|
|
|
|
|
// StaTcl.i swig %typemap(out) PropertyValue switch clause
|
|
|
|
|
|
2018-12-26 20:03:31 +01:00
|
|
|
class PropertyValue
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-05-26 05:02:33 +02:00
|
|
|
enum Type { type_none, type_string, type_float, type_bool,
|
2019-07-02 16:07:34 +02:00
|
|
|
type_library, type_cell, type_port,
|
|
|
|
|
type_liberty_library, type_liberty_cell, type_liberty_port,
|
2018-12-26 20:03:31 +01:00
|
|
|
type_instance, type_pin, type_pins, type_net,
|
2025-03-27 02:21:03 +01:00
|
|
|
type_clk, type_clks, type_paths, type_pwr_activity };
|
2018-12-26 20:03:31 +01:00
|
|
|
PropertyValue();
|
2022-04-21 19:59:47 +02:00
|
|
|
PropertyValue(const char *value);
|
2025-04-12 01:59:48 +02:00
|
|
|
PropertyValue(std::string &value);
|
2022-04-21 19:59:47 +02:00
|
|
|
PropertyValue(float value,
|
|
|
|
|
const Unit *unit);
|
2022-04-15 23:15:25 +02:00
|
|
|
explicit PropertyValue(bool value);
|
2023-01-19 19:23:45 +01:00
|
|
|
PropertyValue(const Library *value);
|
|
|
|
|
PropertyValue(const Cell *value);
|
|
|
|
|
PropertyValue(const Port *value);
|
|
|
|
|
PropertyValue(const LibertyLibrary *value);
|
|
|
|
|
PropertyValue(const LibertyCell *value);
|
|
|
|
|
PropertyValue(const LibertyPort *value);
|
|
|
|
|
PropertyValue(const Instance *value);
|
|
|
|
|
PropertyValue(const Pin *value);
|
2018-12-26 20:03:31 +01:00
|
|
|
PropertyValue(PinSeq *value);
|
|
|
|
|
PropertyValue(PinSet *value);
|
2023-01-19 19:23:45 +01:00
|
|
|
PropertyValue(const PinSet &value);
|
|
|
|
|
PropertyValue(const Net *value);
|
|
|
|
|
PropertyValue(const Clock *value);
|
2018-12-26 20:03:31 +01:00
|
|
|
PropertyValue(ClockSeq *value);
|
|
|
|
|
PropertyValue(ClockSet *value);
|
2025-03-27 02:21:03 +01:00
|
|
|
PropertyValue(ConstPathSeq *value);
|
2019-04-29 17:39:05 +02:00
|
|
|
PropertyValue(PwrActivity *value);
|
2018-12-26 20:03:31 +01:00
|
|
|
// Copy constructor.
|
|
|
|
|
PropertyValue(const PropertyValue &props);
|
2019-03-13 01:25:53 +01:00
|
|
|
// Move constructor.
|
|
|
|
|
PropertyValue(PropertyValue &&props);
|
2018-12-26 20:03:31 +01:00
|
|
|
~PropertyValue();
|
|
|
|
|
Type type() const { return type_; }
|
2022-04-21 19:59:47 +02:00
|
|
|
const Unit *unit() const { return unit_; }
|
|
|
|
|
|
2025-04-24 20:09:30 +02:00
|
|
|
std::string to_string(const Network *network) const;
|
2024-07-30 07:56:46 +02:00
|
|
|
const char *stringValue() const; // valid for type string
|
|
|
|
|
float floatValue() const; // valid for type float
|
|
|
|
|
bool boolValue() const; // valid for type bool
|
2023-01-19 19:23:45 +01:00
|
|
|
const LibertyLibrary *libertyLibrary() const { return liberty_library_; }
|
|
|
|
|
const LibertyCell *libertyCell() const { return liberty_cell_; }
|
|
|
|
|
const LibertyPort *libertyPort() const { return liberty_port_; }
|
|
|
|
|
const Library *library() const { return library_; }
|
|
|
|
|
const Cell *cell() const { return cell_; }
|
|
|
|
|
const Port *port() const { return port_; }
|
|
|
|
|
const Instance *instance() const { return inst_; }
|
|
|
|
|
const Pin *pin() const { return pin_; }
|
2018-12-26 20:03:31 +01:00
|
|
|
PinSeq *pins() const { return pins_; }
|
2023-01-19 19:23:45 +01:00
|
|
|
const Net *net() const { return net_; }
|
|
|
|
|
const Clock *clock() const { return clk_; }
|
2018-12-26 20:03:31 +01:00
|
|
|
ClockSeq *clocks() const { return clks_; }
|
2025-03-27 02:21:03 +01:00
|
|
|
ConstPathSeq *paths() const { return paths_; }
|
2019-04-29 17:39:05 +02:00
|
|
|
PwrActivity pwrActivity() const { return pwr_activity_; }
|
2022-04-21 19:59:47 +02:00
|
|
|
|
2019-03-13 01:25:53 +01:00
|
|
|
// Copy assignment.
|
|
|
|
|
PropertyValue &operator=(const PropertyValue &);
|
|
|
|
|
// Move assignment.
|
|
|
|
|
PropertyValue &operator=(PropertyValue &&);
|
2018-12-26 20:03:31 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Type type_;
|
2019-03-13 01:25:53 +01:00
|
|
|
union {
|
|
|
|
|
const char *string_;
|
|
|
|
|
float float_;
|
2019-05-26 05:02:33 +02:00
|
|
|
bool bool_;
|
2023-01-19 19:23:45 +01:00
|
|
|
const Library *library_;
|
|
|
|
|
const Cell *cell_;
|
|
|
|
|
const Port *port_;
|
|
|
|
|
const LibertyLibrary *liberty_library_;
|
|
|
|
|
const LibertyCell *liberty_cell_;
|
|
|
|
|
const LibertyPort *liberty_port_;
|
|
|
|
|
const Instance *inst_;
|
|
|
|
|
const Pin *pin_;
|
2019-03-13 01:25:53 +01:00
|
|
|
PinSeq *pins_;
|
2023-01-19 19:23:45 +01:00
|
|
|
const Net *net_;
|
|
|
|
|
const Clock *clk_;
|
2019-03-13 01:25:53 +01:00
|
|
|
ClockSeq *clks_;
|
2025-03-27 02:21:03 +01:00
|
|
|
ConstPathSeq *paths_;
|
2019-04-29 17:39:05 +02:00
|
|
|
PwrActivity pwr_activity_;
|
2019-03-13 01:25:53 +01:00
|
|
|
};
|
2022-04-21 19:59:47 +02:00
|
|
|
const Unit *unit_;
|
2018-12-26 20:03:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|