forked from The-OpenROAD-Project/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExceptionPath.hh
673 lines (626 loc) · 21.5 KB
/
ExceptionPath.hh
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2023, 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/>.
#pragma once
#include "Error.hh"
#include "Set.hh"
#include "SdcCmdComment.hh"
#include "SdcClass.hh"
namespace sta {
class RiseFall;
class RiseFallBoth;
class MinMaxAll;
class Network;
class Pin;
class Clock;
class ExceptionPt;
class ExceptionFrom;
class ExceptionThru;
class ExceptionTo;
class ExceptionState;
typedef Vector<ExceptionPath*> ExceptionPathSeq;
class ExceptionPath : public SdcCmdComment
{
public:
ExceptionPath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
bool own_pts,
int priority,
const char *comment);
virtual ~ExceptionPath();
virtual bool isFalse() const { return false; }
virtual bool isLoop() const { return false; }
virtual bool isMultiCycle() const { return false; }
virtual bool isPathDelay() const { return false; }
virtual bool isGroupPath() const { return false; }
virtual bool isFilter() const { return false; }
virtual ExceptionPathType type() const = 0;
virtual const char *asString(const Network *network) const;
ExceptionFrom *from() const { return from_; }
ExceptionThruSeq *thrus() const { return thrus_; }
ExceptionTo *to() const { return to_; }
ExceptionPt *firstPt();
bool intersectsPts(ExceptionPath *exception) const;
const MinMaxAll *minMax() const { return min_max_; }
virtual bool matches(const MinMax *min_max,
bool exact) const;
bool matchesFirstPt(const RiseFall *to_rf,
const MinMax *min_max);
ExceptionState *firstState();
virtual bool resetMatch(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max);
// The priority remains the same even though pin/clock/net/inst objects
// are added to the exceptions points during exception merging because
// only exceptions with the same priority are merged.
virtual int priority(const MinMax *) const { return priority_; }
int priority() const { return priority_; }
void setPriority(int priority);
virtual int typePriority() const = 0;
// Exception type priorities are spaced to accomodate
// fromThruToPriority from 0 thru 127.
static int falsePathPriority() { return 4000; }
static int pathDelayPriority() { return 3000; }
static int multiCyclePathPriority() { return 2000; }
static int filterPathPriority() { return 1000; }
static int groupPathPriority() { return 0; }
// Compare the value (path delay or cycle count) to another exception
// of the same priority. Because the exception "values" are floats,
// they cannot be coded into the priority.
virtual bool tighterThan(ExceptionPath *exception) const = 0;
static int fromThruToPriority(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to);
size_t hash() const;
size_t hash(ExceptionPt *missing_pt) const;
// Mergeable properties (independent of exception points).
virtual bool mergeable(ExceptionPath *exception) const;
bool mergeablePts(ExceptionPath *exception) const;
bool mergeablePts(ExceptionPath *exception2,
ExceptionPt *missing_pt2,
ExceptionPt *&missing_pt) const;
// Overrides properties (independent of exception points).
virtual bool overrides(ExceptionPath *exception) const = 0;
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts) = 0;
// Default handlers.
virtual bool useEndClk() const { return false; }
virtual int pathMultiplier() const { return 0; }
virtual float delay() const { return 0.0; }
virtual const char *name() const { return nullptr; }
virtual bool isDefault() const { return false; }
virtual bool ignoreClkLatency() { return false; }
protected:
virtual const char *typeString() const = 0;
const char *fromThruToString(const Network *network) const;
void makeStates();
ExceptionFrom *from_;
ExceptionThruSeq *thrus_;
ExceptionTo *to_;
const MinMaxAll *min_max_;
bool own_pts_;
int priority_;
ExceptionState *states_;
};
// set_false_path
class FalsePath : public ExceptionPath
{
public:
FalsePath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
bool own_pts,
const char *comment);
FalsePath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
bool own_pts,
int priority,
const char *comment);
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual bool isFalse() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::false_path; }
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
virtual bool overrides(ExceptionPath *exception) const;
virtual int typePriority() const;
virtual bool tighterThan(ExceptionPath *exception) const;
};
// Loop paths are false paths used to disable paths around
// combinational loops when dynamic loop breaking is enabled.
class LoopPath : public FalsePath
{
public:
LoopPath(ExceptionThruSeq *thrus,
bool own_pts);
virtual bool isLoop() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::loop; }
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
};
// set_max_delay/set_min_delay
class PathDelay : public ExceptionPath
{
public:
PathDelay(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMax *min_max,
bool ignore_clk_latency,
float delay,
bool own_pts,
const char *comment);
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual bool isPathDelay() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::path_delay; }
virtual const char *asString(const Network *network) const;
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
virtual bool overrides(ExceptionPath *exception) const;
virtual float delay() const { return delay_; }
virtual int typePriority() const;
virtual bool tighterThan(ExceptionPath *exception) const;
virtual bool ignoreClkLatency() { return ignore_clk_latency_; }
protected:
bool ignore_clk_latency_;
float delay_;
};
// set_multicycle_path
class MultiCyclePath : public ExceptionPath
{
public:
MultiCyclePath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max,
bool use_end_clk,
int path_multiplier,
bool own_pts,
const char *comment);
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual bool isMultiCycle() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::multi_cycle; }
virtual bool matches(const MinMax *min_max,
bool exactly) const;
virtual const char *asString(const Network *network) const;
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
virtual bool overrides(ExceptionPath *exception) const;
virtual bool useEndClk() const { return use_end_clk_; }
virtual int pathMultiplier(const MinMax *min_max) const;
virtual int pathMultiplier() const { return path_multiplier_; }
virtual int priority(const MinMax *min_max) const;
virtual int typePriority() const;
virtual bool tighterThan(ExceptionPath *exception) const;
using ExceptionPath::priority;
protected:
bool use_end_clk_;
int path_multiplier_;
};
// Filter used restrict path reporting -from/-thru nets/pins.
class FilterPath : public ExceptionPath
{
public:
FilterPath(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual bool isFilter() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::filter; }
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
virtual bool overrides(ExceptionPath *exception) const;
virtual bool resetMatch(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
const MinMaxAll *min_max);
virtual int typePriority() const;
virtual bool tighterThan(ExceptionPath *exception) const;
};
class GroupPath : public ExceptionPath
{
public:
GroupPath(const char *name,
bool is_default,
ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts,
const char *comment);
virtual ~GroupPath();
virtual ExceptionPath *clone(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to,
bool own_pts);
virtual bool isGroupPath() const { return true; }
virtual ExceptionPathType type() const { return ExceptionPathType::group_path; }
virtual const char *typeString() const;
virtual bool mergeable(ExceptionPath *exception) const;
virtual bool overrides(ExceptionPath *exception) const;
virtual int typePriority() const;
virtual bool tighterThan(ExceptionPath *exception) const;
virtual const char *name() const { return name_; }
virtual bool isDefault() const { return is_default_; }
protected:
const char *name_;
bool is_default_;
};
// Base class for Exception from/thru/to.
class ExceptionPt
{
public:
ExceptionPt(const RiseFallBoth *rf,
bool own_pts);
virtual ~ExceptionPt() {};
virtual bool isFrom() const { return false; }
virtual bool isThru() const { return false; }
virtual bool isTo() const { return false; }
const RiseFallBoth *transition() const { return rf_; }
virtual PinSet *pins() = 0;
virtual ClockSet *clks() = 0;
virtual InstanceSet *instances() = 0;
virtual NetSet *nets() = 0;
virtual EdgePinsSet *edges() = 0;
size_t hash() const;
virtual int compare(ExceptionPt *pt,
const Network *network) const = 0;
virtual void mergeInto(ExceptionPt *pt,
const Network *network) = 0;
// All pins and instance/net pins.
virtual void allPins(const Network *network,
PinSet *pins) = 0;
virtual int typePriority() const = 0;
virtual const char *asString(const Network *network) const = 0;
virtual size_t objectCount() const = 0;
virtual void addPin(const Pin *pin,
const Network *network) = 0;
virtual void addClock(Clock *clk) = 0;
virtual void addInstance(const Instance *inst,
const Network *network) = 0;
virtual void addNet(const Net *net,
const Network *network) = 0;
virtual void addEdge(const EdgePins &edge,
const Network *network) = 0;
virtual void connectPinAfter(PinSet *,
Network *network) = 0;
virtual void disconnectPinBefore(const Pin *pin,
Network *network) = 0;
protected:
const RiseFallBoth *rf_;
// True when the pin/net/inst/edge sets are owned by the exception point.
bool own_pts_;
// Hash is cached because there may be many objects to speed up
// exception merging.
size_t hash_;
// Maximum number of objects for asString() to show.
static const int as_string_max_objects_;
static const size_t hash_clk = 3;
static const size_t hash_pin = 5;
static const size_t hash_net = 7;
static const size_t hash_inst = 11;
};
class ExceptionFromTo : public ExceptionPt
{
public:
ExceptionFromTo(PinSet *pins,
ClockSet *clks,
InstanceSet *insts,
const RiseFallBoth *rf,
bool own_pts,
const Network *network);
~ExceptionFromTo();
virtual PinSet *pins() { return pins_; }
bool hasPins() const;
ClockSet *clks() { return clks_; }
bool hasClocks() const;
InstanceSet *instances() { return insts_; }
bool hasInstances() const;
virtual NetSet *nets() { return nullptr; }
virtual EdgePinsSet *edges() { return nullptr; }
bool hasObjects() const;
void deleteObjects(ExceptionFromTo *pt,
const Network *network);
virtual void allPins(const Network *network,
PinSet *pins);
bool equal(ExceptionFromTo *from_to) const;
virtual int compare(ExceptionPt *pt,
const Network *network) const;
virtual void mergeInto(ExceptionPt *pt,
const Network *network);
virtual const char *asString(const Network *network) const;
virtual size_t objectCount() const;
void deleteClock(Clock *clk);
virtual void addPin(const Pin *pin,
const Network *network);
virtual void addClock(Clock *clk);
virtual void addInstance(const Instance *inst,
const Network *network);
virtual void addNet(const Net *,
const Network *) {}
virtual void addEdge(const EdgePins &,
const Network *) {}
virtual void connectPinAfter(PinSet *,
Network *) {}
virtual void disconnectPinBefore(const Pin *,
Network *) {}
protected:
virtual void findHash(const Network *network);
void deletePin(const Pin *pin,
const Network *network);
void deleteInstance(const Instance *inst,
const Network *network);
virtual const char *cmdKeyword() const = 0;
PinSet *pins_;
ClockSet *clks_;
InstanceSet *insts_;
};
class ExceptionFrom : public ExceptionFromTo
{
public:
ExceptionFrom(PinSet *pins,
ClockSet *clks,
InstanceSet *insts,
const RiseFallBoth *rf,
bool own_pts,
const Network *network);
ExceptionFrom *clone(const Network *network);
virtual bool isFrom() const { return true; }
bool intersectsPts(ExceptionFrom *from) const;
virtual int typePriority() const { return 0; }
protected:
virtual const char *cmdKeyword() const;
virtual void findHash(const Network *network);
};
class ExceptionTo : public ExceptionFromTo
{
public:
ExceptionTo(PinSet *pins,
ClockSet *clks,
InstanceSet *insts,
// -to|-rise_to|-fall_to
const RiseFallBoth *rf,
// -rise|-fall endpoint transition.
const RiseFallBoth *end_rf,
bool own_pts,
const Network *network);
ExceptionTo *clone(const Network *network);
virtual bool isTo() const { return true; }
const char *asString(const Network *network) const;
const RiseFallBoth *endTransition() { return end_rf_; }
bool intersectsPts(ExceptionTo *to) const;
virtual int typePriority() const { return 1; }
bool matches(const Pin *pin,
const ClockEdge *clk_edge,
const RiseFall *end_rf,
const Network *network) const;
bool matches(const Pin *pin,
const RiseFall *end_rf) const;
bool matches(const Clock *clk) const;
bool matches(const Pin *pin,
const RiseFall *end_rf,
const Network *network) const;
bool matchesFilter(const Pin *pin,
const ClockEdge *clk_edge,
const RiseFall *end_rf,
const Network *network) const;
virtual int compare(ExceptionPt *pt,
const Network *network) const;
protected:
bool matches(const Pin *pin,
const ClockEdge *clk_edge,
const RiseFall *end_rf,
bool inst_matches_reg_clk_pin,
const Network *network) const;
virtual const char *cmdKeyword() const;
// -rise|-fall endpoint transition.
const RiseFallBoth *end_rf_;
};
class ExceptionThru : public ExceptionPt
{
public:
ExceptionThru(PinSet *pins,
NetSet *nets,
InstanceSet *insts,
const RiseFallBoth *rf,
bool own_pts,
const Network *network);
~ExceptionThru();
ExceptionThru *clone(const Network *network);
virtual const char *asString(const Network *network) const;
virtual bool isThru() const { return true; }
PinSet *pins() { return pins_; }
EdgePinsSet *edges() { return edges_; }
NetSet *nets() { return nets_; }
InstanceSet *instances() { return insts_; }
virtual ClockSet *clks() { return nullptr; }
bool hasObjects() const;
void deleteObjects(ExceptionThru *pt,
const Network *network);
virtual void allPins(const Network *network,
PinSet *pins);
bool matches(const Pin *from_pin,
const Pin *to_pin,
const RiseFall *to_rf,
const Network *network);
bool equal(ExceptionThru *thru) const;
virtual int compare(ExceptionPt *pt,
const Network *network) const;
virtual void mergeInto(ExceptionPt *pt,
const Network *network);
bool intersectsPts(ExceptionThru *thru) const;
virtual int typePriority() const { return 2; }
virtual size_t objectCount() const;
virtual void connectPinAfter(PinSet *drvrs,
Network *network);
virtual void disconnectPinBefore(const Pin *pin,
Network *network);
protected:
void findHash(const Network *network);
virtual void addPin(const Pin *pin,
const Network *network);
virtual void addEdge(const EdgePins &edge,
const Network *network);
virtual void addNet(const Net *net,
const Network *network);
virtual void addInstance(const Instance *inst,
const Network *network);
virtual void addClock(Clock *) {}
void deletePin(const Pin *pin,
const Network *network);
void deleteEdge(const EdgePins &edge);
void deleteNet(const Net *net,
const Network *network);
void deleteInstance(const Instance *inst,
const Network *network);
void makeAllEdges(const Network *network);
void makePinEdges(const Network *network);
void makeNetEdges(const Network *network);
void makeInstEdges(const Network *network);
void makeHpinEdges(const Pin *pin,
const Network *network);
void makePinEdges(const Pin *pin,
const Network *network);
void makeNetEdges(const Net *net,
const Network *network);
void makeInstEdges(Instance *inst,
Network *network);
void deletePinEdges(const Pin *pin,
Network *network);
void deleteNetEdges(Net *net,
const Network *network);
void deleteInstEdges(Instance *inst,
Network *network);
// Leaf/port pins.
PinSet *pins_;
// Graph edges that traverse thru hierarchical pins.
EdgePinsSet *edges_;
NetSet *nets_;
InstanceSet *insts_;
};
ExceptionThruSeq *
exceptionThrusClone(ExceptionThruSeq *thrus,
const Network *network);
// Iterate uniformly across exception from/thru/to's.
class ExceptionPtIterator
{
public:
explicit ExceptionPtIterator(const ExceptionPath *exception);
bool hasNext();
ExceptionPt *next();
private:
const ExceptionPath *exception_;
bool from_done_;
ExceptionThruSeq::Iterator thru_iter_;
bool to_done_;
};
// Visitor for exception point sets expanded into single object paths.
// For example:
// -from {A B} -to {C D}
// expands into
// -from A -to C
// -from A -to D
// -from B -to C
// -from B -to D
class ExpandedExceptionVisitor
{
public:
ExpandedExceptionVisitor(ExceptionPath *exception,
const Network *network);
virtual ~ExpandedExceptionVisitor() {}
void visitExpansions();
// From/thrus/to have a single exception point (pin/instance/net/clock).
virtual void visit(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to) = 0;
protected:
ExceptionPath *exception_;
const Network *network_;
private:
void expandFrom();
void expandThrus(ExceptionFrom *expanded_from);
void expandThru(ExceptionFrom *expanded_from,
ExceptionThruSeq::Iterator &thru_iter,
ExceptionThruSeq *expanded_thrus);
void expandTo(ExceptionFrom *expanded_from,
ExceptionThruSeq *expanded_thrus);
};
// States used by tags to know what exception points have been seen
// so far in a path.
class ExceptionState
{
public:
ExceptionState(ExceptionPath *exception,
ExceptionThru *next_thru,
int index);
ExceptionPath *exception() { return exception_; }
const ExceptionPath *exception() const { return exception_; }
bool matchesNextThru(const Pin *from_pin,
const Pin *to_pin,
const RiseFall *to_rf,
const MinMax *min_max,
const Network *network) const;
bool isComplete() const;
ExceptionThru *nextThru() const { return next_thru_; }
ExceptionState *nextState() const { return next_state_; }
void setNextState(ExceptionState *next_state);
int index() const { return index_; }
size_t hash() const;
private:
ExceptionPath *exception_;
ExceptionThru *next_thru_;
ExceptionState *next_state_;
int index_;
};
// Exception thrown by check.
class EmptyExpceptionPt : public Exception
{
public:
virtual const char *what() const noexcept;
};
class ExceptionPathLess
{
public:
ExceptionPathLess(const Network *network);
bool operator()(const ExceptionPath *except1,
const ExceptionPath *except2) const;
private:
const Network *network_;
};
// Throws EmptyExpceptionPt it finds an empty exception point.
void
checkFromThrusTo(ExceptionFrom *from,
ExceptionThruSeq *thrus,
ExceptionTo *to);
} // namespace