1 #ifndef OT_LIBERTY_TIMING_HPP_ 2 #define OT_LIBERTY_TIMING_HPP_ 3 4 #include <ot/liberty/lut.hpp> 5 6 namespace ot { 7 8 enum class TimingSense { 9 NON_UNATE = 0, 10 POSITIVE_UNATE, 11 NEGATIVE_UNATE 12 }; 13 14 enum class TimingType { 15 COMBINATIONAL = 0, 16 COMBINATIONAL_RISE, 17 COMBINATIONAL_FALL, 18 THREE_STATE_DISABLE, 19 THREE_STATE_DISABLE_RISE, 20 THREE_STATE_DISABLE_FALL, 21 THREE_STATE_ENABLE, 22 THREE_STATE_ENABLE_RISE, 23 THREE_STATE_ENABLE_FALL, 24 RISING_EDGE, 25 FALLING_EDGE, 26 PRESET, 27 CLEAR, 28 HOLD_RISING, 29 HOLD_FALLING, 30 SETUP_RISING, 31 SETUP_FALLING, 32 RECOVERY_RISING, 33 RECOVERY_FALLING, 34 SKEW_RISING, 35 SKEW_FALLING, 36 REMOVAL_RISING, 37 REMOVAL_FALLING, 38 MIN_PULSE_WIDTH, 39 MINIMUM_PERIOD, 40 MAX_CLOCK_TREE_PATH, 41 MIN_CLOCK_TREE_PATH, 42 NON_SEQ_SETUP_RISING, 43 NON_SEQ_SETUP_FALLING, 44 NON_SEQ_HOLD_RISING, 45 NON_SEQ_HOLD_FALLING, 46 NOCHANGE_HIGH_HIGH, 47 NOCHANGE_HIGH_LOW, 48 NOCHANGE_LOW_HIGH, 49 NOCHANGE_LOW_LOW, 50 }; 51 52 inline const std::unordered_map<std::string_view, TimingType> timing_types = { 53 {"combinational", TimingType::COMBINATIONAL}, 54 {"combinational_rise", TimingType::COMBINATIONAL_RISE}, 55 {"combinational_fall", TimingType::COMBINATIONAL_FALL}, 56 {"three_state_disable", TimingType::THREE_STATE_DISABLE}, 57 {"three_state_disable_rise", TimingType::THREE_STATE_DISABLE_RISE}, 58 {"three_state_disable_fall", TimingType::THREE_STATE_DISABLE_FALL}, 59 {"three_state_enable", TimingType::THREE_STATE_ENABLE}, 60 {"three_state_enable_rise", TimingType::THREE_STATE_ENABLE_RISE}, 61 {"three_state_enable_fall", TimingType::THREE_STATE_ENABLE_FALL}, 62 {"rising_edge", TimingType::RISING_EDGE}, 63 {"falling_edge", TimingType::FALLING_EDGE}, 64 {"preset", TimingType::PRESET}, 65 {"clear", TimingType::CLEAR}, 66 {"hold_rising", TimingType::HOLD_RISING}, 67 {"hold_falling", TimingType::HOLD_FALLING}, 68 {"setup_rising", TimingType::SETUP_RISING}, 69 {"setup_falling", TimingType::SETUP_FALLING}, 70 {"recovery_rising", TimingType::RECOVERY_RISING}, 71 {"recovery_falling", TimingType::RECOVERY_FALLING}, 72 {"skew_rising", TimingType::SKEW_RISING}, 73 {"skew_falling", TimingType::SKEW_FALLING}, 74 {"removal_rising", TimingType::REMOVAL_RISING}, 75 {"removal_falling", TimingType::REMOVAL_FALLING}, 76 {"min_pulse_width", TimingType::MIN_PULSE_WIDTH}, 77 {"minimum_period", TimingType::MINIMUM_PERIOD}, 78 {"max_clock_tree_path", TimingType::MAX_CLOCK_TREE_PATH}, 79 {"min_clock_tree_path", TimingType::MIN_CLOCK_TREE_PATH}, 80 {"non_seq_setup_rising", TimingType::NON_SEQ_SETUP_RISING}, 81 {"non_seq_setup_falling", TimingType::NON_SEQ_SETUP_FALLING}, 82 {"non_seq_hold_rising", TimingType::NON_SEQ_HOLD_RISING}, 83 {"non_seq_hold_falling", TimingType::NON_SEQ_HOLD_FALLING}, 84 {"nochange_high_high", TimingType::NOCHANGE_HIGH_HIGH}, 85 {"nochange_high_low", TimingType::NOCHANGE_HIGH_LOW}, 86 {"nochange_low_high", TimingType::NOCHANGE_LOW_HIGH}, 87 {"nochange_low_low", TimingType::NOCHANGE_LOW_LOW} 88 }; 89 90 // Function: to_string 91 std::string to_string(TimingSense); 92 std::string to_string(TimingType); 93 94 // Struct: Timing 95 struct Timing { 96 97 std::string related_pin; 98 99 std::optional<TimingSense> sense; 100 std::optional<TimingType> type; 101 std::optional<Lut> cell_rise; 102 std::optional<Lut> cell_fall; 103 std::optional<Lut> rise_transition; 104 std::optional<Lut> fall_transition; 105 std::optional<Lut> rise_constraint; 106 std::optional<Lut> fall_constraint; 107 108 bool is_combinational() const; 109 bool is_constraint() const; 110 bool is_min_constraint() const; 111 bool is_max_constraint() const; 112 bool is_rising_edge_triggered() const; 113 bool is_falling_edge_triggered() const; 114 bool is_input_transition_defined() const; 115 bool is_input_transition_defined(Tran) const; 116 bool is_output_transition_defined(Tran) const; 117 bool is_transition_defined(Tran, Tran) const; 118 bool isomorphic(const Timing&) const; 119 120 void scale_time(float); 121 void scale_capacitance(float); 122 123 std::optional<float> delay(Tran, Tran, float, float) const; 124 std::optional<float> slew(Tran, Tran, float, float) const; 125 std::optional<float> constraint(Tran, Tran, float, float) const; 126 }; 127 128 std::ostream& operator << (std::ostream&, const Timing&); 129 130 // Alias 131 using TimingView = TimingData<const Timing*, MAX_SPLIT>; 132 133 134 }; // end of namespace ot. ----------------------------------------------------------------------- 135 136 137 #endif 138