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