-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbondtools.il
498 lines (435 loc) · 12.2 KB
/
bondtools.il
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
/*=============================================================================*
*
* bondtools
*
*
* Purpose : Routing Bondwires in IC-Packages
* Authors : Matthias Schweikardt
*
* Language : Cadence Skill
* Lint : IQ score is 100 (best is 100) {sklint ?file "bondtools.il"}
*
* Globals :
* - Functions :
* o EDbondtoolsDrawWires
* o EDbondtoolsGetLabelsFromHierarchy
* o EDbondtoolsOpenUserInterface
* o EDbondtoolsDrawBondWiresCallback
* o EDbondtoolsEnableLogfileCallback
* - Symbols : none
*
* Copyright 2023 Reutlingen University, Electronics & Drives (Germany)
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*=============================================================================*/
;FUNCTION
; EDbondtoolsDrawWires
;
;Description:
; Draw bondwires in a layout cellview
;
;Parameters:
; cv dbobj, cellview where the bonding diagram is created
; fBallRadius float, radius of the ball in *du*
; fWireDiameter float, diameter of bondwire in *du*
; fWedgeExtention float, extension of the wedge in *du*
; sLogfile string, path to logfile (provide nil when no logfile is cretaed)
;
;Return:
; retval bool, 't' when successful, 'nil' otherwise
;
(defun EDbondtoolsDrawWires (cv fBallRadius fWireDiameter
fWedgeExtention sLogfile "gnnng")
(let (ballLabels wedgeLabels labelPairs (port nil))
;for lint
fWedgeExtention
(if
(and
(dbIsId cv)
(equal cv~>cellViewType "maskLayout")
(or
(equal cv~>mode "a")
(equal cv~>mode "w")
);or
);and
then
(when (stringp sLogfile)
(setq port (outfile sLogfile "w"))
(fprintf port "name,type1,type2,x1,y1,x2,y2")
);when
(setq
ballLabels
(EDbondtoolsGetLabelsFromHierarchy cv (list "BALL" "label"))
);setq
(setq
wedgeLabels
(EDbondtoolsGetLabelsFromHierarchy cv (list "WEDGE" "label"))
);setq
(setq labelPairs (makeTable "labelPairs" nil))
(foreach label ballLabels
(unless (arrayref labelPairs (car label))
(setarray labelPairs (car label) (tconc nil nil))
);unless
(tconc (arrayref labelPairs (car label)) (list (cadr label) "BALL"))
);foreach
(foreach label wedgeLabels
(unless (arrayref labelPairs (car label))
(setarray labelPairs (car label) (tconc nil nil))
);unless
(tconc (arrayref labelPairs (car label)) (list (cadr label) "WEDGE"))
);foreach
(foreach label labelPairs~>?
(setarray
labelPairs
label
(cdar (arrayref labelPairs label))
);setarray
(unless (equal (length (arrayref labelPairs label)) 2)
(if (onep (length (arrayref labelPairs label))) then
(warn
"Too less pins (1) are specified for wire %L, will be ignored"
label
);warn
else
(warn
"Too much pins (%L) are specified for wire %L, will be ignored"
(length (arrayref labelPairs label))
label
);warn
);if
(remove
label
labelPairs
);remove
);unless
);foreach
(foreach label labelPairs~>?
(if (equal (cadar (arrayref labelPairs label)) "BALL") then
(dbCreateEllipse
cv
(list "BONDWIRE" "drawing")
(list
(list
(difference (xCoord (caar (arrayref labelPairs label))) fBallRadius)
(difference (yCoord (caar (arrayref labelPairs label))) fBallRadius)
);list
(list
(plus (xCoord (caar (arrayref labelPairs label))) fBallRadius)
(plus (yCoord (caar (arrayref labelPairs label))) fBallRadius)
);list
);list
);dbCreateEllipse
(when (portp port)
(fprintf
port
"\n%s,ball"
label
);fprintf
);when
else
(when (portp port)
(fprintf
port
"\n%s,wedge"
label
);fprintf
);when
);if
(if (equal (cadadr (arrayref labelPairs label)) "BALL") then
(dbCreateEllipse
cv
(list "BONDWIRE" "drawing")
(list
(list
(difference (xCoord (caadr (arrayref labelPairs label))) fBallRadius)
(difference (yCoord (caadr (arrayref labelPairs label))) fBallRadius)
);list
(list
(plus (xCoord (caadr (arrayref labelPairs label))) fBallRadius)
(plus (yCoord (caadr (arrayref labelPairs label))) fBallRadius)
);list
);list
);dbCreateEllipse
(when (portp port)
(fprintf
port
",ball"
);fprintf
);when
else
(when (portp port)
(fprintf
port
",wedge"
);fprintf
);when
);when
(dbCreatePath
cv
(list "BONDWIRE" "drawing")
(list
(caar (arrayref labelPairs label))
(caadr (arrayref labelPairs label))
);list
fWireDiameter
);dbCreatePath
(when (portp port)
(fprintf
port
",%L,%L,%L,%L"
(xCoord (caar (arrayref labelPairs label)))
(yCoord (caar (arrayref labelPairs label)))
(xCoord (caadr (arrayref labelPairs label)))
(yCoord (caadr (arrayref labelPairs label)))
);fprintf
);when
);foreach
(when (portp port)
(close port)
);when
labelPairs
else
(error "No editable cellview is provided")
nil
);if
);let
);defun EDbondtoolsDrawWires
;FUNCTION
; EDbondtoolsGetLabelsFromHierarchy
;
;Description:
; Get the position of the bondtools labels hierarchically
;
;Parameters:
; dbobj dbobj, database object to be searched for labels
; layer lpp, layer purpose pair of label
;
;Return:
; labels list, list of labels
;
(defun EDbondtoolsGetLabelsFromHierarchy (dbobj layer)
(let ((lAccumulator (tconc nil nil)) subLabels)
(foreach shape dbobj~>shapes
(when
(and
(equal shape~>lpp layer)
(equal shape~>objType "label")
);and
(tconc lAccumulator (list shape~>theLabel shape->xy))
);when
);foreach
(foreach inst dbobj~>instances
(setq subLabels (EDbondtoolsGetLabelsFromHierarchy inst~>master layer))
(when subLabels
(lconc
lAccumulator
(foreach mapcar elem subLabels
(list
(car elem)
(dbTransformPoint (cadr elem) inst~>transform)
);list
);foreach
);lconc
);when
);foreach
(cdar lAccumulator)
);let
);defun
;FUNCTION
; EDbondtoolsOpenUserInterface
;
;Description:
; This function open the user interface of the software bondtools
;
;Return:
; always 't'
;
(defun EDbondtoolsOpenUserInterface ()
(let (form cv (logfile "./bondtools.log"))
(setq form (eval (quote EDdrawBondWires)))
(when
(and
(setq cv (geGetWindowCellView))
(equal cv~>cellViewType "maskLayout")
);and
(setq
logfile
(lsprintf
"./bondtools_%s_%s_%s.log"
cv~>libName
cv~>cellName
cv~>viewName
);lsprintf
);setq
);when
(putpropq
form~>logfile
logfile
value
);putpropq
(hiDisplayForm (quote EDdrawBondWires))
);let
);defun
;FUNCTION
; EDbondtoolsDrawBondWiresCallback
;
;Description:
; Callback that is triggered when the button *OK* or *Apply*
; is pushed in the GUI
;
;Return:
; t bool, always 't'
;
(defun EDbondtoolsDrawBondWiresCallback ()
(let (form cv)
(setq form (eval (quote EDdrawBondWires)))
(if
(and
(setq cv (geGetWindowCellView))
(equal cv~>cellViewType "maskLayout")
(or
(equal cv~>mode "w")
(equal cv~>mode "a")
);or
);and
then
(EDbondtoolsDrawWires
cv
form~>ballRadius~>value
form~>bondDiameter~>value
form~>wedgeExtionsion~>value
(when form~>enableLogfile~>value
form~>logfile~>value
);when
);EDbondtoolsDrawWires
(when form~>enableLogfile~>value
(hiViewTextFile form~>logfile~>value)
);when
else
(error "No editable layout cellview available")
);if
t
);let
);defun
;FUNCTION
; EDbondtoolsEnableLogfileCallback
;
;Description:
; Callback that is triggered when the boolean button "Enable Logfile"
; is pushed in the Draw Bondwire form
;
;Return:
; t bool, always 't'
;
(defun EDbondtoolsEnableLogfileCallback ()
(let (form)
(setq form (eval (quote EDdrawBondWires)))
(putpropq
form~>logfile
form~>enableLogfile~>value
enabled
);putpropq
t
);let
);defun EDbondtoolsEnableLogfileCallback
(let (bondDiameter ballRadius wedgeExtionsion enableLogfile logfile formLayout)
(setq
bondDiameter
(hiCreateFloatField
?name (quote bondDiameter)
?prompt "Bondwire Diameter"
?value 25.0
?range (list 0.01 "infinity")
);hiCreateFloatField
);setq
(setq
ballRadius
(hiCreateFloatField
?name (quote ballRadius)
?prompt "Ball Radius"
?value 35.0
?range (list 0.01 "infinity")
);hiCreateFloatField
);setq
(setq
wedgeExtionsion
(hiCreateFloatField
?name (quote wedgeExtionsion)
?prompt "Wedge Extension"
?value 0.0
?range (list 0.0 "infinity")
?editable nil
);hiCreateFloatField
);setq
(setq
enableLogfile
(hiCreateBooleanButton
?name (quote enableLogfile)
?buttonText "Enable Logfile"
?defValue nil
?callback "(EDbondtoolsEnableLogfileCallback)"
);hiCreateBooleanButton
);setq
(setq
logfile
(hiCreateFileSelectorField
?name (quote logfile)
?mode (quote anyFile)
?prompt "Logfile"
?enabled nil
?value ""
);hiCreateFileSelectorField
);setq
(setq
formLayout
(hiCreateFormLayout
(quote drawBondwireFormLayout)
?frame "drawBondwireFormLayout"
?items
(list
bondDiameter
ballRadius
wedgeExtionsion
enableLogfile
logfile
);list
);hiCreateFormLayout
);setq
(hiCreateLayoutForm
(quote EDdrawBondWires)
"[ED] Draw Bondwires"
formLayout
?sizePolicy (quote horizontalExpanding)
?dialogStyle (quote modeless)
?buttonLayout (quote OKCancelApply)
?minSize 300:100
?callback
(list
"(EDbondtoolsDrawBondWiresCallback)"
"nil"
);list
;?buttonDisabled (list 'Help)
);hiCreateLayoutForm
(putpropq
(quote EDdrawBondWires)
"(hiLaunchBrowser \"https://github.com/matthschw/bondtools\")"
hiHelpAction
);putpropq
);let