forked from The-OpenROAD-Project/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PathEnd.cc
2080 lines (1867 loc) · 48.9 KB
/
PathEnd.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
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
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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/>.
#include "PathEnd.hh"
#include "Debug.hh"
#include "TimingRole.hh"
#include "TimingArc.hh"
#include "Liberty.hh"
#include "Network.hh"
#include "Graph.hh"
#include "Clock.hh"
#include "PortDelay.hh"
#include "DataCheck.hh"
#include "Sdc.hh"
#include "ExceptionPath.hh"
#include "ClkInfo.hh"
#include "Tag.hh"
#include "PathAnalysisPt.hh"
#include "Search.hh"
#include "ReportPath.hh"
#include "Sim.hh"
#include "Latches.hh"
#include "StaState.hh"
#include "PathExpanded.hh"
#include "search/Crpr.hh"
namespace sta {
PathEnd::PathEnd(Path *path) :
path_(path)
{
}
PathEnd::~PathEnd()
{
path_.deleteRep();
}
void
PathEnd::setPath(PathEnumed *path,
const StaState *)
{
path_.init(path);
}
Vertex *
PathEnd::vertex(const StaState *sta) const
{
return path_.vertex(sta);
}
const MinMax *
PathEnd::minMax(const StaState *sta) const
{
return path_.pathAnalysisPt(sta)->pathMinMax();
}
const EarlyLate *
PathEnd::pathEarlyLate(const StaState *sta) const
{
return path_.pathAnalysisPt(sta)->pathMinMax();
}
const EarlyLate *
PathEnd::clkEarlyLate(const StaState *sta) const
{
return checkRole(sta)->tgtClkEarlyLate();
}
const RiseFall *
PathEnd::transition(const StaState *sta) const
{
return path_.transition(sta);
}
PathAPIndex
PathEnd::pathIndex(const StaState *sta) const
{
return path_.pathAnalysisPtIndex(sta);
}
PathAnalysisPt *
PathEnd::pathAnalysisPt(const StaState *sta) const
{
return path_.pathAnalysisPt(sta);
}
const ClockEdge *
PathEnd::sourceClkEdge(const StaState *sta) const
{
return path_.clkEdge(sta);
}
Arrival
PathEnd::dataArrivalTime(const StaState *sta) const
{
return path_.arrival(sta);
}
Arrival
PathEnd::dataArrivalTimeOffset(const StaState *sta) const
{
return dataArrivalTime(sta) + sourceClkOffset(sta);
}
Required
PathEnd::requiredTimeOffset(const StaState *sta) const
{
return requiredTime(sta) + sourceClkOffset(sta);
}
const RiseFall *
PathEnd::targetClkEndTrans(const StaState *sta) const
{
const PathVertex *clk_path = targetClkPath();
if (clk_path)
return clk_path->transition(sta);
else {
const ClockEdge *clk_edge = targetClkEdge(sta);
if (clk_edge)
return clk_edge->transition();
else
return nullptr;
}
}
const TimingRole *
PathEnd::checkGenericRole(const StaState *sta) const
{
return checkRole(sta)->genericRole();
}
Delay
PathEnd::sourceClkLatency(const StaState *) const
{
return delay_zero;
}
Delay
PathEnd::sourceClkInsertionDelay(const StaState *) const
{
return delay_zero;
}
const Clock *
PathEnd::targetClk(const StaState *) const
{
return nullptr;
}
const ClockEdge *
PathEnd::targetClkEdge(const StaState *) const
{
return nullptr;
}
float
PathEnd::targetClkTime(const StaState *) const
{
return 0.0;
}
float
PathEnd::targetClkOffset(const StaState *) const
{
return 0.0;
}
Arrival
PathEnd::targetClkArrival(const StaState *) const
{
return delay_zero;
}
Delay
PathEnd::targetClkDelay(const StaState *) const
{
return delay_zero;
}
Delay
PathEnd::targetClkInsertionDelay(const StaState *) const
{
return delay_zero;
}
float
PathEnd::targetNonInterClkUncertainty(const StaState *) const
{
return 0.0;
}
float
PathEnd::interClkUncertainty(const StaState *) const
{
return 0.0;
}
float
PathEnd::targetClkUncertainty(const StaState *) const
{
return 0.0;
}
float
PathEnd::targetClkMcpAdjustment(const StaState *) const
{
return 0.0;
}
TimingRole *
PathEnd::checkRole(const StaState *) const
{
return nullptr;
}
PathVertex *
PathEnd::targetClkPath()
{
return nullptr;
}
const PathVertex *
PathEnd::targetClkPath() const
{
return nullptr;
}
bool
PathEnd::pathDelayMarginIsExternal() const
{
return false;
}
PathDelay *
PathEnd::pathDelay() const
{
return nullptr;
}
Arrival
PathEnd::borrow(const StaState *) const
{
return 0.0;
}
Crpr
PathEnd::commonClkPessimism(const StaState *) const
{
return 0.0;
}
MultiCyclePath *
PathEnd::multiCyclePath() const
{
return nullptr;
}
int
PathEnd::exceptPathCmp(const PathEnd *path_end,
const StaState *) const
{
Type type1 = type();
Type type2 = path_end->type();
if (type1 == type2)
return 0;
else if (type1 < type2)
return -1;
else
return 1;
}
// PathExpanded::expand() and PathExpanded::clkPath().
// Similar to srcClkPath but for PathVertex's.
void
PathEnd::clkPath(PathVertex *path,
const StaState *sta,
// Return value.
PathVertex &clk_path)
{
PathVertex p(path);
while (!p.isNull()) {
PathVertex prev_path;
TimingArc *prev_arc;
p.prevPath(sta, prev_path, prev_arc);
if (p.isClock(sta)) {
clk_path = p;
return;
}
if (prev_arc) {
TimingRole *prev_role = prev_arc->role();
if (prev_role == TimingRole::regClkToQ()
|| prev_role == TimingRole::latchEnToQ()) {
p.prevPath(sta, prev_path, prev_arc);
clk_path = prev_path;
return;
}
else if (prev_role == TimingRole::latchDtoQ()) {
const Latches *latches = sta->latches();
Edge *prev_edge = p.prevEdge(prev_arc, sta);
PathVertex enable_path;
latches->latchEnablePath(&p, prev_edge, enable_path);
clk_path = enable_path;
return;
}
}
p = prev_path;
}
}
////////////////////////////////////////////////////////////////
Arrival
PathEnd::checkTgtClkDelay(const PathVertex *tgt_clk_path,
const ClockEdge *tgt_clk_edge,
const TimingRole *check_role,
const StaState *sta)
{
Arrival insertion, latency;
checkTgtClkDelay(tgt_clk_path, tgt_clk_edge, check_role, sta,
insertion, latency);
return Arrival(insertion + latency);
}
void
PathEnd::checkTgtClkDelay(const PathVertex *tgt_clk_path,
const ClockEdge *tgt_clk_edge,
const TimingRole *check_role,
const StaState *sta,
// Return values.
Arrival &insertion,
Arrival &latency)
{
if (tgt_clk_path) {
Search *search = sta->search();
// If propagated clk, adjust required time for target clk network delay.
const MinMax *min_max = tgt_clk_path->minMax(sta);
const EarlyLate *early_late = check_role->tgtClkEarlyLate();
const PathAnalysisPt *tgt_path_ap = tgt_clk_path->pathAnalysisPt(sta);
ClkInfo *clk_info = tgt_clk_path->clkInfo(sta);
const Pin *tgt_src_pin = clk_info->clkSrc();
const Clock *tgt_clk = tgt_clk_edge->clock();
const RiseFall *tgt_clk_rf = tgt_clk_edge->transition();
insertion = search->clockInsertion(tgt_clk, tgt_src_pin, tgt_clk_rf,
min_max, early_late, tgt_path_ap);
if (clk_info->isPropagated()
// Data check target clock is always propagated.
|| check_role->isDataCheck()) {
// Propagated clock. Propagated arrival is seeded with
// early_late==path_min_max insertion delay.
Arrival clk_arrival = tgt_clk_path->arrival(sta);
Arrival path_insertion = search->clockInsertion(tgt_clk, tgt_src_pin,
tgt_clk_rf, min_max,
min_max, tgt_path_ap);
latency = delayRemove(clk_arrival - tgt_clk_edge->time(), path_insertion);
}
else
// Ideal clock.
latency = clk_info->latency();
}
else {
insertion = 0.0F;
latency = 0.0F;
}
}
float
PathEnd::checkClkUncertainty(const ClockEdge *src_clk_edge,
const ClockEdge *tgt_clk_edge,
const PathVertex *tgt_clk_path,
const TimingRole *check_role,
const StaState *sta)
{
float inter_clk;
bool inter_exists;
checkInterClkUncertainty(src_clk_edge, tgt_clk_edge, check_role, sta,
inter_clk, inter_exists);
if (inter_exists)
return inter_clk;
else
return checkNonInterClkUncertainty(tgt_clk_path, tgt_clk_edge,
check_role, sta);
}
float
PathEnd::checkNonInterClkUncertainty(const PathVertex *tgt_clk_path,
const ClockEdge *tgt_clk_edge,
const TimingRole *check_role,
const StaState *sta)
{
MinMax *min_max = check_role->pathMinMax();
ClockUncertainties *uncertainties = nullptr;
if (tgt_clk_path && tgt_clk_path->isClock(sta))
uncertainties = tgt_clk_path->clkInfo(sta)->uncertainties();
else if (tgt_clk_edge)
uncertainties = tgt_clk_edge->clock()->uncertainties();
float uncertainty = 0.0;
if (uncertainties) {
bool exists;
float uncertainty1;
uncertainties->value(min_max, uncertainty1, exists);
if (exists)
uncertainty = uncertainty1;
}
if (check_role->genericRole() == TimingRole::setup())
uncertainty = -uncertainty;
return uncertainty;
}
void
PathEnd::checkInterClkUncertainty(const ClockEdge *src_clk_edge,
const ClockEdge *tgt_clk_edge,
const TimingRole *check_role,
const StaState *sta,
float &uncertainty,
bool &exists)
{
Sdc *sdc = sta->sdc();
if (src_clk_edge
&& src_clk_edge != sdc->defaultArrivalClockEdge()
&& tgt_clk_edge) {
sdc->clockUncertainty(src_clk_edge->clock(),
src_clk_edge->transition(),
tgt_clk_edge->clock(),
tgt_clk_edge->transition(),
check_role->pathMinMax(),
uncertainty, exists);
if (exists
&& check_role->genericRole() == TimingRole::setup())
uncertainty = -uncertainty;
}
else
exists = false;
}
////////////////////////////////////////////////////////////////
void
PathEndUnconstrained::reportFull(ReportPath *report) const
{
report->reportFull(this);
}
Slack
PathEndUnconstrained::slackNoCrpr(const StaState *) const
{
return INF;
}
void
PathEndUnconstrained::reportShort(ReportPath *report) const
{
report->reportShort(this);
}
////////////////////////////////////////////////////////////////
PathEndUnconstrained::PathEndUnconstrained(Path *path) :
PathEnd(path)
{
}
PathEnd *
PathEndUnconstrained::copy()
{
return new PathEndUnconstrained(path_.path());
}
bool
PathEndUnconstrained::isUnconstrained() const
{
return true;
}
Required
PathEndUnconstrained::requiredTime(const StaState *sta) const
{
return delayInitValue(minMax(sta)->opposite());
}
Required
PathEndUnconstrained::requiredTimeOffset(const StaState *sta) const
{
return delayInitValue(minMax(sta)->opposite());
}
ArcDelay
PathEndUnconstrained::margin(const StaState *) const
{
return delay_zero;
}
Slack
PathEndUnconstrained::slack(const StaState *) const
{
return INF;
}
float
PathEndUnconstrained::sourceClkOffset(const StaState *) const
{
return 0.0;
}
PathEnd::Type
PathEndUnconstrained::type() const
{
return Type::unconstrained;
}
const char *
PathEndUnconstrained::typeName() const
{
return "unconstrained";
}
////////////////////////////////////////////////////////////////
PathEndClkConstrained::PathEndClkConstrained(Path *path,
PathVertex *clk_path) :
PathEnd(path),
clk_path_(clk_path),
crpr_(0.0),
crpr_valid_(false)
{
}
PathEndClkConstrained::PathEndClkConstrained(Path *path,
PathVertex *clk_path,
Crpr crpr,
bool crpr_valid) :
PathEnd(path),
clk_path_(clk_path),
crpr_(crpr),
crpr_valid_(crpr_valid)
{
}
void
PathEndClkConstrained::setPath(PathEnumed *path,
const StaState *)
{
path_.init(path);
crpr_valid_ = false;
}
float
PathEndClkConstrained::sourceClkOffset(const StaState *sta) const
{
return sourceClkOffset(sourceClkEdge(sta),
targetClkEdge(sta),
checkRole(sta),
sta);
}
float
PathEndClkConstrained::sourceClkOffset(const ClockEdge *src_clk_edge,
const ClockEdge *tgt_clk_edge,
const TimingRole *check_role,
const StaState *sta) const
{
Sdc *sdc = sta->sdc();
CycleAccting *acct = sdc->cycleAccting(src_clk_edge, tgt_clk_edge);
return acct->sourceTimeOffset(check_role);
}
Arrival
PathEndClkConstrained::sourceClkLatency(const StaState *sta) const
{
ClkInfo *clk_info = path_.clkInfo(sta);
return clk_info->latency();
}
Arrival
PathEndClkConstrained::sourceClkInsertionDelay(const StaState *sta) const
{
ClkInfo *clk_info = path_.clkInfo(sta);
return clk_info->insertion();
}
PathVertex *
PathEndClkConstrained::targetClkPath()
{
if (clk_path_.isNull())
return nullptr;
else
return &clk_path_;
}
const PathVertex *
PathEndClkConstrained::targetClkPath() const
{
if (clk_path_.isNull())
return nullptr;
else
return &clk_path_;
}
float
PathEndClkConstrained::targetClkOffset(const StaState *sta) const
{
const ClockEdge *src_clk_edge = sourceClkEdge(sta);
const ClockEdge *tgt_clk_edge = targetClkEdge(sta);
const TimingRole *check_role = checkRole(sta);
Sdc *sdc = sta->sdc();
CycleAccting *acct = sdc->cycleAccting(src_clk_edge, tgt_clk_edge);
return acct->targetTimeOffset(check_role);
}
const ClockEdge *
PathEndClkConstrained::targetClkEdge(const StaState *sta) const
{
if (!clk_path_.isNull())
return clk_path_.clkEdge(sta);
else
return nullptr;
}
const Clock *
PathEndClkConstrained::targetClk(const StaState *sta) const
{
const ClockEdge *clk_edge = targetClkEdge(sta);
if (clk_edge)
return clk_edge->clock();
else
return nullptr;
}
float
PathEndClkConstrained::targetClkTime(const StaState *sta) const
{
const ClockEdge *src_clk_edge = sourceClkEdge(sta);
const ClockEdge *tgt_clk_edge = targetClkEdge(sta);
const TimingRole *check_role = checkRole(sta);
Sdc *sdc = sta->sdc();
CycleAccting *acct = sdc->cycleAccting(src_clk_edge, tgt_clk_edge);
return acct->requiredTime(check_role);
}
Arrival
PathEndClkConstrained::targetClkArrival(const StaState *sta) const
{
return targetClkArrivalNoCrpr(sta)
+ commonClkPessimism(sta);
}
Arrival
PathEndClkConstrained::targetClkArrivalNoCrpr(const StaState *sta) const
{
return targetClkTime(sta)
+ targetClkDelay(sta)
+ checkClkUncertainty(sourceClkEdge(sta),
targetClkEdge(sta),
targetClkPath(),
checkRole(sta), sta)
+ targetClkMcpAdjustment(sta);
}
Arrival
PathEndClkConstrained::targetClkDelay(const StaState *sta) const
{
return checkTgtClkDelay(targetClkPath(), targetClkEdge(sta),
checkRole(sta), sta);
}
Arrival
PathEndClkConstrained::targetClkInsertionDelay(const StaState *sta) const
{
Arrival insertion, latency;
checkTgtClkDelay(targetClkPath(), targetClkEdge(sta),
checkRole(sta), sta,
insertion, latency);
return insertion;
}
float
PathEndClkConstrained::targetNonInterClkUncertainty(const StaState *sta) const
{
const ClockEdge *src_clk_edge = sourceClkEdge(sta);
const ClockEdge *tgt_clk_edge = targetClkEdge(sta);
const TimingRole *check_role = checkRole(sta);
float inter_clk;
bool inter_exists;
checkInterClkUncertainty(src_clk_edge, tgt_clk_edge, check_role,
sta, inter_clk, inter_exists);
if (inter_exists)
// This returns non inter-clock uncertainty.
return 0.0;
else
return checkNonInterClkUncertainty(targetClkPath(), tgt_clk_edge,
check_role, sta);
}
float
PathEndClkConstrained::interClkUncertainty(const StaState *sta) const
{
float uncertainty;
bool exists;
checkInterClkUncertainty(sourceClkEdge(sta), targetClkEdge(sta),
checkRole(sta), sta,
uncertainty, exists);
if (exists)
return uncertainty;
else
return 0.0;
}
float
PathEndClkConstrained::targetClkUncertainty(const StaState *sta) const
{
return checkClkUncertainty(sourceClkEdge(sta), targetClkEdge(sta),
targetClkPath(), checkRole(sta), sta);
}
Crpr
PathEndClkConstrained::commonClkPessimism(const StaState *sta) const
{
if (!crpr_valid_) {
CheckCrpr *check_crpr = sta->search()->checkCrpr();
crpr_ = check_crpr->checkCrpr(path_.path(), targetClkPath());
if (checkRole(sta)->genericRole() == TimingRole::hold())
crpr_ = -crpr_;
crpr_valid_ = true;
}
return crpr_;
}
Required
PathEndClkConstrained::requiredTime(const StaState *sta) const
{
return requiredTimeNoCrpr(sta)
+ commonClkPessimism(sta);
}
Required
PathEndClkConstrained::requiredTimeNoCrpr(const StaState *sta) const
{
Arrival tgt_clk_arrival = targetClkArrivalNoCrpr(sta);
ArcDelay check_margin = margin(sta);
if (checkGenericRole(sta) == TimingRole::setup())
return tgt_clk_arrival - check_margin;
else
return tgt_clk_arrival + check_margin;
}
Slack
PathEndClkConstrained::slack(const StaState *sta) const
{
Arrival arrival = dataArrivalTime(sta);
Required required = requiredTime(sta);
if (checkGenericRole(sta) == TimingRole::setup())
return required - arrival;
else
return arrival - required;
}
int
PathEndClkConstrained::exceptPathCmp(const PathEnd *path_end,
const StaState *sta) const
{
int cmp = PathEnd::exceptPathCmp(path_end, sta);
if (cmp == 0) {
const PathEndClkConstrained *path_end2 =
dynamic_cast<const PathEndClkConstrained*>(path_end);
const PathVertex *clk_path2 = path_end2->targetClkPath();
return Path::cmp(targetClkPath(), clk_path2, sta);
}
else
return cmp;
}
////////////////////////////////////////////////////////////////
PathEndClkConstrainedMcp::PathEndClkConstrainedMcp(Path *path,
PathVertex *clk_path,
MultiCyclePath *mcp) :
PathEndClkConstrained(path, clk_path),
mcp_(mcp)
{
}
PathEndClkConstrainedMcp::PathEndClkConstrainedMcp(Path *path,
PathVertex *clk_path,
MultiCyclePath *mcp,
Crpr crpr,
bool crpr_valid) :
PathEndClkConstrained(path, clk_path, crpr, crpr_valid),
mcp_(mcp)
{
}
float
PathEndClkConstrainedMcp::targetClkMcpAdjustment(const StaState *sta) const
{
return checkMcpAdjustment(path_.path(), targetClkEdge(sta), sta);
}
float
PathEndClkConstrainedMcp::checkMcpAdjustment(const Path *path,
const ClockEdge *tgt_clk_edge,
const StaState *sta) const
{
if (mcp_) {
const TimingRole *check_role = checkRole(sta);
const MinMax *min_max = check_role->pathMinMax();
const ClockEdge *src_clk_edge = path->clkEdge(sta);
Sdc *sdc = sta->sdc();
if (min_max == MinMax::max())
return PathEnd::checkSetupMcpAdjustment(src_clk_edge, tgt_clk_edge,
mcp_, setupDefaultCycles(), sdc);
else {
// Hold check.
// Default arrival clock is a proxy for the target clock.
if (src_clk_edge == nullptr)
src_clk_edge = tgt_clk_edge;
else if (src_clk_edge->clock() == sdc->defaultArrivalClock())
src_clk_edge = tgt_clk_edge->clock()->edge(src_clk_edge->transition());
const MultiCyclePath *setup_mcp;
const MultiCyclePath *hold_mcp;
// Hold checks also need the setup mcp for cycle accounting.
findHoldMcps(tgt_clk_edge, setup_mcp, hold_mcp, sta);
if (setup_mcp && hold_mcp) {
int setup_mult = setup_mcp->pathMultiplier(MinMax::max());
int hold_mult = hold_mcp->pathMultiplier(MinMax::min());
const ClockEdge *setup_clk_edge =
setup_mcp->useEndClk() ? tgt_clk_edge : src_clk_edge;
float setup_period = setup_clk_edge->clock()->period();
const ClockEdge *hold_clk_edge =
hold_mcp->useEndClk() ? tgt_clk_edge : src_clk_edge;
float hold_period = hold_clk_edge->clock()->period();
return (setup_mult - 1) * setup_period - hold_mult * hold_period;
}
else if (hold_mcp) {
int mult = hold_mcp->pathMultiplier(min_max);
const ClockEdge *clk_edge =
hold_mcp->useEndClk() ? tgt_clk_edge : src_clk_edge;
float period = clk_edge->clock()->period();
return -mult * period;
}
else if (setup_mcp) {
int mult = setup_mcp->pathMultiplier(min_max);
const ClockEdge *clk_edge =
setup_mcp->useEndClk() ? tgt_clk_edge : src_clk_edge;
float period = clk_edge->clock()->period();
return (mult - 1) * period;
}
else
return 0.0;
}
}
else
return 0.0;
}
float
PathEnd::checkSetupMcpAdjustment(const ClockEdge *src_clk_edge,
const ClockEdge *tgt_clk_edge,
const MultiCyclePath *mcp,
int default_cycles,
Sdc *sdc)
{
if (mcp) {
// Default arrival clock is a proxy for the target clock.
if (src_clk_edge == nullptr)
src_clk_edge = tgt_clk_edge;
else if (src_clk_edge->clock() == sdc->defaultArrivalClock())
src_clk_edge = tgt_clk_edge->clock()->edge(src_clk_edge->transition());
if (mcp->minMax()->matches(MinMax::max())) {
int mult = mcp->pathMultiplier(MinMax::max());
const ClockEdge *clk_edge =
mcp->useEndClk() ? tgt_clk_edge : src_clk_edge;
float period = clk_edge->clock()->period();
return (mult - default_cycles) * period;
}
else
return 0.0;
}
else
return 0.0;
}
Slack
PathEndClkConstrained::slackNoCrpr(const StaState *sta) const
{
Arrival arrival = dataArrivalTime(sta);
Required required = requiredTimeNoCrpr(sta);
if (checkGenericRole(sta) == TimingRole::setup())
return required - arrival;
else
return arrival - required;
}
void
PathEndClkConstrainedMcp::findHoldMcps(const ClockEdge *tgt_clk_edge,
const MultiCyclePath *&setup_mcp,
const MultiCyclePath *&hold_mcp,
const StaState *sta) const
{
Pin *pin = path_.pin(sta);
const RiseFall *rf = path_.transition(sta);
// Mcp may be setup, hold or setup_hold, since all match min paths.
const MinMaxAll *mcp_min_max = mcp_->minMax();
Search *search = sta->search();
if (mcp_min_max->matches(MinMax::min())) {
hold_mcp = mcp_;
setup_mcp =
dynamic_cast<MultiCyclePath*>(search->exceptionTo(ExceptionPathType::multi_cycle,
path_.path(), pin, rf,
tgt_clk_edge,
MinMax::max(), true,
false));
}
else {
setup_mcp = mcp_;
hold_mcp =
dynamic_cast<MultiCyclePath*>(search->exceptionTo(ExceptionPathType::multi_cycle,
path_.path(), pin, rf,
tgt_clk_edge,
MinMax::min(), true,
false));
}
}
int
PathEndClkConstrainedMcp::exceptPathCmp(const PathEnd *path_end,
const StaState *sta) const
{
int cmp = PathEndClkConstrained::exceptPathCmp(path_end, sta);
if (cmp == 0) {
const PathEndClkConstrainedMcp *path_end2 =
dynamic_cast<const PathEndClkConstrainedMcp*>(path_end);
const MultiCyclePath *mcp2 = path_end2->mcp_;
if (mcp_ == mcp2)
return 0;
else if (mcp_ < mcp2)
return -1;
else
return 1;
}
else
return cmp;
}
////////////////////////////////////////////////////////////////
PathEndCheck::PathEndCheck(Path *path,
TimingArc *check_arc,
Edge *check_edge,
PathVertex *clk_path,
MultiCyclePath *mcp,
const StaState *) :
PathEndClkConstrainedMcp(path, clk_path, mcp),
check_arc_(check_arc),
check_edge_(check_edge)
{
}
PathEndCheck::PathEndCheck(Path *path,
TimingArc *check_arc,
Edge *check_edge,
PathVertex *clk_path,
MultiCyclePath *mcp,
Crpr crpr,
bool crpr_valid) :
PathEndClkConstrainedMcp(path, clk_path, mcp, crpr, crpr_valid),
check_arc_(check_arc),
check_edge_(check_edge)
{
}
PathEnd *
PathEndCheck::copy()
{
return new PathEndCheck(path_.path(), check_arc_, check_edge_,
&clk_path_, mcp_, crpr_, crpr_valid_);
}
PathEnd::Type
PathEndCheck::type() const
{