forked from ICBench/OpenSTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSta.tcl
1540 lines (1342 loc) · 44.7 KB
/
Sta.tcl
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) 2022, 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/>.
namespace eval sta {
################################################################
#
# Non-SDC commands
#
################################################################
define_cmd_args "delete_clock" {[-all] clocks}
proc delete_clock { args } {
parse_key_args "delete_clock" args keys {} flags {-all}
if { [info exists flags(-all)] } {
check_argc_eq0 "delete_clock" $args
set clks [all_clocks]
} else {
check_argc_eq1 "delete_clock" $args
set clks [get_clocks_warn "clocks" [lindex $args 0]]
}
foreach clk $clks {
remove_clock_cmd $clk
}
}
################################################################
define_cmd_args "delete_generated_clock" {[-all] clocks}
proc delete_generated_clock { args } {
remove_gclk_cmd "delete_generated_clock" $args
}
################################################################
define_cmd_args "set_disable_inferred_clock_gating" { objects }
proc set_disable_inferred_clock_gating { objects } {
set_disable_inferred_clock_gating_cmd $objects
}
proc set_disable_inferred_clock_gating_cmd { objects } {
parse_inst_port_pin_arg $objects insts pins
foreach inst $insts {
disable_clock_gating_check_inst $inst
}
foreach pin $pins {
disable_clock_gating_check_pin $pin
}
}
################################################################
define_cmd_args "unset_case_analysis" {pins}
proc unset_case_analysis { pins } {
set pins1 [get_port_pins_error "pins" $pins]
foreach pin $pins1 {
unset_case_analysis_cmd $pin
}
}
################################################################
define_cmd_args "unset_clock_groups" \
{[-logically_exclusive] [-physically_exclusive]\
[-asynchronous] [-name names] [-all]}
proc unset_clock_groups { args } {
unset_clk_groups_cmd "unset_clock_groups" $args
}
proc unset_clk_groups_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args \
keys {-name} \
flags {-logically_exclusive -physically_exclusive -asynchronous -all}
set all [info exists flags(-all)]
set names {}
if {[info exists keys(-name)]} {
set names $keys(-name)
}
if { $all && $names != {} } {
sta_error 454 "the -all and -name options are mutually exclusive."
}
if { !$all && $names == {} } {
sta_error 455 "either -all or -name options must be specified."
}
set logically_exclusive [info exists flags(-logically_exclusive)]
set physically_exclusive [info exists flags(-physically_exclusive)]
set asynchronous [info exists flags(-asynchronous)]
if { ($logically_exclusive+$physically_exclusive+$asynchronous) == 0 } {
sta_error 456 "one of -logically_exclusive, -physically_exclusive or -asynchronous is required."
}
if { ($logically_exclusive+$physically_exclusive+$asynchronous) > 1 } {
sta_error 457 "the keywords -logically_exclusive, -physically_exclusive and -asynchronous are mutually exclusive."
}
if { $all } {
if { $logically_exclusive } {
unset_clock_groups_logically_exclusive "NULL"
} elseif { $physically_exclusive } {
unset_clock_groups_physically_exclusive "NULL"
} elseif { $asynchronous } {
unset_clock_groups_asynchronous "NULL"
}
} else {
foreach name $names {
if { $logically_exclusive } {
unset_clock_groups_logically_exclusive $name
} elseif { $physically_exclusive } {
unset_clock_groups_physically_exclusive $name
} elseif { $asynchronous } {
unset_clock_groups_asynchronous $name
}
}
}
}
################################################################
define_cmd_args "unset_clock_latency" {[-source] [-clock clock] objects}
proc unset_clock_latency { args } {
unset_clk_latency_cmd "unset_clock_latency" $args
}
proc unset_clk_latency_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args keys {-clock} flags {-source}
check_argc_eq1 $cmd $cmd_args
set objects [lindex $cmd_args 0]
parse_clk_port_pin_arg $objects clks pins
set pin_clk "NULL"
if { [info exists keys(-clock)] } {
set pin_clk [get_clock_warn "clock" $keys(-clock)]
if { $clks != {} } {
sta_warn 303 "-clock ignored for clock objects."
}
}
if {[info exists flags(-source)]} {
# Source latency.
foreach clk $clks {
unset_clock_insertion_cmd $clk "NULL"
}
foreach pin $pins {
# Source only allowed on clocks and clock pins.
if { ![is_clock_pin $pin] } {
sta_error 458 "-source '[$pin path_name]' is not a clock pin."
}
unset_clock_insertion_cmd $pin_clk $pin
}
} else {
# Latency.
foreach clk $clks {
unset_clock_latency_cmd $clk "NULL"
}
foreach pin $pins {
unset_clock_latency_cmd $pin_clk $pin
}
}
}
################################################################
define_cmd_args "unset_clock_transition" {clocks}
proc unset_clock_transition { args } {
check_argc_eq1 "unset_clock_transition" $args
set clks [get_clocks_warn "clocks" [lindex $args 0]]
foreach clk $clks {
unset_clock_slew_cmd $clk
}
}
################################################################
define_cmd_args "unset_clock_uncertainty" \
{[-from|-rise_from|-fall_from from_clock]\
[-to|-rise_to|-fall_to to_clock] [-rise] [-fall]\
[-setup] [-hold] [objects]}
proc unset_clock_uncertainty { args } {
unset_clk_uncertainty_cmd "unset_clock_uncertainty" $args
}
proc unset_clk_uncertainty_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args \
keys {-from -rise_from -fall_from -to -rise_to -fall_to} \
flags {-rise -fall -setup -hold}
set min_max "min_max"
if { [info exists flags(-setup)] && ![info exists flags(-hold)] } {
set min_max "max"
}
if { [info exists flags(-hold)] && ![info exists flags(-setup)] } {
set min_max "min"
}
if { [info exists keys(-from)] } {
set from_key "-from"
set from_rf "rise_fall"
} elseif { [info exists keys(-rise_from)] } {
set from_key "-rise_from"
set from_rf "rise"
} elseif { [info exists keys(-fall_from)] } {
set from_key "-fall_from"
set from_rf "fall"
} else {
set from_key "none"
}
if { [info exists keys(-to)] } {
set to_key "-to"
set to_rf "rise_fall"
} elseif { [info exists keys(-rise_to)] } {
set to_key "-rise_to"
set to_rf "rise"
} elseif { [info exists keys(-fall_to)] } {
set to_key "-fall_to"
set to_rf "fall"
} else {
set to_key "none"
}
if { $from_key != "none" && $to_key == "none" \
|| $from_key == "none" && $to_key != "none" } {
sta_error 459 "-from/-to must be used together."
} elseif { $from_key != "none" && $to_key != "none" } {
# Inter-clock uncertainty.
check_argc_eq0 "unset_clock_uncertainty" $cmd_args
# -from/-to can be lists.
set from_clks [get_clocks_warn "from_clocks" $keys($from_key)]
set to_clks [get_clocks_warn "to_clocks" $keys($to_key)]
foreach from_clk $from_clks {
foreach to_clk $to_clks {
unset_inter_clock_uncertainty $from_clk $from_rf \
$to_clk $to_rf $min_max
}
}
} else {
# Single clock uncertainty.
check_argc_eq1 $cmd $cmd_args
if { [info exists keys(-rise)] \
|| [info exists keys(-fall)] } {
sta_error 460 "-rise, -fall options not allowed for single clock uncertainty."
}
set objects [lindex $cmd_args 0]
parse_clk_port_pin_arg $objects clks pins
foreach clk $clks {
unset_clock_uncertainty_clk $clk $min_max
}
foreach pin $pins {
unset_clock_uncertainty_pin $pin $min_max
}
}
}
################################################################
define_cmd_args "unset_data_check" \
{[-from from_pin] [-rise_from from_pin] [-fall_from from_pin]\
[-to to_pin] [-rise_to to_pin] [-fall_to to_pin]\
[-setup | -hold] [-clock clock]}
proc unset_data_check { args } {
unset_data_checks_cmd "unset_data_check" $args
}
proc unset_data_checks_cmd { cmd cmd_args } {
parse_key_args cmd cmd_args \
keys {-from -rise_from -fall_from -to -rise_to -fall_to -clock} \
flags {-setup -hold}
check_argc_eq0 $cmd $cmd_args
set from_rf "rise_fall"
set to_rf "rise_fall"
set clk "NULL"
set setup_hold "max"
if [info exists keys(-from)] {
set from [get_port_pin_error "from_pin" $keys(-from)]
} elseif [info exists keys(-rise_from)] {
set from [get_port_pin_error "from_pin" $keys(-rise_from)]
set from_rf "rise"
} elseif [info exists keys(-fall_from)] {
set from [get_port_pin_error "from_pin" $keys(-fall_from)]
set from_rf "fall"
} else {
sta_error 461 "missing -from, -rise_from or -fall_from argument."
}
if [info exists keys(-to)] {
set to [get_port_pin_error "to_pin" $keys(-to)]
} elseif [info exists keys(-rise_to)] {
set to [get_port_pin_error "to_pin" $keys(-rise_to)]
set to_rf "rise"
} elseif [info exists keys(-fall_to)] {
set to [get_port_pin_error "to_pin" $keys(-fall_to)]
set to_rf "fall"
} else {
sta_error 462 "missing -to, -rise_to or -fall_to argument."
}
if [info exists keys(-clock)] {
set clk [get_clock_warn "clock" $keys(-clock)]
}
if { [info exists flags(-setup)] && ![info exists flags(-hold)] } {
set setup_hold "setup"
} elseif { [info exists flags(-hold)] && ![info exists flags(-setup)] } {
set setup_hold "hold"
} else {
set setup_hold "setup_hold"
}
unset_data_check_cmd $from $from_rf $to $to_rf $clk $setup_hold
}
################################################################
define_cmd_args "unset_disable_inferred_clock_gating" { objects }
proc unset_disable_inferred_clock_gating { objects } {
unset_disable_inferred_clock_gating_cmd $objects
}
proc unset_disable_inferred_clock_gating_cmd { objects } {
parse_inst_port_pin_arg $objects insts pins
foreach inst $insts {
unset_disable_clock_gating_check_inst $inst
}
foreach pin $pins {
unset_disable_clock_gating_check_pin $pin
}
}
################################################################
define_cmd_args "unset_disable_timing" \
{[-from from_port] [-to to_port] objects}
proc unset_disable_timing { args } {
unset_disable_cmd "unset_disable_timing" $args
}
proc unset_disable_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args keys {-from -to} flags {}
check_argc_eq1 $cmd $cmd_args
set from ""
if { [info exists keys(-from)] } {
set from $keys(-from)
}
set to ""
if { [info exists keys(-to)] } {
set to $keys(-to)
}
parse_libcell_libport_inst_port_pin_edge_timing_arc_set_arg $cmd_args \
libcells libports insts ports pins edges timing_arc_sets
if { ([info exists keys(-from)] || [info exists keys(-to)]) \
&& ($libports != {} || $pins != {} || $ports != {}) } {
sta_warn 304 "-from/-to keywords ignored for lib_pin, port and pin arguments."
}
foreach libcell $libcells {
unset_disable_timing_cell $libcell $from $to
}
foreach libport $libports {
unset_disable_lib_port $libport
}
foreach inst $insts {
unset_disable_timing_instance $inst $from $to
}
foreach pin $pins {
unset_disable_pin $pin
}
foreach port $ports {
unset_disable_port $port
}
foreach edge $edges {
unset_disable_edge $edge
}
foreach timing_arc_set $timing_arc_sets {
unset_disable_timing_arc_set $timing_arc_set
}
}
proc unset_disable_timing_cell { cell from to } {
set from_ports [parse_disable_cell_ports $cell $from]
set to_ports [parse_disable_cell_ports $cell $to]
if { $from_ports == "NULL" && $to_ports == "NULL" } {
unset_disable_cell $cell "NULL" "NULL"
} elseif { $from_ports == "NULL" } {
foreach to_port $to_ports {
unset_disable_cell $cell "NULL" $to_port
}
} elseif { $to_ports == "NULL" } {
foreach from_port $from_ports {
unset_disable_cell $cell $from_port "NULL"
}
} else {
foreach from_port $from_ports {
foreach to_port $to_ports {
unset_disable_cell $cell $from_port $to_port
}
}
}
}
proc unset_disable_timing_instance { inst from to } {
set from_ports [parse_disable_inst_ports $inst $from]
set to_ports [parse_disable_inst_ports $inst $to]
if { ![$inst is_leaf] } {
sta_error 463 "-from/-to hierarchical instance not supported."
}
if { $from_ports == "NULL" && $to_ports == "NULL" } {
unset_disable_instance $inst "NULL" "NULL"
} elseif { $from_ports == "NULL" } {
foreach to_port $to_ports {
unset_disable_instance $inst "NULL" $to_port
}
} elseif { $to_ports == "NULL" } {
foreach from_port $from_ports {
unset_disable_instance $inst $from_port "NULL"
}
} else {
foreach from_port $from_ports {
foreach to_port $to_ports {
unset_disable_instance $inst $from_port $to_port
}
}
}
}
################################################################
define_cmd_args "unset_generated_clock" {[-all] clocks}
proc unset_generated_clock { args } {
unset_gclk_cmd "unset_generated_clock" $args
}
proc remove_gclk_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args keys {} flags {-all}
if { [info exists flags(-all)] } {
check_argc_eq0 $cmd $cmd_args
set clks [all_clocks]
} else {
check_argc_eq1 $cmd $cmd_args
set clks [get_clocks_warn "clocks" [lindex $cmd_args 0]]
}
foreach clk $clks {
if { [$clk is_generated] } {
remove_clock_cmd $clk
}
}
}
################################################################
define_cmd_args "unset_input_delay" \
{[-rise] [-fall] [-max] [-min]\
[-clock clock] [-clock_fall]\
port_pin_list}
proc unset_input_delay { args } {
unset_port_delay "unset_input_delay" "unset_input_delay_cmd" $args
}
################################################################
define_cmd_args "unset_output_delay" \
{[-rise] [-fall] [-max] [-min]\
[-clock clock] [-clock_fall]\
port_pin_list}
proc unset_output_delay { args } {
unset_port_delay "unset_output_delay" "unset_output_delay_cmd" $args
}
proc unset_port_delay { cmd swig_cmd cmd_args } {
parse_key_args $cmd cmd_args \
keys {-clock -reference_pin} \
flags {-rise -fall -max -min -clock_fall }
check_argc_eq1 $cmd $cmd_args
set pins [get_port_pins_error "pins" [lindex $cmd_args 0]]
set clk "NULL"
if [info exists keys(-clock)] {
set clk [get_clock_warn "clock" $keys(-clock)]
}
if [info exists flags(-clock_fall)] {
set clk_rf "fall"
} else {
set clk_rf "rise"
}
set tr [parse_rise_fall_flags flags]
set min_max [parse_min_max_all_flags flags]
foreach pin $pins {
$swig_cmd $pin $tr $clk $clk_rf $min_max
}
}
################################################################
define_cmd_args "unset_path_exceptions" \
{[-setup] [-hold] [-rise] [-fall] [-from from_list]\
[-rise_from from_list] [-fall_from from_list]\
[-through through_list] [-rise_through through_list]\
[-fall_through through_list] [-to to_list] [-rise_to to_list]\
[-fall_to to_list]}
proc unset_path_exceptions { args } {
unset_path_exceptions_cmd "unset_path_exceptions" $args
}
proc unset_path_exceptions_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args \
keys {-from -rise_from -fall_from -to -rise_to -fall_to} \
flags {-setup -hold -rise -fall} 0
set min_max "min_max"
if { [info exists flags(-setup)] && ![info exists flags(-hold)] } {
set min_max "max"
}
if { [info exists flags(-hold)] && ![info exists flags(-setup)] } {
set min_max "min"
}
set arg_error 0
set from [parse_from_arg keys arg_error]
set thrus [parse_thrus_arg cmd_args arg_error]
set to [parse_to_arg keys flags arg_error]
if { $arg_error } {
delete_from_thrus_to $from $thrus $to
sta_error 464 "$cmd command failed."
return 0
}
check_for_key_args $cmd cmd_args
if { $cmd_args != {} } {
delete_from_thrus_to $from $thrus $to
sta_error 465 "positional arguments not supported."
}
if { ($from == "NULL" && $thrus == "" && $to == "NULL") } {
delete_from_thrus_to $from $thrus $to
sta_error 466 "-from, -through or -to required."
}
reset_path_cmd $from $thrus $to $min_max
delete_from_thrus_to $from $thrus $to
}
################################################################
define_cmd_args "unset_propagated_clock" {objects}
proc unset_propagated_clock { objects } {
parse_clk_port_pin_arg $objects clks pins
foreach clk $clks {
unset_propagated_clock_cmd $clk
}
foreach pin $pins {
unset_propagated_clock_pin_cmd $pin
}
}
################################################################
define_cmd_args "unset_timing_derate" {}
proc unset_timing_derate { args } {
check_argc_eq0 "unset_timing_derate" $args
unset_timing_derate_cmd
}
################################################################
#
# Network editing commands
#
################################################################
define_cmd_args "connect_pin" {net pin}
# deprecated 2.0.16 05/02/2019
define_cmd_args "connect_pins" {net pins}
define_cmd_args "delete_instance" {inst}
define_cmd_args "delete_net" {net}
define_cmd_args "disconnect_pin" {net -all|pin}
# deprecated 2.0.16 05/02/2019
define_cmd_args "disconnect_pins" {net -all|pins}
define_cmd_args "make_instance" {inst_path lib_cell}
define_cmd_args "make_net" {}
define_cmd_args "replace_cell" {instance lib_cell}
define_cmd_args "insert_buffer" {buffer_name buffer_cell net load_pins\
buffer_out_net_name}
################################################################
#
# Delay calculation commands
#
################################################################
define_cmd_args "set_assigned_delay" \
{-cell|-net [-rise] [-fall] [-corner corner_name] [-min] [-max]\
[-from from_pins] [-to to_pins] delay}
# Change the delay for timing arcs between from_pins and to_pins matching
# on cell (instance) or net.
proc set_assigned_delay { args } {
set_assigned_delay_cmd "set_assigned_delay" $args
}
proc set_assigned_delay_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args keys {-corner -from -to} \
flags {-cell -net -rise -fall -max -min}
check_argc_eq1 $cmd $cmd_args
set corner [parse_corner keys]
set min_max [parse_min_max_all_check_flags flags]
set to_rf [parse_rise_fall_flags flags]
if [info exists keys(-from)] {
set from_pins [get_port_pins_error "from_pins" $keys(-from)]
} else {
sta_error 442 "$cmd missing -from argument."
}
if [info exists keys(-to)] {
set to_pins [get_port_pins_error "to_pins" $keys(-to)]
} else {
sta_error 443 "$cmd missing -to argument."
}
set delay [lindex $cmd_args 0]
if {![string is double $delay]} {
sta_error 444 "$cmd delay is not a float."
}
set delay [time_ui_sta $delay]
if {[info exists flags(-cell)] && [info exists flags(-net)]} {
sta_error 445 "set_annotated_delay -cell and -net options are mutually excluive."
} elseif {[info exists flags(-cell)]} {
if { $from_pins != {} } {
set inst [[lindex $from_pins 0] instance]
foreach pin $from_pins {
if {[$pin instance] != $inst} {
sta_error 446 "$cmd pin [get_full_name $pin] is not attached to instance [get_full_name $inst]."
}
}
foreach pin $to_pins {
if {[$pin instance] != $inst} {
sta_error 447 "$cmd pin [get_full_name $pin] is not attached to instance [get_full_name $inst]"
}
}
}
} elseif {![info exists flags(-net)]} {
sta_error 448 "$cmd -cell or -net required."
}
foreach from_pin $from_pins {
set from_vertices [$from_pin vertices]
set_assigned_delay1 [lindex $from_vertices 0] \
$to_pins $to_rf $corner $min_max $delay
if { [llength $from_vertices] == 2 } {
set_assigned_delay1 [lindex $from_vertices 1] \
$to_pins $to_rf $corner $min_max $delay
}
}
}
proc set_assigned_delay1 { from_vertex to_pins to_rf corner min_max delay } {
foreach to_pin $to_pins {
set to_vertices [$to_pin vertices]
set_assigned_delay2 $from_vertex [lindex $to_vertices 0] \
$to_rf $corner $min_max $delay
if { [llength $to_vertices] == 2 } {
# Bidirect driver.
set_assigned_delay2 $from_vertex [lindex $to_vertices 1] \
$to_rf $corner $min_max $delay
}
}
}
proc set_assigned_delay2 {from_vertex to_vertex to_rf corner min_max delay} {
set edge_iter [$from_vertex out_edge_iterator]
while {[$edge_iter has_next]} {
set edge [$edge_iter next]
if { [$edge to] == $to_vertex \
&& ![timing_role_is_check [$edge role]] } {
foreach arc [$edge timing_arcs] {
if { $to_rf == "rise_fall" \
|| $to_rf eq [$arc to_edge_name] } {
set_arc_delay $edge $arc $corner $min_max $delay
}
}
}
}
$edge_iter finish
}
################################################################
define_cmd_args "set_assigned_check" \
{-setup|-hold|-recovery|-removal [-rise] [-fall]\
[-corner corner_name] [-min] [-max]\
[-from from_pins] [-to to_pins] [-clock rise|fall]\
[-cond sdf_cond] [-worst] check_value}
# -worst is ignored.
proc set_assigned_check { args } {
set_assigned_check_cmd "set_assigned_check" $args
}
# -worst is ignored.
proc set_assigned_check_cmd { cmd cmd_args } {
parse_key_args $cmd cmd_args \
keys {-from -to -corner -clock -cond} \
flags {-setup -hold -recovery -removal -rise -fall -max -min -worst}
check_argc_eq1 $cmd $cmd_args
if { [info exists keys(-from)] } {
set from_pins [get_port_pins_error "from_pins" $keys(-from)]
} else {
sta_error 449 "$cmd missing -from argument."
}
set from_rf "rise_fall"
if { [info exists keys(-clock)] } {
set clk_arg $keys(-clock)
if { $clk_arg eq "rise" \
|| $clk_arg eq "fall" } {
set from_rf $clk_arg
} else {
sta_error 450 "$cmd -clock must be rise or fall."
}
}
if { [info exists keys(-to)] } {
set to_pins [get_port_pins_error "to_pins" $keys(-to)]
} else {
sta_error 451 "$cmd missing -to argument."
}
set to_rf [parse_rise_fall_flags flags]
set corner [parse_corner keys]
set min_max [parse_min_max_all_check_flags flags]
if { [info exists flags(-setup)] } {
set role "setup"
} elseif { [info exists flags(-hold)] } {
set role "hold"
} elseif { [info exists flags(-recovery)] } {
set role "recovery"
} elseif { [info exists flags(-removal)] } {
set role "removal"
} else {
sta_error 452 "$cmd missing -setup|-hold|-recovery|-removal check type.."
}
set cond ""
if { [info exists key(-cond)] } {
set cond $key(-cond)
}
set check_value [lindex $cmd_args 0]
if { ![string is double $check_value] } {
sta_error 453 "$cmd check_value is not a float."
}
set check_value [time_ui_sta $check_value]
foreach from_pin $from_pins {
set from_vertices [$from_pin vertices]
set_assigned_check1 [lindex $from_vertices 0] $from_rf \
$to_pins $to_rf $role $corner $min_max $cond $check_value
if { [llength $from_vertices] == 2 } {
set_assigned_check1 [lindex $from_vertices 1] $from_rf \
$to_pins $to_rf $role $corner $min_max $cond $check_value
}
}
}
proc set_assigned_check1 { from_vertex from_rf to_pins to_rf \
role corner min_max cond check_value } {
foreach to_pin $to_pins {
set to_vertices [$to_pin vertices]
set_assigned_check2 $from_vertex $from_rf [lindex $to_vertices 0] \
$to_rf $role $corner $min_max $cond $check_value
if { [llength $to_vertices] == 2 } {
# Bidirect driver.
set_assigned_check2 $from_vertex $from_rf \
[lindex $to_vertices 1] $to_rf $role $corner $min_max \
$cond $check_value
}
}
}
proc set_assigned_check2 { from_vertex from_rf to_vertex to_rf \
role corner min_max cond check_value } {
set edge_iter [$from_vertex out_edge_iterator]
while {[$edge_iter has_next]} {
set edge [$edge_iter next]
if { [$edge to] == $to_vertex } {
foreach arc [$edge timing_arcs] {
if { ($from_rf eq "rise_fall" \
|| $from_rf eq [$arc from_edge_name]) \
&& ($to_rf eq "rise_fall" \
|| $to_rf eq [$arc to_edge_name]) \
&& [$arc role] eq $role \
&& ($cond eq "" || [$arc sdf_cond] eq $cond) } {
set_arc_delay $edge $arc $corner $min_max $check_value
}
}
}
}
$edge_iter finish
}
################################################################a
define_cmd_args "set_assigned_transition" \
{[-rise] [-fall] [-corner corner_name] [-min] [-max] slew pins}
# Change the slew on a list of ports.
proc set_assigned_transition { args } {
parse_key_args "set_assigned_transition" args keys {-corner} \
flags {-rise -fall -max -min}
set corner [parse_corner keys]
set min_max [parse_min_max_all_check_flags flags]
set tr [parse_rise_fall_flags flags]
check_argc_eq2 "set_assigned_transition" $args
set slew [lindex $args 0]
if {![string is double $slew]} {
sta_error 428 "set_assigned_transition transition is not a float."
}
set slew [time_ui_sta $slew]
set pins [get_port_pins_error "pins" [lindex $args 1]]
foreach pin $pins {
set vertices [$pin vertices]
set vertex [lindex $vertices 0]
set_annotated_slew $vertex $corner $min_max $tr $slew
if { [llength $vertices] == 2 } {
# Bidirect driver.
set vertex [lindex $vertices 1]
set_annotated_slew $vertex $min_max $tr $slew
}
}
}
################################################################a
# compatibility
define_cmd_args "read_parasitics" \
{[-min]\
[-max]\
[-elmore]\
[-path path]\
[-increment]\
[-pin_cap_included]\
[-keep_capacitive_coupling]\
[-coupling_reduction_factor factor]\
[-reduce_to pi_elmore|pi_pole_residue2]\
[-delete_after_reduce]\
[-quiet]\
[-save]\
filename}
################################################################
#
# Utility commands
#
################################################################
define_cmd_args "delete_from_list" {list objs}
proc delete_from_list { list objects } {
delete_objects_from_list_cmd $list $objects
}
proc delete_objects_from_list_cmd { list objects } {
set list0 [lindex $list 0]
set list_is_object [is_object $list0]
set list_type [object_type $list0]
foreach obj $objects {
# If the list is a collection of tcl objects (returned by get_*),
# convert the obj to be removed from a name to an object of the same
# type.
if {$list_is_object && ![is_object $obj]} {
if {$list_type == "Clock"} {
set obj [find_clock $obj]
} elseif {$list_type == "Port"} {
set top_instance [top_instance]
set top_cell [$top_instance cell]
set obj [$top_cell find_port $obj]
} elseif {$list_type == "Pin"} {
set obj [find_pin $obj]
} elseif {$list_type == "Instance"} {
set obj [find_instance $obj]
} elseif {$list_type == "Net"} {
set obj [find_net $obj]
} elseif {$list_type == "LibertyLibrary"} {
set obj [find_liberty $obj]
} elseif {$list_type == "LibertyCell"} {
set obj [find_liberty_cell $obj]
} elseif {$list_type == "LibertyPort"} {
set obj [get_lib_pins $obj]
} else {
sta_error 439 "unsupported object type $list_type."
}
}
set index [lsearch $list $obj]
if { $index != -1 } {
set list [lreplace $list $index $index]
}
}
return $list
}
################################################################
define_cmd_args "get_fanin" \
{-to sink_list [-flat] [-only_cells] [-startpoints_only]\
[-levels level_count] [-pin_levels pin_count]\
[-trace_arcs timing|enabled|all]}
proc get_fanin { args } {
parse_key_args "get_fanin" args \
keys {-to -levels -pin_levels -trace_arcs} \
flags {-flat -only_cells -startpoints_only}
if { [llength $args] != 0 } {
cmd_usage_error "get_fanin"
}
if { ![info exists keys(-to)] } {
cmd_usage_error "get_fanin"
}
parse_port_pin_net_arg $keys(-to) pins nets
foreach net $nets {
lappend pins [net_driver_pins $net]
}
set flat [info exists flags(-flat)]
set only_insts [info exists flags(-only_cells)]
set startpoints_only [info exists flags(-startpoints_only)]
set inst_levels 0
if { [info exists keys(-levels)] } {
set inst_levels $keys(-levels)
}
set pin_levels 0
if { [info exists keys(-pin_levels)] } {
set pin_levels $keys(-pin_levels)
}
set thru_disabled 0
set thru_constants 0
if { [info exists keys(-trace_arcs)] } {
set trace_arcs $keys(-trace_arcs)
if { $trace_arcs == "timing" } {
set thru_disabled 0
set thru_constants 0
} elseif { $trace_arcs == "enabled" } {
set thru_disabled 0
set thru_constants 0
} elseif { $trace_arcs == "all" } {
set thru_disabled 1
set thru_constants 1
} else {
cmd_usage_error "get_fanin"
}
}
if { $only_insts } {
return [find_fanin_insts $pins $flat $startpoints_only \
$inst_levels $pin_levels $thru_disabled $thru_constants]
} else {
return [find_fanin_pins $pins $flat $startpoints_only \