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 | ###############################################################################
# Copyright (c) 2001-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.
# =============================================================================
# @plugin
# Load FastScan Report
# @namespace
# FastScan
# @section
# Read Side Files and Annotate Data
# @description
# Parse a FastScan report file and display a pin list.
# @test
# ModuleTest
# @files
# fastscan/fastscan.tcl
# fastscan/bus85.fas
# fastscan/bus85_small.fas
# fastscan/minirisc.fas
# @example
# demo/verilog/bus85.f
# @cmdline
# -verilog
# -F @example[0]
# -userware2 @files[0] @files[1]
# @tag
# zdb gui netlist verilog
###############################################################################
# =============================================================================
# Init - Initialize the plugin.
# =============================================================================
#
proc FastScan:Init {argc argv} {
global FastScan
set db [gui database get]
FastScan:ResetVariables $db
gui menu command {"Fastscan" "Load Report"} [list FastScan:loadFile $db]
if {$argc == 1} {
set FastScan(cmd) \
[list FastScan:ResetVariablesAndLoadFile [lindex $argv 0]]
} else {
set FastScan(cmd) FastScan:ResetVariables
}
gui database registerChangedCallback $FastScan(cmd)
}
# =============================================================================
# Finit - Finalize the plugin.
# =============================================================================
#
proc FastScan:Finit {} {
global FastScan
gui database removeChangedCallback [lindex $FastScan(cmd) 0]
gui menu removeEntry {"Fastscan" "Load Report"}
array unset FastScan
}
# =============================================================================
# ResetVariables - Reset all internal variables.
# =============================================================================
#
proc FastScan:ResetVariables {db} {
global FastScan
set FastScan(db) $db
set FastScan(displayAttribute) 0
if {$db == {}} {
return
}
$db foreach top top {
set FastScan(top) [$db oid oname $top]
break
}
}
# =============================================================================
# ResetVariablesAndLoadFile - Reset variables and load the given file.
# =============================================================================
#
proc FastScan:ResetVariablesAndLoadFile {file db} {
FastScan:ResetVariables $db
##
# If db is close do no load file again.
#
if {$db ne {}} {
FastScan:showFile $file
}
}
# -----------------------------------------------------------------------------
# loadFile - Show a browse file dialog to open a FastScan file.
# -----------------------------------------------------------------------------
#
proc FastScan:loadFile {{db {}}} {
global FastScan
if {![info exists FastScan(db)]} {
FastScan:Init 1 [list $db]
} else {
set db $FastScan(db)
}
if {$FastScan(db) == {}} {
set msg "No database loaded."
zmessage print ERR $msg
tk_messageBox -message $msg -icon error -parent . -title "Error:"
return
}
set fileTypes {{"FastScan-File" {".fas" ".faults"}}}
set f [gui window fileDialog openFile "Open a FastScan file" $fileTypes]
if {$f eq ""} {
return
}
FastScan:showFile $f
}
# -----------------------------------------------------------------------------
# showFile -
# -----------------------------------------------------------------------------
#
proc FastScan:showFile {file} {
global FastScan
if {[winfo exists .fas]} {
destroy .fas
}
toplevel .fas
wm transient .fas .
wm group .fas .
wm title .fas FastScan
wm withdraw .fas
##
# Listbox with y scrollbars.
#
ttk::frame .fas.l
listbox .fas.l.pinList -exportselection 0 \
-selectborderwidth 0 \
-selectmode single \
-yscrollcommand [list .fas.l.ysb set]
ttk::scrollbar .fas.l.ysb -orient vertical \
-command [list .fas.l.pinList yview]
grid .fas.l.pinList -column 0 -row 0 -sticky news
grid .fas.l.ysb -column 1 -row 0 -sticky ns
grid rowconfigure .fas.l 0 -weight 1
grid columnconfigure .fas.l 0 -weight 1
grid columnconfigure .fas.l 1 -weight 0
##
# Text widget with x and y scrollbars.
#
ttk::frame .fas.r
text .fas.r.lineNo -bd 0 \
-font TkFixedFont \
-cursor {} \
-width 6 \
-wrap none \
-state disabled \
-yscrollcommand [list .fas.r.ysb set] \
-xscrollcommand [list .fas.r.xsb set]
text .fas.r.source -bd 0 \
-font TkFixedFont \
-cursor {} \
-wrap none \
-state disabled \
-takefocus 1 \
-width 50 \
-yscrollcommand [list .fas.r.ysb set] \
-xscrollcommand [list .fas.r.xsb set]
ttk::scrollbar .fas.r.ysb -orient vertical \
-command [list FastScan:scrollText]
ttk::scrollbar .fas.r.xsb -orient horizontal \
-command [list .fas.r.source xview]
grid .fas.r.lineNo -column 0 -row 0 -sticky news
grid .fas.r.source -column 1 -row 0 -sticky news
grid .fas.r.xsb -column 0 -row 1 -sticky we -columnspan 2
grid .fas.r.ysb -column 2 -row 0 -sticky ns
grid rowconfigure .fas.r 0 -weight 1
grid columnconfigure .fas.r 1 -weight 1
.fas.r.source tag configure highlight -foreground #FF0000
.fas.r.lineNo configure -foreground #777777
bind .fas.r.source <Double-ButtonPress-1> {
FastScan:gotoSelected %W %x %y
break
}
bind .fas.l.pinList <Double-ButtonPress-1> {
FastScan:gotoSelected %W %x %y
break
}
bind .fas.r.source <B2-Motion> {break}
bind .fas.r.source <MouseWheel> {break}
bind .fas.r.lineNo <B2-Motion> {break}
bind .fas.r.lineNo <MouseWheel> {break}
##
# Frame with window selection radiobuttons.
#
ttk::frame .fas.bl -relief sunken -borderwidth 1
label .fas.bl.winLab -text "Window:"
ttk::radiobutton .fas.bl.winSrc -text "Source" \
-value .fas.r \
-variable FastScan(showWindow) \
-command [list raise .fas.r]
ttk::radiobutton .fas.bl.winPin -text "Pins" \
-value .fas.l \
-variable FastScan(showWindow) \
-command [list raise .fas.l]
pack .fas.bl.winLab .fas.bl.winSrc .fas.bl.winPin -side left
##
# Frame with attribute selection radiobuttons.
#
set FastScan(displayAttribute) 1
ttk::frame .fas.br -relief sunken -borderwidth 1
label .fas.br.winLab -text "Attribute:"
ttk::radiobutton .fas.br.winSrc -text "Fault" \
-value 1 \
-variable FastScan(displayAttribute) \
-command FastScan:displayAttributes
ttk::radiobutton .fas.br.winPin -text "None" \
-value 0 \
-variable FastScan(displayAttribute) \
-command FastScan:displayAttributes
pack .fas.br.winLab .fas.br.winSrc .fas.br.winPin -side left
##
# The cancel button.
#
ttk::button .fas.cancel -text "Cancel" -command [list destroy .fas]
##
# Pack all with a grid layout.
#
grid .fas.l -row 0 -column 0 -sticky news -columnspan 3
grid .fas.r -row 0 -column 0 -sticky news -columnspan 3
grid .fas.bl -row 1 -column 0 -sticky we -pady 2 -padx 1
grid .fas.br -row 1 -column 1 -sticky we -pady 2 -padx 1
grid .fas.cancel -row 1 -column 2 -sticky e -pady 2 -padx 2
grid rowconfigure .fas 0 -weight 1
grid rowconfigure .fas 1 -weight 0
grid columnconfigure .fas 0 -weight 0
grid columnconfigure .fas 1 -weight 1
FastScan:Parse $file $FastScan(db)
wm deiconify .fas
set FastScan(showWindow) .fas.r
FastScan:displayAttributes
}
# =============================================================================
# Parse - Parse the FastScan file.
# =============================================================================
#
proc FastScan:Parse {file db} {
global FastScan
set id [open $file "r"]
.fas.r.lineNo configure -state normal
.fas.r.source configure -state normal
set FastScan(pinList) {}
set lineNumber 0
set lastMeaningFull "EQ"
while {[gets $id line] >= 0} {
incr lineNumber
set line [string trim $line]
##
# empty lines are ignored
#
if {[string length $line] == 0} {
continue
}
if {[llength $line] != 3} {
zmessage print ERR "fastscan: bad syntax at $file:$lineNumber"
continue
}
set faultVal [lindex $line 0]
set faultType [lindex $line 1]
set pinString [lindex $line 2]
if {$faultType == "EQ"} {
set faultType $lastMeaningFull
} else {
set lastMeaningFull $faultType
}
set pinList [split $pinString /]
set pinListLen [llength $pinList]
if {$pinListLen > 2} {
set type pin
} elseif {$pinListLen == 2} {
set type port
} else {
##
# ignore strings without a single /
#
continue
}
set oid [concat $type $FastScan(top) [lrange $pinList 1 end]]
if {[catch {$db oid create $oid}]} {
zmessage print ERR "Cannot find object: $oid in database."
continue
}
set name [$db oid oname $oid]
set pName [$db oid pname $oid]
.fas.r.lineNo insert end "${lineNumber}:\n"
.fas.r.source insert end "$line\n"
.fas.l.pinList insert end "$faultVal $faultType - $type $name $pName"
lappend FastScan(pinList) $oid
##
# annotate the pinBus so the attr is still visible
#
if {[$db isBusMember $oid]} {
set oid [$db busOf $oid]
}
set value "$faultVal $faultType"
$db flatattr $oid set Fault=${value}
}
.fas.r.lineNo configure -state disabled
.fas.r.source configure -state disabled
raise .fas.r.source
close $id
}
# -----------------------------------------------------------------------------
# displayAttributes - Display values in the schematic and cone window.
# -----------------------------------------------------------------------------
#
proc FastScan:displayAttributes {} {
global FastScan
if {$FastScan(displayAttribute)} {
set show "value\n%Fault"
} else {
set show "value\n%none"
}
$FastScan(db) attr -db set @nlv:pin=%$show
$FastScan(db) attr -db set @nlv:pinBus=%$show
$FastScan(db) attr -db set @nlv:port=%$show
$FastScan(db) attr -db set @nlv:portBus=%$show
gui attribute changed
}
# -----------------------------------------------------------------------------
# gotoSelected - Highlight the double clicked pin and call Goto.
# -----------------------------------------------------------------------------
#
proc FastScan:gotoSelected {w x y} {
global FastScan
set index [$w index @$x,$y]
if {$w == ".fas.r.source"} {
set line [lindex [split $index .] 0]
set index [expr {$line - 1}]
} else {
set line [expr {$index + 1}]
}
.fas.r.source tag remove highlight 1.0 end
.fas.r.source tag add highlight $line.0 $line.end
.fas.r.source see $line.0
.fas.r.lineNo see $line.0
.fas.l.pinList selection clear 0 end
.fas.l.pinList selection set $index
.fas.l.pinList see $index
set oid [lindex $FastScan(pinList) $index]
gui goto -class Schem [list $oid]
gui tree setCurrentModule $oid
}
# -----------------------------------------------------------------------------
# scrollText - Scroll source and lineno text widget.
# -----------------------------------------------------------------------------
#
proc FastScan:scrollText {args} {
eval .fas.r.source yview $args
eval .fas.r.lineNo yview $args
}
# =============================================================================
# Call the initialization procedure.
# =============================================================================
#
FastScan:Init $argc $argv
|