1 #ifndef OT_LIBERTY_LUT_HPP_ 2 #define OT_LIBERTY_LUT_HPP_ 3 4 #include <ot/headerdef.hpp> 5 #include <ot/static/logger.hpp> 6 #include <ot/utility/utility.hpp> 7 #include <ot/exception.hpp> 8 9 namespace ot { 10 11 // Enum: LutVar 12 enum class LutVar { 13 TOTAL_OUTPUT_NET_CAPACITANCE = 0, 14 INPUT_NET_TRANSITION, 15 CONSTRAINED_PIN_TRANSITION, 16 RELATED_PIN_TRANSITION, 17 INPUT_TRANSITION_TIME, 18 }; 19 20 // Variable mapping 21 inline const std::unordered_map<std::string_view, LutVar> lut_vars { 22 {"total_output_net_capacitance", LutVar::TOTAL_OUTPUT_NET_CAPACITANCE}, 23 {"input_net_transition", LutVar::INPUT_NET_TRANSITION}, 24 {"constrained_pin_transition", LutVar::CONSTRAINED_PIN_TRANSITION}, 25 {"related_pin_transition", LutVar::RELATED_PIN_TRANSITION}, 26 {"input_transition_timing", LutVar::INPUT_TRANSITION_TIME} 27 }; 28 29 // Function: is_time_lut_var 30 bool is_time_lut_var(LutVar); 31 bool is_capacitance_lut_var(LutVar); 32 33 // Function: to_string 34 std::string to_string(LutVar); 35 36 // Struct: LutTemplate 37 struct LutTemplate { 38 39 std::string name; 40 41 std::optional<LutVar> variable1; 42 std::optional<LutVar> variable2; 43 44 std::vector<float> indices1; 45 std::vector<float> indices2; 46 }; 47 48 std::ostream& operator << (std::ostream& os, const LutTemplate&); 49 50 // ------------------------------------------------------------------------------------------------ 51 52 // Struct: Lut 53 struct Lut { 54 55 std::string name; 56 57 std::vector<float> indices1; 58 std::vector<float> indices2; 59 std::vector<float> table; 60 61 const LutTemplate* lut_template {nullptr}; 62 63 float operator() (float, float) const; 64 65 bool is_scalar() const; 66 bool empty() const; 67 68 void scale_time(float); 69 void scale_capacitance(float); 70 }; 71 72 std::ostream& operator << (std::ostream& os, const Lut&); 73 74 }; // end of namespace ot ------------------------------------------------------------------------ 75 76 #endif 77