1 #ifndef OT_LIBERTY_LIBERTY_HPP_
2 #define OT_LIBERTY_LIBERTY_HPP_
3 
4 #include <ot/liberty/cell.hpp>
5 #include <ot/unit/unit.hpp>
6 
7 namespace ot {
8 
9 // Enum: DelayModel
10 enum class DelayModel {
11   GENERIC_CMOS,
12   TABLE_LOOKUP,
13   CMOS2,
14   PIECEWISE_CMOS,
15   DCM,
16   POLYNOMIAL
17 };
18 
19 inline const std::unordered_map<std::string_view, DelayModel> delay_models {
20   {"generic_cmos",   DelayModel::GENERIC_CMOS},
21   {"table_lookup",   DelayModel::TABLE_LOOKUP},
22   {"cmos2",          DelayModel::CMOS2},
23   {"piecewise_cmos", DelayModel::PIECEWISE_CMOS},
24   {"dcm",            DelayModel::DCM},
25   {"polynomial",     DelayModel::POLYNOMIAL}
26 };
27 
28 // Function: to_string
29 std::string to_string(DelayModel);
30 
31 // Class: Celllib
32 struct Celllib {
33 
34   using token_iterator = std::vector<std::string_view>::iterator;
35 
36   std::string name {"OpenTimer"};
37 
38   std::optional<DelayModel> delay_model;
39 
40   std::optional<second_t> time_unit;
41   std::optional<watt_t> power_unit;
42   std::optional<ohm_t> resistance_unit;
43   std::optional<farad_t> capacitance_unit;
44   std::optional<ampere_t> current_unit;
45   std::optional<volt_t> voltage_unit;
46 
47   std::optional<float> default_cell_leakage_power;
48   std::optional<float> default_inout_pin_cap;
49   std::optional<float> default_input_pin_cap;
50   std::optional<float> default_output_pin_cap;
51   std::optional<float> default_fanout_load;
52   std::optional<float> default_max_fanout;
53   std::optional<float> default_max_transition;
54 
55   std::unordered_map<std::string, LutTemplate> lut_templates;
56   std::unordered_map<std::string, Cell> cells;
57 
58   void read(const std::filesystem::path&);
59   void scale_time(float);
60   void scale_resistance(float);
61   void scale_power(float);
62   void scale_capacitance(float);
63   void scale_current(float);
64   void scale_voltage(float);
65 
66   const LutTemplate* lut_template(const std::string&) const;
67   const Cell* cell(const std::string&) const;
68 
69   LutTemplate* lut_template(const std::string&);
70   Cell* cell(const std::string&);
71 
72   private:
73 
74     LutTemplate _extract_lut_template(token_iterator&, const token_iterator);
75     Lut         _extract_lut         (token_iterator&, const token_iterator);
76     Cell        _extract_cell        (token_iterator&, const token_iterator);
77     Cellpin     _extract_cellpin     (token_iterator&, const token_iterator);
78     Timing      _extract_timing      (token_iterator&, const token_iterator);
79 
80     void _apply_default_values();
81     void _uncomment(std::vector<char>&);
82     void _tokenize(const std::vector<char>&, std::vector<std::string_view>&);
83 };
84 
85 // Operator <<
86 std::ostream& operator << (std::ostream&, const Celllib&);
87 
88 
89 };  // end of namespace ot. -----------------------------------------------------------------------
90 
91 
92 #endif
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103