forked from The-OpenROAD-Project/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchPred.cc
272 lines (239 loc) · 6.57 KB
/
SearchPred.cc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2024, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "SearchPred.hh"
#include "TimingArc.hh"
#include "TimingRole.hh"
#include "Liberty.hh"
#include "Network.hh"
#include "Graph.hh"
#include "Sdc.hh"
#include "Levelize.hh"
#include "Search.hh"
#include "Latches.hh"
namespace sta {
static bool
searchThruSimEdge(const Vertex *vertex, const RiseFall *rf);
static bool
searchThruTimingSense(const Edge *edge, const RiseFall *from_rf,
const RiseFall *to_rf);
SearchPred0::SearchPred0(const StaState *sta) :
sta_(sta)
{
}
bool
SearchPred0::searchFrom(const Vertex *from_vertex)
{
return !(from_vertex->isDisabledConstraint()
|| from_vertex->isConstant());
}
bool
SearchPred0::searchThru(Edge *edge)
{
const TimingRole *role = edge->role();
const Sdc *sdc = sta_->sdc();
return !(edge->isDisabledConstraint()
// Constants disable edge cond expression.
|| edge->isDisabledCond()
|| sdc->isDisabledCondDefault(edge)
// Register/latch preset/clr edges are disabled by default.
|| (role == TimingRole::regSetClr()
&& !sdc->presetClrArcsEnabled())
// Constants on other pins disable this edge (ie, a mux select).
|| edge->simTimingSense() == TimingSense::none
|| (edge->isBidirectInstPath()
&& !sdc->bidirectInstPathsEnabled())
|| (edge->isBidirectNetPath()
&& !sdc->bidirectNetPathsEnabled())
|| (role == TimingRole::latchDtoQ()
&& sta_->latches()->latchDtoQState(edge)
== LatchEnableState::closed));
}
bool
SearchPred0::searchTo(const Vertex *to_vertex)
{
return !to_vertex->isConstant();
}
////////////////////////////////////////////////////////////////
SearchPred1::SearchPred1(const StaState *sta) :
SearchPred0(sta)
{
}
bool
SearchPred1::searchThru(Edge *edge)
{
return SearchPred0::searchThru(edge)
&& !edge->isDisabledLoop();
}
////////////////////////////////////////////////////////////////
SearchPred2::SearchPred2(const StaState *sta) :
SearchPred1(sta)
{
}
bool
SearchPred2::searchThru(Edge *edge)
{
return SearchPred1::searchThru(edge)
&& !edge->role()->isTimingCheck();
}
////////////////////////////////////////////////////////////////
SearchPredNonLatch2::SearchPredNonLatch2(const StaState *sta) :
SearchPred2(sta)
{
}
bool
SearchPredNonLatch2::searchThru(Edge *edge)
{
return SearchPred2::searchThru(edge)
&& !sta_->latches()->isLatchDtoQ(edge);
}
////////////////////////////////////////////////////////////////
SearchPredNonReg2::SearchPredNonReg2(const StaState *sta) :
SearchPred2(sta)
{
}
bool
SearchPredNonReg2::searchThru(Edge *edge)
{
const TimingRole *role = edge->role();
return SearchPred2::searchThru(edge)
// Enqueue thru latches is handled explicitly by search.
&& !sta_->latches()->isLatchDtoQ(edge)
&& role->genericRole() != TimingRole::regClkToQ();
}
////////////////////////////////////////////////////////////////
ClkTreeSearchPred::ClkTreeSearchPred(const StaState *sta) :
SearchPred1(sta)
{
}
bool
ClkTreeSearchPred::searchThru(Edge *edge)
{
const Sdc *sdc = sta_->sdc();
// Propagate clocks through constants.
const TimingRole *role = edge->role();
return (role->isWire()
|| role == TimingRole::combinational())
&& (sdc->clkThruTristateEnabled()
|| !(role == TimingRole::tristateEnable()
|| role == TimingRole::tristateDisable()))
&& SearchPred1::searchThru(edge);
}
bool
isClkEnd(Vertex *vertex,
Graph *graph)
{
ClkTreeSearchPred pred(graph);
VertexOutEdgeIterator edge_iter(vertex, graph);
while (edge_iter.hasNext()) {
Edge *edge = edge_iter.next();
if (pred.searchThru(edge))
return false;
}
return true;
}
////////////////////////////////////////////////////////////////
bool
searchThru(const Edge *edge,
const TimingArc *arc,
const Graph *graph)
{
RiseFall *from_rf = arc->fromEdge()->asRiseFall();
RiseFall *to_rf = arc->toEdge()->asRiseFall();
// Ignore transitions other than rise/fall.
return from_rf && to_rf
&& searchThru(edge->from(graph), from_rf, edge, edge->to(graph), to_rf);
}
bool
searchThru(Vertex *from_vertex,
const RiseFall *from_rf,
const Edge *edge,
Vertex *to_vertex,
const RiseFall *to_rf)
{
return searchThruTimingSense(edge, from_rf, to_rf)
&& searchThruSimEdge(from_vertex, from_rf)
&& searchThruSimEdge(to_vertex, to_rf);
}
// set_case_analysis rising/falling filters rise/fall edges during search.
static bool
searchThruSimEdge(const Vertex *vertex,
const RiseFall *rf)
{
LogicValue sim_value = vertex->simValue();
switch (sim_value) {
case LogicValue::rise:
return rf == RiseFall::rise();
case LogicValue::fall:
return rf == RiseFall::fall();
default:
return true;
};
}
static bool
searchThruTimingSense(const Edge *edge, const RiseFall *from_rf,
const RiseFall *to_rf)
{
switch (edge->simTimingSense()) {
case TimingSense::unknown:
return true;
case TimingSense::positive_unate:
return from_rf == to_rf;
case TimingSense::negative_unate:
return from_rf != to_rf;
case TimingSense::non_unate:
return true;
case TimingSense::none:
return false;
default:
return true;
}
}
////////////////////////////////////////////////////////////////
bool
hasFanin(Vertex *vertex,
SearchPred *pred,
const Graph *graph)
{
if (pred->searchTo(vertex)) {
VertexInEdgeIterator edge_iter(vertex, graph);
while (edge_iter.hasNext()) {
Edge *edge = edge_iter.next();
Vertex *from_vertex = edge->from(graph);
if (pred->searchFrom(from_vertex)
&& pred->searchThru(edge))
return true;
}
}
return false;
}
bool
hasFanout(Vertex *vertex,
SearchPred *pred,
const Graph *graph)
{
if (pred->searchFrom(vertex)) {
VertexOutEdgeIterator edge_iter(vertex, graph);
while (edge_iter.hasNext()) {
Edge *edge = edge_iter.next();
Vertex *to_vertex = edge->to(graph);
if (pred->searchTo(to_vertex)
&& pred->searchThru(edge))
return true;
}
}
return false;
}
} // namespace