-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnet.ps
4970 lines (3586 loc) · 104 KB
/
fnet.ps
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
%!PS
cleardictstack % leaking dicts on debug error crashes
% extract netlist from schematic
% requires ghostscript min and max functions
%project notes
% update schematic parser to use pc version which is later revisionn
% could split off s2n lightweight conversion
% PCB text is centered, chack rotated symbols.
/tfd (NetlistFFex.sch) def
%-------------------------------------------------------------------------
/KiCadDataFolderPfx (KiCad/myFiles/) def % change this to the full path where the
% converted files will be stored. Must be full path from
% top file directory, or files will be stored
% in the conversion source directory. Directory must exist.
/verbose false def % used for debug
/render false def % used for debug
/writefiles true def % writes the net file
/writenets true def % write an expressPCB netlist file.
/enets false def % attempt to create an expressPCB net.
/writeProjectFile false def % attempt to create a full KiCad project
/writeFootprints true def % log the footprints
/staticlib false def % used for lib extraction
/DisplayFont /URWGothicL-Book def
%/DisplayFont /AvanteGarde-Book def
% no user settings past this point
%######################################################################
/=$ {dup length 2 mul dup 60 idiv add 1 add string dup
/ASCIIHexEncode filter 3 -1 roll 3 copy writestring 2
index flushfile pop pop closefile =} bind def
/$ {dup length 2 mul dup 60 idiv add 1 add string dup
/ASCIIHexEncode filter 3 -1 roll 3 copy writestring 2
index flushfile pop pop closefile } bind def
%/dfa {pop} bind def %
/dfa {{ exch =string cvs print (: ) print ==} forall} bind def
/makestring {
%verbose 2 gt {(<) print =$} if
dup length string % new string of right size
dup /NullEncode filter % make a file out of string
2 index % array to stack top
{ 2 copy write pop } % integers to string
forall
flushfile exch pop % clean up
} bind def
/strcat {
dup length 2 index length add string
2 index length 3 -1 roll 3 copy putinterval pop pop
0 3 -1 roll 3 copy putinterval pop pop
} bind def
/Word_l$ <870000> def % low first
/Long_l$ <8500000000> def % low first
/Word$ <860000> def % high first
/Long$ <8400000000> def % high first
% level2 date function
% example Tuesday, 11 February 2014 14:54:19
(%Calendar%) /IODevice resourcestatus {
pop pop (%Calendar%) currentdevparams
dup /Running get { /timedict exch def
[
timedict /Year get 4 string cvs {} forall 45
timedict /Month get 2 string cvs {} forall 45
timedict /Day get 2 string cvs {} forall 32
timedict /Hour get 2 string cvs {} forall 58
timedict /Minute get 100 add 3 string cvs 1 2 getinterval {} forall 58
timedict /Second get 100 add 3 string cvs 1 2 getinterval {} forall
]
makestring dup == /StartTime$ exch def
[
timedict /Day get 2 string cvs {} forall
[( jan ) ( feb ) ( mar ) ( apr ) ( may ) ( jun )
( jul ) ( aug ) ( sep ) ( oct ) ( nov ) ( dec )
]
timedict /Month get 1 sub get {} forall
timedict /Year get 4 string cvs {} forall
]
makestring /SimpleDate exch def
[
[(Sunday, ) (Monday, ) (Tuesday, ) (Wednesday, ) (Thursday, ) (Friday, ) (Saturday, )]
timedict /Weekday get get {} forall
timedict /Day get 2 string cvs {} forall
[( January ) ( February ) ( March ) ( April ) ( May ) ( June )
( July ) ( August ) ( September ) ( October ) ( November ) ( December )
]
timedict /Month get 1 sub get {} forall
timedict /Year get 4 string cvs {} forall 32
timedict /Hour get 2 string cvs {} forall 58
timedict /Minute get 100 add 3 string cvs 1 2 getinterval {} forall 58
timedict /Second get 100 add 3 string cvs 1 2 getinterval {} forall
]
makestring /NetDate$ exch def
}{
(Clock/calendar is present but not running.\n) print
/StartTime$ (0) def
/SimpleDate ( nodate ) def
} ifelse
} {
(No clock/calendar present.\n) print
/StartTime$ (0) def
/SimpleDate ( noclock ) def
} ifelse
/TimeHashes 10 dict def
%quick and dirty proc for making a sort of timestamp
/TimeStamp {
(%Calendar%) currentdevparams begin
10 dict begin % make a local dictionary for constants
/SEC_PER_HOUR 60 60 mul def
/SEC_PER_DAY SEC_PER_HOUR 24 mul def
/SEC_IN_MONTH [0 2678400 5097600 7776000 10368000 13046400 15638400 18316800 20995200 23587200 26265600 28857600] def
Year 1970 sub 365.2425 mul SEC_PER_DAY mul cvi % approximate the number of seconds since 0 time
SEC_IN_MONTH Month 1 sub get cvi add % add in the seconds to the first of the month
Day 1 sub SEC_PER_DAY mul cvi add % seconds to midnight the prior day
Hour SEC_PER_HOUR mul cvi add
Minute 60 mul cvi add
% (->) print pstack (<-) =
Second add
% (->) print pstack (<-) =
cvi dup 16 8 string cvrs exch
end
{
1 index cvn TimeHashes exch 2 copy known
{
%(y->) print pstack (<-) = flush
get 1 add
cvi dup 16 8 string cvrs exch
4 -2 roll pop pop %put
%(y->) print pstack (<-) = flush
}{
%(n->) print pstack (<-) = flush
3 -1 roll put exit
%(n->) print pstack (<-) = flush
}ifelse
} loop
end
} bind def
% functions for decoding the input stream
/keydict 10 dict def
/initIO {
keydict begin
tf read not {end exit} if % read low byte
tf read not {end exit} if % read high byte
8 bitshift or
/key exch def
/Object /keyDictType def
(\nkey: 0x) print key 16 =string cvrs =
end
} bind def
/nextKeyNumber {
keydict begin
/paramInt key def
17 {
/j 0 def
paramInt 16#20 and 0 ne {/j 1 def} if
paramInt 16#08 and 0 ne {/j j 1 add def}if
paramInt 16#04 and 0 ne {/j j 1 add def}if
paramInt 16#01 and 0 ne {/j j 1 add def}if
/paramInt paramInt -1 bitshift def
j 16#1 and 0 ne {/paramInt paramInt 32768 add def}if
} repeat
/key paramInt def
end
} bind def
/read1 {
keydict begin
tf read not {end exit} if % read i
nextKeyNumber
key xor 255 and
end
} bind def
/read2 {
keydict begin
tf read not {end exit} if % read i
tf read not {end exit} if % read j
8 bitshift or % j << 8
nextKeyNumber
key xor 65535 and
end
} bind def
/read3 {
keydict begin
tf read not {end exit} if % read i
tf read not {end exit} if % read j
8 bitshift or % j << 8
tf read not {end exit} if % read k
16 bitshift or % k << 16
/m exch def
nextKeyNumber
/n key 16 bitshift def
nextKeyNumber
/n n key or def
/m m n xor def
/m m 16777215 and def %0xFFFFFF
m 16#800000 and 0 ne {/m m -16777216 or def }if % 0xFF000000
m
end
} bind def
/dsysparm3 {
read3 verbose {dup dup 4 -1 roll print 16 =string cvrs print (h ) print =string cvs print ( ) print
[ exch dup -16 bitshift exch 16#FFFF and dup -8 bitshift exch 16#FF and ] makestring == }{pop pop} ifelse
} bind def
/dsysparm2 {
read2 verbose {dup dup 4 -1 roll print 16 =string cvrs print (h ) print =string cvs print ( ) print
[ exch dup -8 bitshift exch 16#FF and ] makestring == }{pop pop} ifelse
} bind def
/dsysparm1 {
read1 verbose {dup dup 4 -1 roll print 16 =string cvrs print (h ) print =string cvs print ( ) print
[ exch 16#FF and ] makestring == }{pop pop} ifelse
} bind def
% constant lookup tables
/SCHFILE 16#5678 def
/CMPFILE 16#5685 def
/PCBFILE 16#B9C7 def
/FPTFILE 16#7DF8 def
/DIRECTION [0 0 90 180 270] def
/KI_DIRECTION [
( 1 0 0 1\n) % degenerate 0
( 1 0 0 1\n) % 0 rotate
( 0 -1 1 0\n) % -90 rotate
(-1 0 0 -1\n) % -180
( 0 1 -1 0\n) % -270
] def
/PS_DIRECTION [
[ 1 0 0 1 0 0] % degenerate 0
[ 1 0 0 1 0 0] % 0 rotate
[ 0 -1 1 0 0 0] % -90 rotate
[-1 0 0 -1 0 0] % -180
[ 0 1 -1 0 0 0] % -270
] def
%0 0 90 180 270
/KORENTATION [(H ) (H ) (V ) (H ) (V )] def % Kicad text orientation Horizontal|Vertical
/KJUSTIFY [(L T) dup (L T) (R B) (R B)] def % kicad text justify Left|Right Top|Bottom
/K_TXT_DIRECTION << % >>
% coordinates are mirrored
% 1 2 3 4
-180 {
[(H ) (H ) (V ) (H ) (V )] 1 index get /lKTxtOrent exch def
[(L T) dup (L T) (R B) (R B)] exch get /lKTxtJust exch def
}
dup 180 exch % flip rotates sometimes have issues with the sign magnitude
90 {
[(V ) (V ) (H ) (H ) (V )] 1 index get /lKTxtOrent exch def
[(L T) dup (L T) (R B) (R B)] exch get /lKTxtJust exch def
}
dup -270 exch
-90 {
[(V ) (V ) (H ) (V ) (H )] 1 index get /lKTxtOrent exch def
[(R B) dup (L T) (R B) (L T)] exch get /lKTxtJust exch def
}
dup 270 exch
0 {
[(H ) (H ) (V ) (H ) (V )] 1 index get /lKTxtOrent exch def
[(R B) dup (L T) (R B) (L T)] exch get /lKTxtJust exch def
}
dup -360 exch
dup 360 exch
>> def
/FONT [/notdef /PLAIN /BOLD] def
/ARC [ 0 360 300 210 180 90 90 ] def
/ARC_SHAPE [[0 3600] dup [1200 600] [1650 150] [1801 3599] [2250 3150] [2700 0]] def
/KSCH_ARC_DIRECTION [
[[0 3600] dup [1200 600] [1650 150] [1801 3599] [2250 3150] [2700 0] ] % 0
[[0 3600] dup [2100 1500] [2550 1050] [2701 899] [3150 450] [0 900] ] % 90
[[0 3600] dup [3000 2400] [3450 1950] [1 1799] [450 1350] [900 1800] ] % ]180
[[0 3600] dup [300 3300] [750 2850] [901 2699] [1350 2250] [1800 2700]] % 270
] def
% 360 0 300 210 180 90 90
/K_ARC_DIRECTION [
[[0 3600] dup [3000 2400] [3450 1950] [1 1799] [450 1350] [900 1800] ] % ]180
[[0 3600] dup [300 3300] [750 2850] [901 2699] [1350 2250] [1800 2700]] % 270
[[0 3600] dup [1200 600] [1650 150] [1801 3599] [2250 3150] [2700 0] ] % 0
[[0 3600] dup [2100 1500] [2550 1050] [2701 899] [3150 450] [0 900] ] % 90
] def
/COMPONENT_TYPE [/notdef /titleBlockType /componentType /symbolType /footprintType /notdef] def
/invalid %(/\\:*?"<>|)
<<47 95 92 95 58 95 42 95 63 95 34 95 60 95 62 95 124 95 >>
def
%*fields Properties
%-Reference
/quoteText {
tf read {
%dup ==
% find first quote
{
34 eq {exit}if
tf read not {exit} if
} loop
[
{
tf read {
dup 34 eq {pop exit} if
invalid 1 index known {
pop % ignore invalid chars
}if
}{ exit }ifelse
} loop
] makestring
%(->) print pstack (<-) = flush
}{exit}ifelse
} bind def
/isNumber << % >>
/48 0
/49 1
/50 2
/51 3
/52 4
/53 5
/54 6
/55 7
/56 8
/57 9
>> def
%16#DF toupper mask
/decomposeRef {
/instance 0 def
/isMultiGate false def
% /libRefTxtSfx (_expressPCB) def
/origRefTxtCnt 0 def % count of text bytes in reference name
/origRefTxt exch def % so we can get the prefix back
% since we index the netlist by ref, this field can not be blank
origRefTxt length 0 eq {/origRefTxt (REF0) def}if
[ origRefTxt
dup length 1 sub -1 0 { 1 index exch get exch} for pop
% counttomark 0 gt {
counttomark {
isNumber 1 index =string cvs cvn 2 copy known{
pop pop exit % is a number
}{
pop pop % not a number
origRefTxt origRefTxtCnt 3 -1 roll 16#DF and put
/origRefTxtCnt origRefTxtCnt 1 add def
}ifelse
} repeat
counttomark {
isNumber 1 index =string cvs cvn 2 copy known {
get instance 10 mul add /instance exch def
pop
}{
pop pop
counttomark 0 gt {
% how to handle multiple gate components
16#DF and ] makestring /GateSfx exch def
/isMultiGate true def
mark
}if
exit
}ifelse
} repeat
% } if
pop
%origRefTxtCnt 0 gt {
origRefTxt 0 origRefTxtCnt getinterval
/newRefTxt exch def
% newRefTxt dup length libRefTxtSfx length add string dup
% 3 -1 roll 0 exch putinterval dup origRefTxtCnt libRefTxtSfx putinterval
[ newRefTxt {} forall ] makestring
/libRefTxt exch def
%}if
} bind def
%-Value
%~when unknown
%-Footprint
%~when unknown
%-Datasheet
%~when unknown
%#PWR for power pins -- handle symbols separatly
/getAttributes {
/paramInt exch def
verbose {
paramInt qdbp
% split it out
dup 0 12 getinterval print ( ) print
dup 12 1 getinterval print ( ) print
%dup 13 1 getinterval print ( ) print
13 3 getinterval print (b) =
} if
%FDECBA987654 3 2 10
%0123456789AB C D EF
%ssssssssssss
/TextAttributes << % >>
/attrib_vis paramInt 16#08 and 0 ne
/attrib_dir paramInt 7 and
/attrib_size paramInt -4 bitshift
/attrib_style 1 def % fixed style
/Object /attributesType
>> def
verbose {
TextAttributes begin
(TextAttributes: d:) print
DIRECTION attrib_dir get =string cvs print
( s:) print attrib_size =string cvs print
( f:) print attrib_style =string cvs print
( v:) print attrib_vis =string cvs =
end
} if
} bind def
/createAddGroup {
% creates or adds to a sub group keeping track of the bounding box
/objectDict exch def
/groupRef groupID =string cvs cvn def
subComponents groupRef 2 copy known {
get % existing component directory
}{
10 dict dup 4 1 roll put % creates a new group dictionary
} ifelse
begin %open component dictionary
% calculate the new bounding box just for pins
% this will be used to detect component rotation and orentation
objectDict /Object get /pinType eq {
% (is pin:) =
currentdict /pinCount known
objectDict begin
{
% (has bbox) =
minX lbb1X min
minY lbb1Y min
maxX lbb2X max
maxY lbb2Y max
pinCount 1 add
}{
lbb1X
lbb1Y
lbb2X
lbb2Y
1
} ifelse
end
/pinCount exch def
% (->) print pstack (<-) =
/maxY exch def
/maxX exch def
/minY exch def
/minX exch def
} if
ref objectDict def
end
} bind def
/updateCorners {
% on entry the trace dict is open
%Object ==
% resolve the part reference from the pad
% type -- we are looking for vias which are
% part of the net. We can also create
% the part reference here
%corners begin
%12 setlinewidth
edges from get begin
% Add the name to the edge dictionary
/netRef newNetRef def
%(corner /) print Object =string cvs print
%x1 y1 moveto
Object /pinType eq {
groups parent get /Root 2 copy known {
get begin
refTxt
end
(.) strcat
pinNo 10 string cvs
strcat
}{
pop pop
(ungrouped.)
%ApertureText aperture 1 sub get
pinNo 10 string cvs
strcat
(.pin) strcat
}ifelse
}{
(link.0)
}ifelse
dup /netPadtext exch def
%netPadtext ==
end % from
/stRefTxt exch def % for debug may be used for reporting
% the net list database
% still in edges dict
edges to get begin
% Add the name to the edge dictionary
/netRef newNetRef def
% resolve the part reference from the pad
% type -- we are looking for vias which are
% part of the net. We can also create
% the part reference here
%x1 y1 lineto stroke
%( , ) print Object ==
Object /pinType eq {
groups parent get /Root 2 copy known {
get begin
refTxt
end
(.) strcat
pinNo 10 string cvs
strcat
}{
pop pop
(ungrouped.)
%ApertureText aperture 1 sub get
pinNo 10 string cvs
strcat
(.pin) strcat
}ifelse
}{
(link.$)
}ifelse
dup /netPadtext exch def
end % to
/endRefTxt exch def % for debug may be used for reporting
% the net list database
%end % edges
} bind def
/newNetID {
(# add new ID: /)print newNetRef =string cvs print ( ) print thisRef == flush
%(# dictstack count: ) print countdictstack ==
tempNets begin
10 dict begin % allocate a new net dictionary
/Object /netType def
% store the linked list in the connections structure
/root thisRef def
/wireCount 1 def
/netNumber net$Idx def % index in mnet table of this net
/net$Idx where {
begin
/net$Idx net$Idx 1 add def
end
} if
%(new root: ) print root ==
% wires are connections with attributes for
% drawing or converting the individual trace
connections root get begin
/netLink /0 def
updateCorners
end % connections
currentdict
end % net dict
newNetRef exch def
end % temp nets
} bind def
/addNetItem
<< % >
0 {
% new item
pop % empty array
{
% dynamically create a new text name for this net
(N$) net$Idx 25 string cvs strcat cvn /newNetRef exch def
tempNets newNetRef known {
/net$Idx net$Idx 1 add def
}{
newNetID
exit
}ifelse
}loop
}
1 {
% add item
0 get /newNetRef exch def
tempNets newNetRef 2 copy known {
(# Adding net: /) print newNetRef =string cvs print ( ) print thisRef ==
% add new temp net to chain
get begin % existing net ref
% local wires are open on stack
/wireCount wireCount 1 add def
% search through net for end of start chain
/nextNetlink root def
verbose {(/) print nextNetlink =string cvs print}if
{
connections nextNetlink get begin
netLink
verbose {(-->/) print dup =string cvs print} if
currentdict
end
/linkDict exch def
/nextNetlink exch def
nextNetlink /0 eq{exit} if
}loop
verbose {() = flush}if
linkDict begin
/netLink thisRef def
netLink
end
connections exch get begin
/netLink /0 def
/wire wireCount def
updateCorners
end %connections
%(-e-------------------) =
%currentdict dfa
%(--e------------------) =
end % existing net ref
}{
pop pop
newNetID
}ifelse
%dddrawpage
}
2 { % merge items
%(\n@ trace merge ->) print pstack (<-) =
/oldVerbose verbose def
/verbose false def
10 dict begin % push working directory for temp values
/Object /tempType def
/self /0 def
dup 0 get /sourceNetRef exch def
1 get /targetNetRef exch def
(# Merging 2 temp nets: /) print
sourceNetRef =string cvs print ( - ) print targetNetRef ==
sourceNetRef targetNetRef eq {
(# calling add net: /) print sourceNetRef =string cvs print ( ) print thisRef ==
%(->) print pstack (<-) =
%true {dddrawpage} if
% add single item
[sourceNetRef]
addNetItem 1 get exec
%true {dddrawpage} if
}{
% search for new net name
connections thisRef get /Object get /pinType eq {
(# blank pin: ) print netName ==
}if
sourceNetRef 35 string cvs (N$) search {
pop pop pop
targetNetRef 35 string cvs (N$) search {
pop pop pop
/newNetRef sourceNetRef def
}{
pop
/newNetRef targetNetRef def
}ifelse
}{
pop
/newNetRef sourceNetRef def
}ifelse
(# merged net name: ) print newNetRef == flush
tempNets sourceNetRef known not {
verbose {(source not found: ) = flush}if
newNetID
% tempNets sourceNetRef get dfa stop
}if
tempNets targetNetRef known not{
verbose {(target not found: ) = flush}if
newNetID
% tempNets targetNetRef get dfa stop
}if
/sourceNet tempNets sourceNetRef get def
/targetNet tempNets targetNetRef get def
/sourceNetNumber sourceNet /netNumber get def
/sourceTraceRoot connections sourceNet /root get get def
/targetTraceRoot connections targetNet /root get get def
/thisTraceRef connections thisRef get def
%false {dddrawpage} if
% search through net for end of start chain
/nextNetlink sourceNet /root get def
verbose {(/) print nextNetlink =string cvs print flush}if
{
connections nextNetlink get begin
netLink self eq { % prevent recursive loops on bad data
/netLink /0 def
}if
netLink
verbose {(-->/) print dup =string cvs print flush} if
currentdict
end
/linkDict exch def
/nextNetlink exch def
nextNetlink /0 eq{exit} if
} loop
verbose {() = flush}if
false {
% debug draw the second part of the net
verbose {(# debug second part of net) =} if
/nextNetlink targetNet /root get def
verbose {(/) print nextNetlink =string cvs print} if
{
connections nextNetlink get begin
netLink self eq { % prevent recursive loops on bad data
/netLink /0 def
}if
netLink
verbose {(-->/) print dup =string cvs print}if
%currentdict
end
%/linkDict exch def
/nextNetlink exch def
nextNetlink /0 eq{exit} if
}loop
verbose {()= flush} if
} if
% create all new nets
tempNets sourceNetRef undef
tempNets targetNetRef undef
% we have the choice here to join the nets
% in a sort of order
%(sorting nets) =
%Object ==
%self ==
%count ==
/u sourceNet /root get def
/v targetNet /root get def
/w thisRef def
/p linkDict /to get 10 string cvs cvi def
/q targetTraceRoot /from get 10 string cvs cvi def
/r thisTraceRef /from get 10 string cvs cvi def
%[ u v w ] ==
%[ p q r ] ==
q p lt
{
/t1 p def
/t2 u def
r q lt { %if r < q { p = r; r = t; }
/p r def
/r t1 def
/u w def
/w t2 def
}
%else
{
r t1 lt {%if r < t { p = q; q = r; r = t; }
/p q def
/q r def
/r t1 def
/u v def
/v w def
/w t2 def
}
%else
{ % { p = q; q = t; }
/p q def
/q t1 def
/u v def
/v t2 def
}ifelse
}ifelse
}
%else
{
r q lt %if r < q
{
%t = r; r = q;
/t1 r def
/r q def
/t2 w def
/w v def
t1 p lt { %if t < p { q = p; p = t; }
/q p def
/p t1 def
/v u def
/u t2 def
}
% else { q = t; }
{
/q t1 def
/v t2 def
}ifelse
}if
}ifelse
%Object ==
%self ==
%[ u v w ] ==
%[ p q r ] ==
% assemble the net in semi sort order
/nextNetlink connections u get /self get def
verbose {(# assembling nets in new sort order: ) =} if