1 #include <ot/timer/timer.hpp>
2 
3 namespace ot {
4 
5 // Function: _is_redundant_timing
_is_redundant_timing(const Timing & timing,Split el) const6 bool Timer::_is_redundant_timing(const Timing& timing, Split el) const {
7 
8   switch(el) {
9     case MIN:
10       if(timing.is_max_constraint()) {
11         return true;
12       }
13     break;
14 
15     case MAX:
16       if(timing.is_min_constraint()) {
17         return true;
18       }
19     break;
20   }
21 
22   return false;
23 }
24 
25 // Function: read_celllib
read_celllib(std::filesystem::path path,std::optional<Split> el)26 Timer& Timer::read_celllib(std::filesystem::path path, std::optional<Split> el) {
27 
28   auto lib = std::make_shared<Celllib>();
29 
30   std::scoped_lock lock(_mutex);
31 
32   // Library parser
33   auto parser = _taskflow.emplace([path=std::move(path), lib] () {
34     OT_LOGI("loading celllib ", path);
35     lib->read(path);
36   });
37 
38   // Placeholder to add_lineage
39   auto reader = _taskflow.emplace([this, lib, el] () {
40     if(el) {
41       _merge_celllib(*lib, *el);
42     }
43     else {
44       auto cpy = *lib;
45       _merge_celllib(cpy, MIN);
46       _merge_celllib(*lib, MAX);
47     }
48   });
49 
50   // Reader -> reader
51   parser.precede(reader);
52 
53   _add_to_lineage(reader);
54 
55   return *this;
56 }
57 
58 // Procedure: _merge_celllib
_merge_celllib(Celllib & lib,Split el)59 void Timer::_merge_celllib(Celllib& lib, Split el) {
60 
61   _rebase_unit(lib);
62 
63   // initialize a library
64   if(!_celllib[el]) {
65     _celllib[el] = std::move(lib);
66     OT_LOGI(
67       "added ", to_string(el), " celllib ", std::quoted(_celllib[el]->name),
68       " [cells:", _celllib[el]->cells.size(), ']'
69     );
70   }
71   // merge the library
72   else {
73     // Merge the lut template
74     _celllib[el]->lut_templates.merge(std::move(lib.lut_templates));
75 
76     // Merge the cell
77     _celllib[el]->cells.merge(std::move(lib.cells));
78 
79     OT_LOGI(
80       "merged with library ", std::quoted(lib.name),
81       " [cells:", _celllib[el]->cells.size(), ']'
82     );
83   }
84 }
85 
86 };  // end of namespace ot. -----------------------------------------------------------------------
87 
88 
89 
90 
91