1 #ifndef OT_TIMER_PATH_HPP_
2 #define OT_TIMER_PATH_HPP_
3 
4 #include <ot/headerdef.hpp>
5 
6 namespace ot {
7 
8 class Pin;
9 class Endpoint;
10 
11 // ------------------------------------------------------------------------------------------------
12 
13 // Struct: Point
14 struct Point {
15 
16   const Pin& pin;     // pin reference
17   Tran  transition;   // rise/fall
18   float at;           // arrival
19 
20   Point(const Pin&, Tran, float);
21 };
22 
23 // ------------------------------------------------------------------------------------------------
24 
25 // Struct: Path
26 struct Path : std::list<Point> {
27 
28   Path(float, const Endpoint*);
29   Path(const Path&) = delete;
30   Path(Path&&) = default;
31 
32   Path& operator = (const Path&) = delete;
33   Path& operator = (Path&&) = default;
34 
35   void dump(std::ostream&) const;
36   void dump_tau18(std::ostream&) const;
37 
38   float slack {std::numeric_limits<float>::quiet_NaN()};
39 
40   const Endpoint* endpoint {nullptr};
41 };
42 
43 // Operator << ostream
44 std::ostream& operator << (std::ostream&, const Path&);
45 
46 // ------------------------------------------------------------------------------------------------
47 
48 // Class: PathHeap
49 // A max-heap to maintain the top-k critical paths during the path ranking process.
50 class PathHeap {
51 
52   friend class Timer;
53 
54   // max heap
55   struct PathComparator {
operator ()ot::PathHeap::PathComparator56     bool operator () (const std::unique_ptr<Path>& a, const std::unique_ptr<Path>& b) const {
57       return a->slack < b->slack;
58     }
59   };
60 
61   public:
62 
63     PathHeap() = default;
64     PathHeap(PathHeap&&) = default;
65     PathHeap(const PathHeap&) = delete;
66 
67     PathHeap& operator = (PathHeap&&) = default;
68     PathHeap& operator = (const PathHeap&) = delete;
69 
70     inline size_t num_paths() const;
71     inline size_t size() const;
72     inline bool empty() const;
73 
74     std::vector<Path> extract();
75 
76     void push(std::unique_ptr<Path>);
77     void fit(size_t);
78     void pop();
79     void merge_and_fit(PathHeap&&, size_t);
80     void heapify();
81 
82     Path* top() const;
83 
84     std::string dump() const;
85 
86   private:
87 
88     PathComparator _comp;
89 
90     std::vector<std::unique_ptr<Path>> _paths;
91 };
92 
93 // Function: num_paths
num_paths() const94 inline size_t PathHeap::num_paths() const {
95   return _paths.size();
96 }
97 
98 // Function: size
size() const99 inline size_t PathHeap::size() const {
100   return _paths.size();
101 }
102 
103 // Function: empty
empty() const104 inline bool PathHeap::empty() const {
105   return _paths.empty();
106 }
107 
108 // ----------------------------------------------------------------------------
109 
110 // Class: PathGuide
111 struct PathGuide {
112   std::optional<size_t> max_paths;
113   std::optional<size_t> num_paths_per_endpoint;
114   std::vector<std::string> from;
115   std::vector<std::string> rise_from;
116   std::vector<std::string> fall_from;
117   std::vector<std::string> to;
118   std::vector<std::string> rise_to;
119   std::vector<std::string> fall_to;
120   std::vector<std::string> through;
121   std::vector<std::string> rise_through;
122   std::vector<std::string> fall_through;
123 };
124 
125 };  // end of namespace ot. ---------------------------------------------------
126 
127 
128 
129 #endif
130 
131 
132 
133 
134 
135 
136 
137