1 // OpenSTA, Static Timing Analyzer 2 // Copyright (c) 2020, Parallax Software, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17 #pragma once 18 19 #include <string> 20 21 #include "LibertyClass.hh" 22 #include "NetworkClass.hh" 23 #include "SearchClass.hh" 24 #include "SdcClass.hh" 25 #include "PowerClass.hh" 26 27 namespace sta { 28 29 using std::string; 30 31 class Sta; 32 33 // Adding a new property type 34 // value union 35 // enum Type 36 // constructor 37 // copy constructor switch clause 38 // move constructor switch clause 39 // operator= & switch clause 40 // operator= && switch clause 41 // StaTcl.i swig %typemap(out) PropertyValue switch clause 42 43 class PropertyValue 44 { 45 public: 46 enum Type { type_none, type_string, type_float, type_bool, 47 type_library, type_cell, type_port, 48 type_liberty_library, type_liberty_cell, type_liberty_port, 49 type_instance, type_pin, type_pins, type_net, 50 type_clk, type_clks, type_path_refs, type_pwr_activity }; 51 PropertyValue(); 52 PropertyValue(const char *value); 53 PropertyValue(string &value); 54 PropertyValue(float value); 55 PropertyValue(bool value); 56 PropertyValue(Library *value); 57 PropertyValue(Cell *value); 58 PropertyValue(Port *value); 59 PropertyValue(LibertyLibrary *value); 60 PropertyValue(LibertyCell *value); 61 PropertyValue(LibertyPort *value); 62 PropertyValue(Instance *value); 63 PropertyValue(Pin *value); 64 PropertyValue(PinSeq *value); 65 PropertyValue(PinSet *value); 66 PropertyValue(Net *value); 67 PropertyValue(Clock *value); 68 PropertyValue(ClockSeq *value); 69 PropertyValue(ClockSet *value); 70 PropertyValue(PathRefSeq *value); 71 PropertyValue(PwrActivity *value); 72 // Copy constructor. 73 PropertyValue(const PropertyValue &props); 74 // Move constructor. 75 PropertyValue(PropertyValue &&props); 76 ~PropertyValue(); type() const77 Type type() const { return type_; } stringValue() const78 const char *stringValue() const { return string_; } floatValue() const79 float floatValue() const { return float_; } boolValue() const80 bool boolValue() const { return bool_; } libertyLibrary() const81 LibertyLibrary *libertyLibrary() const { return liberty_library_; } libertyCell() const82 LibertyCell *libertyCell() const { return liberty_cell_; } libertyPort() const83 LibertyPort *libertyPort() const { return liberty_port_; } library() const84 Library *library() const { return library_; } cell() const85 Cell *cell() const { return cell_; } port() const86 Port *port() const { return port_; } instance() const87 Instance *instance() const { return inst_; } pin() const88 Pin *pin() const { return pin_; } pins() const89 PinSeq *pins() const { return pins_; } net() const90 Net *net() const { return net_; } clock() const91 Clock *clock() const { return clk_; } clocks() const92 ClockSeq *clocks() const { return clks_; } pathRefs() const93 PathRefSeq *pathRefs() const { return path_refs_; } pwrActivity() const94 PwrActivity pwrActivity() const { return pwr_activity_; } 95 // Copy assignment. 96 PropertyValue &operator=(const PropertyValue &); 97 // Move assignment. 98 PropertyValue &operator=(PropertyValue &&); 99 100 private: 101 Type type_; 102 union { 103 const char *string_; 104 float float_; 105 bool bool_; 106 Library *library_; 107 Cell *cell_; 108 Port *port_; 109 LibertyLibrary *liberty_library_; 110 LibertyCell *liberty_cell_; 111 LibertyPort *liberty_port_; 112 Instance *inst_; 113 Pin *pin_; 114 PinSeq *pins_; 115 Net *net_; 116 Clock *clk_; 117 ClockSeq *clks_; 118 PathRefSeq *path_refs_; 119 PwrActivity pwr_activity_; 120 }; 121 }; 122 123 PropertyValue 124 getProperty(const Instance *inst, 125 const char *property, 126 Sta *sta); 127 128 PropertyValue 129 getProperty(const Pin *pin, 130 const char *property, 131 Sta *sta); 132 133 PropertyValue 134 getProperty(const Net *net, 135 const char *property, 136 Sta *sta); 137 138 PropertyValue 139 getProperty(const Port *port, 140 const char *property, 141 Sta *sta); 142 143 PropertyValue 144 getProperty(const Cell *cell, 145 const char *property, 146 Sta *sta); 147 148 PropertyValue 149 getProperty(const LibertyCell *cell, 150 const char *property, 151 Sta *sta); 152 153 PropertyValue 154 getProperty(const LibertyPort *port, 155 const char *property, 156 Sta *); 157 158 PropertyValue 159 getProperty(const LibertyLibrary *lib, 160 const char *property, 161 Sta *sta); 162 163 PropertyValue 164 getProperty(const Library *lib, 165 const char *property, 166 Sta *sta); 167 168 PropertyValue 169 getProperty(Edge *edge, 170 const char *property, 171 Sta *sta); 172 173 PropertyValue 174 getProperty(Clock *clk, 175 const char *property, 176 Sta *sta); 177 178 PropertyValue 179 getProperty(PathEnd *end, 180 const char *property, 181 Sta *sta); 182 183 PropertyValue 184 getProperty(PathRef *end, 185 const char *property, 186 Sta *sta); 187 188 PropertyValue 189 getProperty(TimingArcSet *arc_set, 190 const char *property, 191 Sta *sta); 192 193 } // namespace 194