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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031 | ###############################################################################
# Copyright (c) 2009-2024 by Altair Engineering, Inc.
# All rights reserved.
#
# Altair Engineering, Inc. makes this software available as part of the Vision
# tool platform. As long as you are a licensee of the Vision tool platform
# you may make copies of the software and modify it to be used within the
# Vision tool platform, but you must include all of this notice on any copy.
# Redistribution without written permission to any third party, with or
# without modification, is not permitted.
# Altair Engineering, Inc. does not warrant that this software is error free
# or fit for any purpose. Altair Engineering, Inc. disclaims any liability for
# all claims, expenses, losses, damages and costs any user may incur as a
# result of using, copying or modifying the software.
# =============================================================================
# @userware
# Transistor Cone Extraction
# @section
# Miscellaneous Userware Examples
# @description
# Do a special cone extraction on a transistor netlist.
# @files
# cust11/extractCone2.tcl
# @example
# demo/spice/gl85.sp
# @tag
# gui zdb spice
###############################################################################
##
# Path and name of the generated report file.
#
set _static(reportFile) "pathReport.txt"
set _static(errorFile) "pathErrors.txt"
set _static(barrierFile) "barrier.txt"
##
# Hierarchy separator used to match instantiation paths.
#
set _static(hiersep) "."
##
# Number of paths returned by the path extraction.
#
set _static(pathLimit) 1
# -----------------------------------------------------------------------------
# _configure - Clear _config array and update it from the corresponding files.
# -----------------------------------------------------------------------------
#
proc _configure {} {
global _config
array unset _config
set dir [file dirname [info script]]
##
# Fill _config(targetCells) from file "targets.conf".
# Each line in the file contains a triple with
# "target cell name", "Pin at target cell" and "source port".
#
set _config(targetCells) {}
set fname [file join $dir "targets.conf"]
set in [open $fname r]
set size [file size $fname]
set prg 0
zprogress push "Read targets.conf" 0.33
while {($size > 0) && (![eof $in])} {
set line [gets $in]
incr prg [string length $line]
if {[zprogress update "" $prg $size]} {
break
}
set line [string trim $line]
if {($line == "") || [string match "#*" $line]} {
continue
}
if {[llength $line] != 3} {
return -code error "Expect 3 columns in file $fname."
}
set cellName [lindex $line 0]
lappend _config(targetCells) $cellName
set _config($cellName:targetPin) [lindex $line 1]
set _config($cellName:sourcePin) [lindex $line 2]
}
close $in
if {[zprogress pop]} {
return
}
##
# Fill _config(LibCell:$cellName) from file "libcells.conf".
# Each line in the file is a list of the cell names that should be
# treated as a library cells and the primitive Function (symbol).
#
set fname [file join $dir "libcells.conf"]
set in [open $fname r]
set size [file size $fname]
set prg 0
zprogress push "Read libcells.conf" 0.66
while {($size > 0) && (![eof $in])} {
set line [gets $in]
incr prg [string length $line]
if {[zprogress update "" $prg $size]} {
break
}
set line [string trim $line]
if {($line == "") || [string match "#*" $line]} {
continue
}
if {[llength $line] != 2} {
return -code error "Expect 2 columns in libcells.conf file."
}
foreach {cName func} $line {
set _config(LibCell:$cName) $func
}
}
close $in
if {[zprogress pop]} {
return
}
##
# Fill _config(barriers) from file "barriers.conf".
# Each line in the file contains the cell and inst pattern that need to
# match as well as the port name.
#
set _config(barriers) {}
set fname [file join $dir "barriers.conf"]
set in [open $fname r]
set size [file size $fname]
set prg 0
zprogress push "Read barriers.conf" 1.0
while {($size > 0) && (![eof $in])} {
set line [gets $in]
incr prg [string length $line]
if {[zprogress update "" $prg $size]} {
break
}
set line [string trim $line]
if {($line == "") || [string match "#*" $line]} {
continue
}
if {[llength $line] != 3} {
return -code error "Expect 3 columns in barriers.conf file."
}
foreach {cellPattern instPattern portName} $line {
lappend _config(barriers) $cellPattern $instPattern $portName
}
}
close $in
if {[zprogress pop]} {
return
}
}
# -----------------------------------------------------------------------------
# _isLeafCell - Check if the given module is a leaf cell.
# -----------------------------------------------------------------------------
#
proc _isLeafCell {db mod} {
##
# Loop over all instances in the given module and return false if
# a hierarchical instance is found. Otherwise return true.
#
set count [lindex [$db report sizeOf $mod] 1]
set i 0
$db foreach inst $mod inst {
incr i
zprogress update "" $i $count
if {![$db tdevice $inst]} {return false}
}
return true
}
# -----------------------------------------------------------------------------
# _createBarrierReport - create a report file containing all barriers.
# -----------------------------------------------------------------------------
#
proc _createBarrierReport {db} {
global _config _static
zprogress begin
_initialize $db
zprogress push "Create Barriers Report." 0.95
$db foreach cell cell {$db flag $cell set blue}
set blueInstList {}
$db foreach top top {
$db flat foreach instOfCell blue $top inst {lappend blueInstList $inst}
}
set count [llength $blueInstList]
set i 0
set bOut [open $_static(barrierFile) w]
foreach inst $blueInstList {
if {[zprogress update "" $i $count]} {
break
}
incr i
##
# Loop over all 'barriers' triplets and match cell, inst and port.
#
foreach {cellPattern instPattern portName} $_config(barriers) {
##
# Check if the cellPattern matches the cellRef of this inst.
#
if {![string match $cellPattern [$db oid cname $inst]]} {
continue
}
##
# Check if the instPattern matches this inst.
#
set instObject [join [lrange $inst 1 end] $_static(hiersep)]
if {![string match $instPattern $instObject]} {
continue
}
##
# Search for the pin named at this instance.
#
set pin [$db search pin $inst $portName]
if {[$db oid isnull $pin]} {
continue
}
puts -nonewline $bOut "$instObject (of Cell "
puts -nonewline $bOut "[$db oid cname $inst]) (Pattern "
puts -nonewline $bOut "\{Cell:$cellPattern Inst:$instPattern"
puts $bOut " Port:$portName\})"
}
}
close $bOut
if {[zprogress pop]} {
return
}
##
# Clear all database flags used for this userware.
#
zprogress push "Clear Flags" 1.0
_clearUsedFlags $db
zprogress pop
zprogress end
}
# -----------------------------------------------------------------------------
# _flagExcludePins - Exclude pins from the cone search using the black flag.
# -----------------------------------------------------------------------------
#
proc _flagExcludePins {db} {
global _config _static
##
# Lop over all cells and flag all cells with the 'blue' flag.
#
set i 0
set cellList {}
$db foreach cell cell {lappend cellList $cell}
set count [llength $cellList]
zprogress push "" 0.5
foreach cell $cellList {
if {[zprogress update "" $i $count]} {
break
}
incr i
foreach {cellPattern instPattern portName} $_config(barriers) {
set cname [$db oid oname $cell]
if {![string match $cellPattern $cname]} {
continue
}
if {$instPattern != "*"} {
$db flag $cell set blue
continue
}
set port [$db search port $cell $portName]
if {[$db oid isnull $port]} {
continue
}
$db flag $port set green
}
}
if {[zprogress pop]} {
return
}
##
# Build a list of all flat instances of blue flagged cells.
#
set blueInstList {}
$db foreach top top {
$db flat foreach instOfCell blue $top inst {lappend blueInstList $inst}
}
zprogress push "" 1.0
set count [llength $blueInstList]
set i 0
foreach inst $blueInstList {
if {[zprogress update "" $i $count]} {
break
}
incr i
##
# Loop over all 'barriers' triplets and match cell, inst and port.
#
foreach {cellPattern instPattern portName} $_config(barriers) {
##
# Check if the cellPattern matches the cellRef of this inst.
#
if {![string match $cellPattern [$db oid cname $inst]]} {
continue
}
##
# Check if the instPattern matches this inst.
#
set instObject [join [lrange $inst 1 end] $_static(hiersep)]
if {![string match $instPattern $instObject]} {
continue
}
##
# Search for the pin named at this instance.
#
set pin [$db search pin $inst $portName]
if {[$db oid isnull $pin]} {
continue
}
##
# The cell, inst and port name matches the barrier pattern.
#
$db flatflag $pin set black
}
}
if {[zprogress pop]} {
return
}
}
# -----------------------------------------------------------------------------
# _flagLeafCells - Flag all leaf cells.
# -----------------------------------------------------------------------------
#
proc _flagLeafCells {db} {
##
# Loop over all modules and flag cells with no more hierarchical
# content as library cells.
#
set count 0
set i 0
$db foreach module mod {incr count}
$db foreach module mod {
if {[_isLeafCell $db $mod]} {$db flag $mod set libcell}
if {[zprogress update "" $i $count]} {
break
}
incr i
}
##
# From now on the database treats all library cells as primitives.
#
$db setPrimitive -libcell
}
# -----------------------------------------------------------------------------
# _clearUsedFlags - Clear all flags used by this Userware.
# -----------------------------------------------------------------------------
#
proc _clearUsedFlags {db} {
##
# Loop over all cells and remove the flags used by this Userware script.
#
set usedFlags {libcell red green blue}
$db foreach cell cell {
foreach flagName $usedFlags {$db flag $cell clear $flagName}
$db foreach port $cell port {$db flag $cell clear green}
}
##
# Clear all 'black' flat flags below all tops.
#
$db foreach top top {$db flatflag $top clear black}
$db setPrimitive -clear
}
# -----------------------------------------------------------------------------
# _getListOfStartPins - Create a list of pins used as start point for the
# cone search.
# -----------------------------------------------------------------------------
#
proc _getListOfStartPins {db} {
global _config
##
# Lop over all cells and flag all cells listed in _config(targetCells)
# using the 'red' flag.
#
$db foreach cell cell {
if {[$db oid oname $cell] ni $_config(targetCells)} {
continue
}
$db flag $cell set red
}
##
# Build a list of all flat instances of red flagged cells.
#
set pinList {}
$db foreach top top {
$db flat foreach instOfCell red $top inst {
##
# Search for the pin named in _config(*:targetPin) at this instance.
#
set cell [$db oid oname [$db down $inst]]
set pinOid [$db search pin $inst $_config($cell:targetPin)]
if {![$db oid isnull $pinOid]} {lappend pinList $pinOid}
}
}
return $pinList
}
# -----------------------------------------------------------------------------
# _assignSymbols - This procedure assigns the symbol shape for all cells
# listed above.
# -----------------------------------------------------------------------------
#
proc _assignSymbols {db} {
global _config
if {$db == {}} {
return
}
$db foreach cell cell {
set cName [$db oid oname $cell]
if {![info exists _config(LibCell:$cName)]} {
continue
}
set func $_config(LibCell:$cName)
if {$func == {}} {
continue
}
$db attr $cell set @symbol=$func
}
}
# -----------------------------------------------------------------------------
# _undoAssignSymbol - Undo the effect of _assignSymbols (clear the @symlib
# attr).
# -----------------------------------------------------------------------------
#
proc _undoAssignSymbol {db} {
global _config
if {$db == {}} {
return
}
$db foreach cell cell {
set cName [$db oid oname $cell]
if {![info exists _config(LibCell:$cName)]} {
continue
}
$db attr $cell delete @symbol
}
}
# -----------------------------------------------------------------------------
# _flagLibCells - Flag all cells listed above as a library cell.
# -----------------------------------------------------------------------------
#
proc _flagLibCells {db} {
global _config
if {$db == {}} {
return
}
$db foreach cell cell {
set cName [$db oid oname $cell]
if {![info exists _config(LibCell:$cName)]} {
continue
}
$db flag $cell set libcell
}
}
# -----------------------------------------------------------------------------
# _undoFlagLibCell - Undo the effect of _flagLibCells (clear the libcell flag).
# -----------------------------------------------------------------------------
#
proc _undoFlagLibCell {db} {
global _config
if {$db == {}} {
return
}
$db foreach cell cell {
set cName [$db oid oname $cell]
if {![info exists _config(LibCell:$cName)]} {
continue
}
$db flag $cell clear libcell
}
}
# -----------------------------------------------------------------------------
# _togglePrimLevel - This procedure toggles the primitive level of the
# database. If $doit is true then library cells and all
# cells with a symbol are treated as primitives.
# -----------------------------------------------------------------------------
#
proc _togglePrimLevel {db doit} {
if {$db == {}} {
return
}
set args -clear
gui settings set "primLevelOper" $doit
gui settings set "primLevelLibCell" $doit
gui settings set "primLevelSymbol" $doit
gui settings changed
if {[gui settings get "primLevelOper"]} {
lappend args -operator
}
if {[gui settings get "primLevelLibCell"]} {
lappend args -libcell
}
if {[gui settings get "primLevelSymbol"]} {
lappend args -symbol
}
eval $db setPrimitive $args
}
# -----------------------------------------------------------------------------
# _initialize - Initialize the database.
# -----------------------------------------------------------------------------
#
proc _initialize {db} {
##
# Clear all database flags used for this userware.
#
zprogress push "Clear Flags" 0.05
_clearUsedFlags $db
if {[zprogress pop]} {
return
}
_assignSymbols $db ;# Assign all symbols listed in file "libcells.conf"
_flagLibCells $db ;# Flag all cells listed in file "libcells.conf"
_togglePrimLevel $db true ;# change the primitive view of the DB
##
# Flag all leaf cells. This is only needed if the loaded database could
# contain transistor devices (checked by 'zlicense permit spice').
#
if {[zlicense permit spice]} {
zprogress push "Flag Leaf Cells" 0.1
_flagLeafCells $db
if {[zprogress pop]} {
return
}
}
}
# -----------------------------------------------------------------------------
# _doExtract - Start the cone extraction and store the result in _result.
# -----------------------------------------------------------------------------
#
proc _doExtract {db} {
global _static _config _result
if {$db == {}} {
return
}
##
# Start of progress bar.
#
zprogress begin
##
# Update the _config array from the corresponding files.
#
zprogress push "Load Configuration" 0.01
_configure
if {[zprogress pop]} {
return
}
##
# Initialize the database.
#
_initialize $db
##
# Flag all pins that should be excluded from the trace.
#
zprogress push "Flag Exclude Pins" 0.25
_flagExcludePins $db
if {[zprogress pop]} {
return
}
##
# Get a list of all start pins.
#
zprogress push "Get Start Pins" 0.3
set startPins [_getListOfStartPins $db]
if {[zprogress pop]} {
return
}
##
# Loop over all start pins and perform a cone extraction to the
# given source pin. Store the result in _result().
#
zprogress push "Extract Cone" 0.97
array set _result {}
set _result(startPins) $startPins
set _result(errors) {}
set out [open $_static(reportFile) w]
set err [open $_static(errorFile) w]
set _result(all) {}
set n 0
foreach pin $startPins {
set inst [$db oid convertTo inst $pin]
set cell [$db oid oname [$db down $inst]]
set trgt $_config($cell:sourcePin)
puts $out "Path#[incr n]"
set inst [$db oid convertTo inst $pin]
puts $out "[$db oid cname $inst] [$db oid pname $pin] ($inst)"
set lim $_static(pathLimit)
set result [$db cone -in -paths -pathLimit $lim \
-excludeFlaggedPort green \
-excludeFlatFlagged black -targetObj $trgt $pin]
if {[zprogress isinterrupted]} {
break
}
set coneList {}
if {[llength $result] == 0} {
lappend _result(errors) $pin
lappend coneList $pin
puts $err "Path#$n"
puts $err "[$db oid cname $inst] [$db oid pname $pin] ($inst)"
puts $err " {}"
puts $err " $trgt"
puts $out " {}"
}
set i 0
set _result(Path_$n) {}
foreach path $result {
set depth [lindex $path 0]
set path [lrange $path 1 end]
puts $out " Path $n.[incr i] (Depth: $depth)"
set pathOids {}
foreach oid $path {
lappend coneList $oid
lappend pathOids $oid
if {[$db oid type $oid] == "port"} {
continue
}
set inst [$db oid convertTo inst $oid]
if {[$db isModule $inst]} {
continue
}
set cInfo "(of Cell [$db oid cname $inst])"
set pInfo "Pin: [$db oid pname $oid]"
puts $out " [$db oid print $inst] $cInfo $pInfo"
}
lappend _result(Path_$n) $depth $pathOids
}
puts $out " $trgt"
lappend _result(all) [list $pin $coneList]
}
close $out
close $err
if {[zprogress pop]} {
return
}
##
# Clear all database flags used for this userware.
#
zprogress push "Clear Flags" 1.0
_clearUsedFlags $db
if {[zprogress pop]} {
return
}
##
# End of progress bar.
#
zprogress end
##
# Remove _doExtract from 'RegisteredDataBaseChanged' and update the GUI
#
gui database removeChangedCallback "_doExtract"
gui database changed $db
##
# Add a main menu button for displaying the result.
#
gui menu command {"Userware" "Show Extraction Result"} \
[list _show $db]
gui menu command {"Userware" "Show Only Errors"} \
[list _showErrors $db]
gui menu command {"Userware" "Create Barriers Report"} \
[list _createBarrierReport $db]
}
# -----------------------------------------------------------------------------
# _show - Show the result in a new toplevel window.
# -----------------------------------------------------------------------------
#
proc _show {db} {
set f .topUW
destroy $f
##
# Dialog boxes should be transient with respect to their parent.
#
toplevel $f
wm title $f "Path Result"
set partop [winfo toplevel [winfo parent $f]]
if {[winfo ismapped $partop]} {
wm transient $f $partop
}
canvas $f.pinlist -background white -yscrollcommand "$f.ys set"
ttk::scrollbar $f.ys -orient vertical -command "$f.pinlist yview"
grid $f.pinlist -row 0 -column 0 -sticky news
grid $f.ys -row 0 -column 1 -sticky ns
grid rowconfigure $f 0 -weight 1
grid columnconfigure $f 0 -weight 1
set mask "#define mask_width 9\n#define mask_height 9"
append mask {
static unsigned char mask_bits[] = {
0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff,
0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0xff, 0x01
};
}
set data "#define open_width 9\n#define open_height 9"
append data {
static unsigned char open_bits[] = {
0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7d,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x01
};
}
image create bitmap T_Op -data $data -maskdata $mask \
-foreground black -background white
set data "#define close_width 9\n#define close_height 9"
append data {
static unsigned char close_bits[] = {
0xff, 0x01, 0x01, 0x01, 0x11, 0x01, 0x11, 0x01, 0x7d,
0x01, 0x11, 0x01, 0x11, 0x01, 0x01, 0x01, 0xff, 0x01
};
}
image create bitmap T_Cl -data $data -maskdata $mask \
-foreground black -background white
_buildTree $f.pinlist $db
}
# -----------------------------------------------------------------------------
# _buildTree - Build a tree like structure with two levels of hierarchy.
#
# Path#1
# |- SubPath#1
# - Inst 1
# | ...
# | Inst X
# | ...
# |+ SubPath#I
# | ...
# Path#N
# -----------------------------------------------------------------------------
#
proc _buildTree {w db} {
global _result _tree
set b [$w bbox [$w create text 2 0 -text "T" -anchor nw]]
set height [expr {[lindex $b 3] - [lindex $b 1] - 1}]
set x 5
set y 2
set width 0
$w delete all
##
# Loop over all results.
#
set n 0
foreach result $_result(all) {
set pin [lindex $result 0]
set res [lindex $result 1]
set n [incr n]
set selRec [$w create rectangle -100 $y 900 \
[expr {$y + $height}] -tags selrec \
-fill white -outline white]
set col "#00a000"
if {[llength $res] == 1} {
set col "#d00000"
}
set txt "Path #$n from '[$db oid print $pin]': [llength $res] step"
if {[llength $res] > 1} {
append txt "s"
}
set item [$w create text [expr {$x + 12}] $y -text $txt -anchor nw \
-fill $col]
if {[llength $res] > 1} {
if {[info exists _tree(open:$n:0)]} {
set plus [$w create image $x [expr {$y + 2}] -anchor nw \
-image T_Op]
$w bind $plus <Button-1> "_close $w $db $n 0"
##
# Add sub-paths
#
set subX [expr {$x + 25}]
set i 0
foreach {depth subPath} $_result(Path_$n) {
incr y $height
set subSelRec [$w create rectangle -100 $y 900 \
[expr {$y + $height}] -tags selrec \
-fill white -outline white]
set subItem [$w create text $subX $y \
-text "Path $n.[incr i] (Depth: $depth)" \
-anchor nw -fill $col]
$w bind $subSelRec <Button-1> "_select %W $subSelRec"
$w bind $subItem <Button-1> "_select %W $subSelRec"
set dsplCmd "_display $db [list $subPath]"
$w bind $subSelRec <Double-1> $dsplCmd
$w bind $subItem <Double-1> $dsplCmd
set iX [expr {$x + 14}]
if {[info exists _tree(open:$n:$i)]} {
set plus [$w create image $iX [expr {$y + 2}] \
-anchor nw -image T_Op]
$w bind $plus <Button-1> "_close $w $db $n $i"
#checker -scope block exclude warnStyleNesting
foreach oid $subPath {
if {[$db oid type $oid] == "port"} {
continue
}
set inst [$db oid convertTo inst $oid]
incr y $height
set instSelRec [$w create rectangle -100 $y 900 \
[expr {$y + $height}] -tags selrec \
-fill white -outline white]
set cInfo "(of Cell [$db oid cname $inst])"
set pInfo "Pin: [$db oid pname $oid]"
set txt "[$db oid print $inst] $cInfo $pInfo"
set instItem [$w create text $subX $y \
-text $txt -anchor nw -fill $col]
$w bind $instSelRec <Button-1> \
"_select %W $instSelRec"
$w bind $instItem <Button-1> \
"_select %W $instSelRec"
set g "_goto $db [list $subPath] [list $inst]"
$w bind $instSelRec <Double-1> $g
$w bind $instItem <Double-1> $g
}
} else {
set plus [$w create image $iX [expr {$y + 2}] \
-anchor nw -image T_Cl]
$w bind $plus <Button-1> "_open $w $db $n $i"
}
}
} else {
set plus [$w create image $x [expr {$y + 2}] -anchor nw \
-image T_Cl]
$w bind $plus <Button-1> "_open $w $db $n 0"
}
}
$w bind $selRec <Button-1> "_select %W $selRec"
$w bind $item <Button-1> "_select %W $selRec"
$w bind $selRec <Double-1> "_display $db [list $res]"
$w bind $item <Double-1> "_display $db [list $res]"
incr y $height
}
$w config -scrollregion [$w bbox all]
}
# -----------------------------------------------------------------------------
# _select - Remove old selection and apply new selection.
# -----------------------------------------------------------------------------
#
proc _select {w item} {
set selBgBg [option get $w selectBackground Background]
$w itemconfigure selrec -fill white -outline white
$w itemconfigure $item -fill $selBgBg -outline $selBgBg
}
# -----------------------------------------------------------------------------
# _open - Open the tree at the node given with $n and $i.
# -----------------------------------------------------------------------------
#
proc _open {w db n i} {
global _tree
set _tree(open:$n:$i) 1
_buildTree $w $db
}
# -----------------------------------------------------------------------------
# _close - Close the tree at the node given with $n and $i.
# -----------------------------------------------------------------------------
#
proc _close {w db n i} {
global _tree
unset _tree(open:$n:$i)
_buildTree $w $db
}
# -----------------------------------------------------------------------------
# _showErrors - Show only the error result in the Mem window.
# -----------------------------------------------------------------------------
#
proc _showErrors {db} {
global _result
gui mem append $_result(errors)
gui window show Schem
gui window show Cone
}
# -----------------------------------------------------------------------------
# _display - Display the result in the Cone window.
# -----------------------------------------------------------------------------
#
proc _display {db path} {
gui window show Cone
gui cone load $path
update idletasks
gui cone zoom 1.5
gui goto -class Schem [list [lindex $path 0]]
gui tree setCurrentModule [lindex $path 0]
}
# -----------------------------------------------------------------------------
# _goto - Goto an object and load the path (if not visible).
# -----------------------------------------------------------------------------
#
proc _goto {db path inst} {
set contents [gui cone contents]
if {$inst ni $contents} {
_display $db $path
}
gui goto -class Schem [list $inst]
gui tree setCurrentModule $inst
}
# -----------------------------------------------------------------------------
# _runExtraction - Extend the main menu.
# -----------------------------------------------------------------------------
#
proc _runExtraction {} {
_doExtract [gui database get]
}
##
# Add a main menu entry.
#
gui menu command {"Userware" "Run Extraction"} {_runExtraction}
##
# Use gui database runOrRegisterChangedCallback to immediately run
# _doExtract if we have a database, or otherwise register the proc to be
# executed after the database is available.
#
gui database runOrRegisterChangedCallback _doExtract
##
#
#
gui settings set "cone:autohide" 1
gui settings changed
|