forked from nickson-jose/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiberty.cc
2875 lines (2547 loc) · 64.7 KB
/
Liberty.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) 2020, 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 "Liberty.hh"
#include "DisallowCopyAssign.hh"
#include "EnumNameMap.hh"
#include "Report.hh"
#include "Debug.hh"
#include "Error.hh"
#include "StringUtil.hh"
#include "StringSet.hh"
#include "PatternMatch.hh"
#include "Units.hh"
#include "Transition.hh"
#include "TimingRole.hh"
#include "FuncExpr.hh"
#include "TableModel.hh"
#include "TimingArc.hh"
#include "InternalPower.hh"
#include "LeakagePower.hh"
#include "Sequential.hh"
#include "Wireload.hh"
#include "EquivCells.hh"
#include "Network.hh"
#include "PortDirection.hh"
namespace sta {
typedef Set<TimingModel*> TimingModelSet;
typedef Set<FuncExpr*> FuncExprSet;
typedef Set<LatchEnable*> LatchEnableSet;
bool LibertyLibrary::found_rise_fall_caps_ = false;
void
initLiberty()
{
TimingArcSet::init();
}
void
deleteLiberty()
{
TimingArcSet::destroy();
}
LibertyLibrary::LibertyLibrary(const char *name,
const char *filename) :
ConcreteLibrary(name, filename, true),
units_(new Units()),
delay_model_type_(DelayModelType::cmos_linear), // default
nominal_process_(0.0),
nominal_voltage_(0.0),
nominal_temperature_(0.0),
scale_factors_(nullptr),
default_input_pin_cap_(0.0),
default_output_pin_cap_(0.0),
default_bidirect_pin_cap_(0.0),
default_fanout_load_(0.0),
default_fanout_load_exists_(false),
default_max_cap_(0.0),
default_max_cap_exists_(false),
default_max_fanout_(0.0),
default_max_fanout_exists_(false),
default_max_slew_(0.0),
default_max_slew_exists_(false),
slew_derate_from_library_(1.0),
default_wire_load_(nullptr),
default_wire_load_mode_(WireloadMode::unknown),
default_wire_load_selection_(nullptr),
default_operating_conditions_(nullptr),
ocv_arc_depth_(0.0),
default_ocv_derate_(nullptr),
buffers_(nullptr)
{
// Scalar templates are builtin.
for (int i = 0; i != int(TableTemplateType::count); i++) {
TableTemplateType type = static_cast<TableTemplateType>(i);
TableTemplate *scalar_template = new TableTemplate("scalar", nullptr,
nullptr, nullptr);
addTableTemplate(scalar_template, type);
}
for (auto tr_index : RiseFall::rangeIndex()) {
wire_slew_degradation_tbls_[tr_index] = nullptr;
input_threshold_[tr_index] = input_threshold_default_;
output_threshold_[tr_index] = output_threshold_default_;
slew_lower_threshold_[tr_index] = slew_lower_threshold_default_;
slew_upper_threshold_[tr_index] = slew_upper_threshold_default_;
}
}
LibertyLibrary::~LibertyLibrary()
{
bus_dcls_.deleteContents();
for (int i = 0; i < int(TableTemplateType::count); i++)
template_maps_[i].deleteContents();
scale_factors_map_.deleteContents();
delete scale_factors_;
for (auto tr_index : RiseFall::rangeIndex()) {
TableModel *model = wire_slew_degradation_tbls_[tr_index];
delete model;
}
operating_conditions_.deleteContents();
wireloads_.deleteContents();
wire_load_selections_.deleteContents();
delete units_;
ocv_derate_map_.deleteContents();
for (auto name_volt : supply_voltage_map_) {
const char *supply_name = name_volt.first;
stringDelete(supply_name);
}
delete buffers_;
}
LibertyCell *
LibertyLibrary::findLibertyCell(const char *name) const
{
return static_cast<LibertyCell*>(findCell(name));
}
void
LibertyLibrary::findLibertyCellsMatching(PatternMatch *pattern,
LibertyCellSeq *cells)
{
LibertyCellIterator cell_iter(this);
while (cell_iter.hasNext()) {
LibertyCell *cell = cell_iter.next();
if (pattern->match(cell->name()))
cells->push_back(cell);
}
}
LibertyCellSeq *
LibertyLibrary::buffers()
{
if (buffers_ == nullptr) {
buffers_ = new LibertyCellSeq;
LibertyCellIterator cell_iter(this);
while (cell_iter.hasNext()) {
LibertyCell *cell = cell_iter.next();
if (!cell->dontUse()
&& cell->isBuffer())
buffers_->push_back(cell);
}
}
return buffers_;
}
void
LibertyLibrary::setDelayModelType(DelayModelType type)
{
delay_model_type_ = type;
}
void
LibertyLibrary::addBusDcl(BusDcl *bus_dcl)
{
bus_dcls_[bus_dcl->name()] = bus_dcl;
}
BusDcl *
LibertyLibrary::findBusDcl(const char *name) const
{
return bus_dcls_.findKey(name);
}
void
LibertyLibrary::addTableTemplate(TableTemplate *tbl_template,
TableTemplateType type)
{
template_maps_[int(type)][tbl_template->name()] = tbl_template;
}
TableTemplate *
LibertyLibrary::findTableTemplate(const char *name,
TableTemplateType type)
{
return template_maps_[int(type)][name];
}
void
LibertyLibrary::setNominalProcess(float process)
{
nominal_process_ = process;
}
void
LibertyLibrary::setNominalVoltage(float voltage)
{
nominal_voltage_ = voltage;
}
void
LibertyLibrary::setNominalTemperature(float temperature)
{
nominal_temperature_ = temperature;
}
void
LibertyLibrary::setScaleFactors(ScaleFactors *scales)
{
scale_factors_ = scales;
}
void
LibertyLibrary::addScaleFactors(ScaleFactors *scales)
{
scale_factors_map_[scales->name()] = scales;
}
ScaleFactors *
LibertyLibrary::findScaleFactors(const char *name)
{
return scale_factors_map_[name];
}
float
LibertyLibrary::scaleFactor(ScaleFactorType type,
const Pvt *pvt) const
{
return scaleFactor(type, 0, nullptr, pvt);
}
float
LibertyLibrary::scaleFactor(ScaleFactorType type,
const LibertyCell *cell,
const Pvt *pvt) const
{
return scaleFactor(type, 0, cell, pvt);
}
float
LibertyLibrary::scaleFactor(ScaleFactorType type,
int tr_index,
const LibertyCell *cell,
const Pvt *pvt) const
{
if (pvt == nullptr)
pvt = default_operating_conditions_;
// If there is no operating condition, nominal pvt values are used.
// All scale factors are unity for nominal pvt.
if (pvt) {
ScaleFactors *scale_factors = nullptr;
// Cell level scale factors have precidence over library scale factors.
if (cell)
scale_factors = cell->scaleFactors();
if (scale_factors == nullptr)
scale_factors = scale_factors_;
if (scale_factors) {
float process_scale = 1.0F + (pvt->process() - nominal_process_)
* scale_factors->scale(type, ScaleFactorPvt::process, tr_index);
float temp_scale = 1.0F + (pvt->temperature() - nominal_temperature_)
* scale_factors->scale(type, ScaleFactorPvt::temp, tr_index);
float volt_scale = 1.0F + (pvt->voltage() - nominal_voltage_)
* scale_factors->scale(type, ScaleFactorPvt::volt, tr_index);
float scale = process_scale * temp_scale * volt_scale;
return scale;
}
}
return 1.0F;
}
void
LibertyLibrary::setWireSlewDegradationTable(TableModel *model,
RiseFall *rf)
{
int tr_index = rf->index();
if (wire_slew_degradation_tbls_[tr_index])
delete wire_slew_degradation_tbls_[tr_index];
wire_slew_degradation_tbls_[tr_index] = model;
}
TableModel *
LibertyLibrary::wireSlewDegradationTable(const RiseFall *rf) const
{
return wire_slew_degradation_tbls_[rf->index()];
}
float
LibertyLibrary::degradeWireSlew(const LibertyCell *cell,
const RiseFall *rf,
const Pvt *pvt,
float in_slew,
float wire_delay) const
{
const TableModel *model = wireSlewDegradationTable(rf);
if (model)
return degradeWireSlew(cell, pvt, model, in_slew, wire_delay);
else
return in_slew;
}
float
LibertyLibrary::degradeWireSlew(const LibertyCell *cell,
const Pvt *pvt,
const TableModel *model,
float in_slew,
float wire_delay) const
{
switch (model->order()) {
case 0:
return model->findValue(this, cell, pvt, 0.0, 0.0, 0.0);
case 1: {
TableAxis *axis1 = model->axis1();
TableAxisVariable var1 = axis1->variable();
if (var1 == TableAxisVariable::output_pin_transition)
return model->findValue(this, cell, pvt, in_slew, 0.0, 0.0);
else if (var1 == TableAxisVariable::connect_delay)
return model->findValue(this, cell, pvt, wire_delay, 0.0, 0.0);
else {
internalError("unsupported slew degradation table axes");
return 0.0;
}
}
case 2: {
TableAxis *axis1 = model->axis1();
TableAxis *axis2 = model->axis2();
TableAxisVariable var1 = axis1->variable();
TableAxisVariable var2 = axis2->variable();
if (var1 == TableAxisVariable::output_pin_transition
&& var2 == TableAxisVariable::connect_delay)
return model->findValue(this, cell, pvt, in_slew, wire_delay, 0.0);
else if (var1 == TableAxisVariable::connect_delay
&& var2 == TableAxisVariable::output_pin_transition)
return model->findValue(this, cell, pvt, wire_delay, in_slew, 0.0);
else {
internalError("unsupported slew degradation table axes");
return 0.0;
}
}
default:
internalError("unsupported slew degradation table order");
return 0.0;
}
}
// Check for supported axis variables.
// Return true if axes are supported.
bool
LibertyLibrary::checkSlewDegradationAxes(Table *table)
{
switch (table->order()) {
case 0:
return true;
case 1: {
TableAxis *axis1 = table->axis1();
TableAxisVariable var1 = axis1->variable();
return var1 == TableAxisVariable::output_pin_transition
|| var1 == TableAxisVariable::connect_delay;
}
case 2: {
TableAxis *axis1 = table->axis1();
TableAxis *axis2 = table->axis2();
TableAxisVariable var1 = axis1->variable();
TableAxisVariable var2 = axis2->variable();
return (var1 == TableAxisVariable::output_pin_transition
&& var2 == TableAxisVariable::connect_delay)
|| (var1 == TableAxisVariable::connect_delay
&& var2 == TableAxisVariable::output_pin_transition);
}
default:
internalError("unsupported slew degradation table axes");
return 0.0;
}
}
void
LibertyLibrary::defaultMaxFanout(float &fanout,
bool &exists) const
{
fanout = default_max_fanout_;
exists = default_max_fanout_exists_;
}
void
LibertyLibrary::setDefaultMaxFanout(float fanout)
{
default_max_fanout_ = fanout;
default_max_fanout_exists_ = true;
}
void
LibertyLibrary::defaultMaxSlew(float &slew,
bool &exists) const
{
slew = default_max_slew_;
exists = default_max_slew_exists_;
}
void
LibertyLibrary::setDefaultMaxSlew(float slew)
{
default_max_slew_ = slew;
default_max_slew_exists_ = true;
}
void
LibertyLibrary::defaultMaxCapacitance(float &cap,
bool &exists) const
{
cap = default_max_cap_;
exists = default_max_cap_exists_;
}
void
LibertyLibrary::setDefaultMaxCapacitance(float cap)
{
default_max_cap_ = cap;
default_max_cap_exists_ = true;
}
void
LibertyLibrary::defaultFanoutLoad(// Return values.
float &fanout,
bool &exists) const
{
fanout = default_fanout_load_;
exists = default_fanout_load_exists_;
}
void
LibertyLibrary::setDefaultFanoutLoad(float load)
{
default_fanout_load_ = load;
default_fanout_load_exists_ = true;
}
void
LibertyLibrary::setDefaultBidirectPinCap(float cap)
{
default_bidirect_pin_cap_ = cap;
}
void
LibertyLibrary::setDefaultInputPinCap(float cap)
{
default_input_pin_cap_ = cap;
}
void
LibertyLibrary::setDefaultOutputPinCap(float cap)
{
default_output_pin_cap_ = cap;
}
void
LibertyLibrary::defaultIntrinsic(const RiseFall *rf,
// Return values.
float &intrinsic,
bool &exists) const
{
default_intrinsic_.value(rf, intrinsic, exists);
}
void
LibertyLibrary::setDefaultIntrinsic(const RiseFall *rf,
float value)
{
default_intrinsic_.setValue(rf, value);
}
void
LibertyLibrary::defaultPinResistance(const RiseFall *rf,
const PortDirection *dir,
// Return values.
float &res,
bool &exists) const
{
if (dir->isAnyTristate())
defaultBidirectPinRes(rf, res, exists);
else
defaultOutputPinRes(rf, res, exists);
}
void
LibertyLibrary::defaultBidirectPinRes(const RiseFall *rf,
// Return values.
float &res,
bool &exists) const
{
return default_inout_pin_res_.value(rf, res, exists);
}
void
LibertyLibrary::setDefaultBidirectPinRes(const RiseFall *rf,
float value)
{
default_inout_pin_res_.setValue(rf, value);
}
void
LibertyLibrary::defaultOutputPinRes(const RiseFall *rf,
// Return values.
float &res,
bool &exists) const
{
default_output_pin_res_.value(rf, res, exists);
}
void
LibertyLibrary::setDefaultOutputPinRes(const RiseFall *rf,
float value)
{
default_output_pin_res_.setValue(rf, value);
}
void
LibertyLibrary::addWireload(Wireload *wireload)
{
wireloads_[wireload->name()] = wireload;
}
Wireload *
LibertyLibrary::findWireload(const char *name) const
{
return wireloads_.findKey(name);
}
void
LibertyLibrary::setDefaultWireload(Wireload *wireload)
{
default_wire_load_ = wireload;
}
Wireload *
LibertyLibrary::defaultWireload() const
{
return default_wire_load_;
}
void
LibertyLibrary::addWireloadSelection(WireloadSelection *selection)
{
wire_load_selections_[selection->name()] = selection;
}
WireloadSelection *
LibertyLibrary::findWireloadSelection(const char *name) const
{
return wire_load_selections_.findKey(name);
}
WireloadSelection *
LibertyLibrary::defaultWireloadSelection() const
{
return default_wire_load_selection_;
}
void
LibertyLibrary::setDefaultWireloadSelection(WireloadSelection *selection)
{
default_wire_load_selection_ = selection;
}
WireloadMode
LibertyLibrary::defaultWireloadMode() const
{
return default_wire_load_mode_;
}
void
LibertyLibrary::setDefaultWireloadMode(WireloadMode mode)
{
default_wire_load_mode_ = mode;
}
void
LibertyLibrary::addOperatingConditions(OperatingConditions *op_cond)
{
operating_conditions_[op_cond->name()] = op_cond;
}
OperatingConditions *
LibertyLibrary::findOperatingConditions(const char *name)
{
return operating_conditions_.findKey(name);
}
OperatingConditions *
LibertyLibrary::defaultOperatingConditions() const
{
return default_operating_conditions_;
}
void
LibertyLibrary::setDefaultOperatingConditions(OperatingConditions *op_cond)
{
default_operating_conditions_ = op_cond;
}
float
LibertyLibrary::inputThreshold(const RiseFall *rf) const
{
return input_threshold_[rf->index()];
}
void
LibertyLibrary::setInputThreshold(const RiseFall *rf,
float th)
{
input_threshold_[rf->index()] = th;
}
float
LibertyLibrary::outputThreshold(const RiseFall *rf) const
{
return output_threshold_[rf->index()];
}
void
LibertyLibrary::setOutputThreshold(const RiseFall *rf,
float th)
{
output_threshold_[rf->index()] = th;
}
float
LibertyLibrary::slewLowerThreshold(const RiseFall *rf) const
{
return slew_lower_threshold_[rf->index()];
}
void
LibertyLibrary::setSlewLowerThreshold(const RiseFall *rf,
float th)
{
slew_lower_threshold_[rf->index()] = th;
}
float
LibertyLibrary::slewUpperThreshold(const RiseFall *rf) const
{
return slew_upper_threshold_[rf->index()];
}
void
LibertyLibrary::setSlewUpperThreshold(const RiseFall *rf,
float th)
{
slew_upper_threshold_[rf->index()] = th;
}
float
LibertyLibrary::slewDerateFromLibrary() const
{
return slew_derate_from_library_;
}
void
LibertyLibrary::setSlewDerateFromLibrary(float derate)
{
slew_derate_from_library_ = derate;
}
LibertyCell *
LibertyLibrary::makeScaledCell(const char *name,
const char *filename)
{
LibertyCell *cell = new LibertyCell(this, name, filename);
return cell;
}
////////////////////////////////////////////////////////////////
void
LibertyLibrary::makeCornerMap(LibertyLibrary *lib,
int ap_index,
Network *network,
Report *report)
{
LibertyCellIterator cell_iter(lib);
while (cell_iter.hasNext()) {
LibertyCell *cell = cell_iter.next();
const char *name = cell->name();
LibertyCell *link_cell = network->findLibertyCell(name);
if (link_cell)
makeCornerMap(link_cell, cell, ap_index, report);
}
}
// Map a cell linked in the network to the corresponding liberty cell
// to use for delay calculation at a corner.
void
LibertyLibrary::makeCornerMap(LibertyCell *link_cell,
LibertyCell *corner_cell,
int ap_index,
Report *report)
{
link_cell->setCornerCell(corner_cell, ap_index);
makeCornerMap(link_cell, corner_cell, true, ap_index, report);
// Check for brain damage in the other direction.
makeCornerMap(corner_cell, link_cell, false, ap_index, report);
}
void
LibertyLibrary::makeCornerMap(LibertyCell *cell1,
LibertyCell *cell2,
bool link,
int ap_index,
Report *report)
{
LibertyCellPortBitIterator port_iter1(cell1);
while (port_iter1.hasNext()) {
LibertyPort *port1 = port_iter1.next();
const char *port_name = port1->name();
LibertyPort *port2 = cell2->findLibertyPort(port_name);
if (port2) {
if (link)
port1->setCornerPort(port2, ap_index);
}
else
report->warn("cell %s/%s port %s not found in cell %s/%s.\n",
cell1->library()->name(),
cell1->name(),
port_name,
cell2->library()->name(),
cell2->name());
}
for (auto arc_set1 : cell1->timing_arc_sets_) {
auto arc_set2 = cell2->findTimingArcSet(arc_set1);
if (arc_set2) {
if (link) {
TimingArcSetArcIterator arc_iter1(arc_set1);
TimingArcSetArcIterator arc_iter2(arc_set2);
while (arc_iter1.hasNext() && arc_iter2.hasNext()) {
TimingArc *arc1 = arc_iter1.next();
TimingArc *arc2 = arc_iter2.next();
if (TimingArc::equiv(arc1, arc2))
arc1->setCornerArc(arc2, ap_index);
}
}
}
else
report->warn("cell %s/%s %s -> %s timing group %s not found in cell %s/%s.\n",
cell1->library()->name(),
cell1->name(),
arc_set1->from()->name(),
arc_set1->to()->name(),
arc_set1->role()->asString(),
cell2->library()->name(),
cell2->name());
}
}
////////////////////////////////////////////////////////////////
float
LibertyLibrary::ocvArcDepth() const
{
return ocv_arc_depth_;
}
void
LibertyLibrary::setOcvArcDepth(float depth)
{
ocv_arc_depth_ = depth;
}
OcvDerate *
LibertyLibrary::defaultOcvDerate() const
{
return default_ocv_derate_;
}
void
LibertyLibrary::setDefaultOcvDerate(OcvDerate *derate)
{
default_ocv_derate_ = derate;
}
OcvDerate *
LibertyLibrary::findOcvDerate(const char *derate_name)
{
return ocv_derate_map_.findKey(derate_name);
}
void
LibertyLibrary::addOcvDerate(OcvDerate *derate)
{
ocv_derate_map_[derate->name()] = derate;
}
void
LibertyLibrary::addSupplyVoltage(const char *supply_name,
float voltage)
{
supply_voltage_map_[stringCopy(supply_name)] = voltage;
}
void
LibertyLibrary::supplyVoltage(const char *supply_name,
// Return value.
float &voltage,
bool &exists) const
{
supply_voltage_map_.findKey(supply_name, voltage, exists);
}
bool
LibertyLibrary::supplyExists(const char *supply_name) const
{
return supply_voltage_map_.hasKey(supply_name);
}
////////////////////////////////////////////////////////////////
LibertyCellIterator::LibertyCellIterator(const LibertyLibrary *
library):
iter_(library->cell_map_)
{
}
bool
LibertyCellIterator::hasNext()
{
return iter_.hasNext();
}
LibertyCell *
LibertyCellIterator::next()
{
return static_cast<LibertyCell*>(iter_.next());
}
////////////////////////////////////////////////////////////////
LibertyCell::LibertyCell(LibertyLibrary *library,
const char *name,
const char *filename) :
ConcreteCell(library, name, true, filename),
liberty_library_(library),
area_(0.0),
dont_use_(false),
is_macro_(false),
is_memory_(false),
is_pad_(false),
has_internal_ports_(false),
interface_timing_(false),
clock_gate_type_(ClockGateType::none),
has_infered_reg_timing_arcs_(false),
scale_factors_(nullptr),
test_cell_(nullptr),
ocv_arc_depth_(0.0),
ocv_derate_(nullptr),
is_disabled_constraint_(false),
leakage_power_(0.0),
leakage_power_exists_(false)
{
liberty_cell_ = this;
}
LibertyCell::~LibertyCell()
{
mode_defs_.deleteContents();
latch_d_to_q_map_.deleteContents();
deleteTimingArcAttrs();
timing_arc_sets_.deleteContents();
port_timing_arc_set_map_.deleteContents();
timing_arc_set_from_map_.deleteContents();
timing_arc_set_to_map_.deleteContents();
deleteInternalPowerAttrs();
internal_powers_.deleteContents();
leakage_powers_.deleteContents();
sequentials_.deleteContents();
bus_dcls_.deleteContents();
scaled_cells_.deleteContents();
delete test_cell_;
ocv_derate_map_.deleteContents();
pg_port_map_.deleteContents();
}
void
LibertyCell::deleteTimingArcAttrs()
{
for (auto attrs : timing_arc_attrs_) {
attrs->deleteContents();
delete attrs;
}
}
LibertyPort *
LibertyCell::findLibertyPort(const char *name) const
{
return static_cast<LibertyPort*>(findPort(name));
}
void
LibertyCell::findLibertyPortsMatching(PatternMatch *pattern,
LibertyPortSeq *ports) const
{
LibertyCellPortIterator port_iter(this);
while (port_iter.hasNext()) {
LibertyPort *port = port_iter.next();
if (pattern->match(port->name()))
ports->push_back(port);
}
}
void
LibertyCell::addPort(ConcretePort *port)
{
ConcreteCell::addPort(port);
if (port->direction()->isInternal())
has_internal_ports_ = true;
}
void
LibertyCell::setHasInternalPorts(bool has_internal)
{
has_internal_ports_ = has_internal;
}
void
LibertyCell::addPgPort(LibertyPgPort *pg_port)
{
pg_port_map_[pg_port->name()] = pg_port;
}
LibertyPgPort *
LibertyCell::findPgPort(const char *name)
{
return pg_port_map_.findKey(name);
}
ModeDef *
LibertyCell::makeModeDef(const char *name)
{
ModeDef *mode = new ModeDef(name);
mode_defs_[mode->name()] = mode;
return mode;
}
ModeDef *
LibertyCell::findModeDef(const char *name)
{
return mode_defs_.findKey(name);
}
void
LibertyCell::setScaleFactors(ScaleFactors *scale_factors)
{
scale_factors_ = scale_factors;
}
void
LibertyCell::addBusDcl(BusDcl *bus_dcl)
{
bus_dcls_[bus_dcl->name()] = bus_dcl;
}
BusDcl *
LibertyCell::findBusDcl(const char *name) const
{
return bus_dcls_.findKey(name);
}
void
LibertyCell::setArea(float area)
{
area_ = area;
}
void
LibertyCell::setDontUse(bool dont_use)
{
dont_use_ = dont_use;
}
void
LibertyCell::setIsMacro(bool is_macro)
{
is_macro_ = is_macro;
}
void
LibertyCell::setIsMemory(bool is_memory)