OpenCores
URL https://opencores.org/ocsvn/bustap-jtag/bustap-jtag/trunk

Subversion Repositories bustap-jtag

[/] [bustap-jtag/] [trunk/] [cmd/] [altera/] [virtual_jtag_console.tcl] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 ash_riple
##**************************************************************
2 8 ash_riple
## Module             : virtual_jtag_console.tcl
3 6 ash_riple
## Platform           : Windows xp sp2
4
## Author             : Bibo Yang  (ash_riple@hotmail.com)
5
## Organization       : www.opencores.org
6
## Revision           : 2.1 
7
## Date               : 2012/03/15
8
## Description        : Tcl/Tk GUI for the up_monitor
9
##**************************************************************
10
 
11 2 ash_riple
proc reset_fifo {{jtag_index_0 0}} {
12 6 ash_riple
        device_lock -timeout 5
13 2 ash_riple
        device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 2 -no_captured_ir_value
14
        device_virtual_dr_shift -instance_index $jtag_index_0  -length 32 -dr_value 00000000 -value_in_hex -no_captured_dr_value
15
        device_unlock
16
        return 0
17
}
18
 
19
proc query_usedw {{jtag_index_0 0}} {
20
        global fifoUsedw
21 6 ash_riple
        device_lock -timeout 5
22 2 ash_riple
        device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
23
        set usedw [device_virtual_dr_shift -instance_index $jtag_index_0 -length 9 -value_in_hex]
24
        device_unlock
25
                set tmp 0x
26
                append tmp $usedw
27
                set usedw [format "%i" $tmp]
28
        set fifoUsedw $usedw
29
        return $usedw
30
}
31
 
32
proc read_fifo {{jtag_index_0 0}} {
33 6 ash_riple
        device_lock -timeout 5
34 2 ash_riple
        device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
35
        device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 3 -no_captured_ir_value
36 12 ash_riple
        set fifo_data [device_virtual_dr_shift -instance_index $jtag_index_0 -length 82 -value_in_hex]
37 2 ash_riple
        device_unlock
38
        return $fifo_data
39
}
40
 
41 8 ash_riple
proc config_addr {{jtag_index_1 1} {mask 0100000000} {mask_id 1}} {
42
        global log
43
        set mask_leng [string length $mask]
44
        if {$mask_leng!=10} {
45
                $log insert end "\nError: Wrong address mask length @$mask_id: [expr $mask_leng-2]. Expects: 8.\n"
46
 
47
        } else {
48
                device_lock -timeout 5
49
                device_virtual_ir_shift -instance_index $jtag_index_1 -ir_value 1 -no_captured_ir_value
50
                set addr_mask [device_virtual_dr_shift -instance_index $jtag_index_1 -dr_value $mask -length 40 -value_in_hex]
51
                device_unlock
52
                return $addr_mask
53
        }
54 2 ash_riple
}
55
 
56 14 ash_riple
proc config_trig {{jtag_index_2 2} {trig 00000000000000} {pnum 000}} {
57 8 ash_riple
        global log
58
        set trig_leng [string length $trig]
59
        if {$trig_leng!=14} {
60
                $log insert end "\nError: Wrong trigger condition length: [expr $trig_leng-2]. Expects: 4+8.\n"
61
        } else {
62
                device_lock -timeout 5
63
                device_virtual_ir_shift -instance_index $jtag_index_2 -ir_value 1 -no_captured_ir_value
64
                set addr_trig [device_virtual_dr_shift -instance_index $jtag_index_2 -dr_value $trig -length 56 -value_in_hex]
65 11 ash_riple
                device_virtual_ir_shift -instance_index $jtag_index_2 -ir_value 2 -no_captured_ir_value
66 14 ash_riple
                set addr_trig [device_virtual_dr_shift -instance_index $jtag_index_2 -dr_value $pnum -length 10 -value_in_hex]
67 8 ash_riple
                device_unlock
68
                return $addr_trig
69
        }
70 2 ash_riple
}
71
 
72
proc open_jtag_device {{test_cable "USB-Blaster [USB-0]"} {test_device "@2: EP2SGX90 (0x020E30DD)"}} {
73
        open_device -hardware_name $test_cable -device_name $test_device
74
        # Retrieve device id code.
75 6 ash_riple
        device_lock -timeout 5
76 2 ash_riple
        device_ir_shift -ir_value 6 -no_captured_ir_value
77
        set idcode "0x[device_dr_shift -length 32 -value_in_hex]"
78
        device_unlock
79
        return $idcode
80
}
81
 
82
proc close_jtag_device {} {
83
        close_device
84
}
85
 
86
proc scan_chain {} {
87
        global log
88
        $log insert end "JTAG Chain Scanning report:\n"
89
        $log insert end "****************************************\n"
90
        set blaster_cables [get_hardware_names]
91
        set cable_num 0
92
        foreach blaster_cable $blaster_cables {
93
                incr cable_num
94
                $log insert end "@$cable_num: $blaster_cable\n"
95
        }
96
        $log insert end "\n****************************************\n"
97
        global device_list
98
        set device_list ""
99
        foreach blaster_cable $blaster_cables {
100
                $log insert end "$blaster_cable:\n"
101
                lappend device_list $blaster_cable
102
                if [catch {get_device_names -hardware_name $blaster_cable} error_msg] {
103
                        $log insert end $error_msg
104
                        lappend device_list $error_msg
105
                } else {
106
                        foreach test_device [get_device_names -hardware_name $blaster_cable] {
107
                                $log insert end "$test_device\n"
108
                        }
109
                        lappend device_list [get_device_names -hardware_name $blaster_cable]
110
                }
111
        }
112
}
113
 
114
proc select_device {{cableNum 1} {deviceNum 1}} {
115
        global log
116
        global device_list
117
        $log insert end "\n****************************************\n"
118
        set test_cable [lindex $device_list [expr 2*$cableNum-2]]
119
        $log insert end "Selected Cable : $test_cable\n"
120
        set test_device [lindex [lindex $device_list [expr 2*$cableNum-1]] [expr $deviceNum-1]]
121
        $log insert end "Selected Device: $test_device\n"
122
        set jtagIdCode [open_jtag_device $test_cable $test_device]
123
        $log insert end "Device ID code : $jtagIdCode\n"
124
        reset_fifo 0
125
        query_usedw 0
126
}
127
 
128 6 ash_riple
proc updateAddrConfig {} {
129 2 ash_riple
        global address_span1
130
        global address_span2
131
        global address_span3
132
        global address_span4
133
        global address_span5
134
        global address_span6
135
        global address_span7
136
        global address_span8
137
        global address_span9
138
        global address_span10
139
        global address_span11
140
        global address_span12
141
        global address_span13
142
        global address_span14
143
        global address_span15
144
        global address_span16
145 6 ash_riple
        global address_span_en1
146
        global address_span_en2
147
        global address_span_en3
148
        global address_span_en4
149
        global address_span_en5
150
        global address_span_en6
151
        global address_span_en7
152
        global address_span_en8
153
        global address_span_en9
154
        global address_span_en10
155
        global address_span_en11
156
        global address_span_en12
157
        global address_span_en13
158
        global address_span_en14
159
        global address_span_en15
160
        global address_span_en16
161
        global addr_wren
162
        global addr_rden
163
        for {set i 1} {$i<=16} {incr i} {
164
                set    mask [format "%1X" [expr $i-1]]
165
                append mask [format "%1X" [expr $addr_wren*8+$addr_rden*4+[set address_span_en$i]]]
166 2 ash_riple
                append mask [set address_span$i]
167 8 ash_riple
                config_addr 1 $mask $i
168 2 ash_riple
        }
169
}
170
 
171 6 ash_riple
proc initAddrConfig {} {
172 2 ash_riple
        global log
173
        global address_span1
174
        global address_span2
175
        global address_span3
176
        global address_span4
177
        global address_span5
178
        global address_span6
179
        global address_span7
180
        global address_span8
181
        global address_span9
182
        global address_span10
183
        global address_span11
184
        global address_span12
185
        global address_span13
186
        global address_span14
187
        global address_span15
188
        global address_span16
189
        for {set i 1} {$i<=8} {incr i} {
190 11 ash_riple
                if {[set address_span$i]==""} {
191
                        set address_span$i ffff0000
192 2 ash_riple
        }
193 11 ash_riple
        }
194 2 ash_riple
        for {set i 9} {$i<=16} {incr i} {
195 11 ash_riple
                if {[set address_span$i]==""} {
196
                        set address_span$i 00000000
197 2 ash_riple
        }
198
}
199 11 ash_riple
}
200 2 ash_riple
 
201 11 ash_riple
proc initTrigConfig {} {
202
        global triggerAddr
203
        global triggerData
204
        global triggerPnum
205
        if {[set triggerAddr]==""} {
206
                set triggerAddr ffff
207
        }
208
        if {[set triggerData]==""} {
209
                set triggerData a5a5a5a5
210
        }
211
        if {[set triggerPnum]==""} {
212
                set triggerPnum 0
213
        }
214
}
215
 
216 6 ash_riple
proc updateTrigger {{trigCmd 0}} {
217 2 ash_riple
        global triggerAddr
218
        global triggerData
219 11 ash_riple
        global triggerPnum
220 6 ash_riple
        global trig_wren
221
        global trig_rden
222
        global trig_aden
223
        global trig_daen
224
        set    triggerValue [format "%1X" [expr $trig_aden*8+$trig_daen*4+0]]
225
        append triggerValue [format "%1X" [expr $trig_wren*8+$trig_rden*4+$trigCmd]]
226 2 ash_riple
        append triggerValue $triggerAddr
227
        append triggerValue $triggerData
228 14 ash_riple
        config_trig 2 $triggerValue [format "%1X" $triggerPnum]
229 2 ash_riple
}
230
 
231
proc startTrigger {} {
232 6 ash_riple
        global trig_wren
233
        global trig_rden
234
        global trig_aden
235
        global trig_daen
236
        set trigEnable [expr $trig_wren+$trig_rden+$trig_aden+$trig_daen]
237
        if {$trigEnable>0} {
238
                updateTrigger 2
239
                reset_fifo 0
240
                query_usedw 0
241
                updateTrigger 3
242
        } else {
243
                updateTrigger 0
244
        }
245 2 ash_riple
}
246
 
247
proc reset_fifo_ptr {} {
248
        reset_fifo 0
249
        query_usedw 0
250
}
251
 
252
proc query_fifo_usedw {} {
253
        query_usedw 0
254
}
255
 
256
proc read_fifo_content {} {
257
        global log
258
        global fifoUsedw
259
        $log insert end "\n****************************************\n"
260
        for {set i 0} {$i<$fifoUsedw} {incr i} {
261
                set fifoContent [read_fifo 0]
262 6 ash_riple
                set ok_trig [expr [format "%d" 0x[string index $fifoContent 0]]/2]
263
                set wr_cptr [expr [format "%d" 0x[string index $fifoContent 0]]%2]
264 12 ash_riple
                set tm_cptr [format "%d"       0x[string range $fifoContent  1  8]]
265
                set ad_cptr                      [string range $fifoContent  9 12]
266
                set da_cptr                      [string range $fifoContent 13 20]
267 6 ash_riple
                if $ok_trig {
268
                        $log insert end "@@@@@@@@@@@@@@@@@@@@\n"
269
                }
270
                if $wr_cptr {
271 12 ash_riple
                        $log insert end "wr $ad_cptr $da_cptr @$tm_cptr\n"
272 6 ash_riple
                } else {
273 12 ash_riple
                        $log insert end "rd $ad_cptr $da_cptr @$tm_cptr\n"
274 6 ash_riple
                }
275 2 ash_riple
        }
276
        query_usedw 0
277
}
278
 
279
proc clear_log {} {
280
        global log
281
        $log delete insert end
282
}
283
 
284
proc quit {} {
285
        global exit_console
286
        destroy .console
287
        set exit_console 1
288
}
289
 
290
# set the QuartusII special Tk command
291
init_tk
292
set exit_console 0
293
 
294
# set the main window
295
toplevel .console
296 6 ash_riple
wm title .console "www.OpenCores.org: uP Transaction Monitor"
297 2 ash_riple
pack propagate .console true
298
 
299 6 ash_riple
# set the www.OpenCores.org logo
300 2 ash_riple
frame .console.fig -bg white
301
pack .console.fig -expand true -fill both
302 6 ash_riple
image create photo logo -format gif -file "../common/OpenCores.gif"
303
label .console.fig.logo -image logo -bg white
304
pack .console.fig.logo
305 2 ash_riple
 
306 6 ash_riple
# set the JTAG utility
307
frame .console.jtag -relief groove -borderwidth 5
308
pack .console.jtag
309
button .console.jtag.scan -text {Scan JTAG Chain} -command {scan_chain}
310
button .console.jtag.select -text {Select JTAG Device :} -command {select_device $cableNum $deviceNum}
311
button .console.jtag.deselect -text {DeSelect JTAG Device} -command {close_jtag_device}
312
label .console.jtag.cable -text {Cable @}
313
label .console.jtag.devic -text {Device @}
314
entry .console.jtag.cable_num -textvariable cableNum -width 5
315
entry .console.jtag.devic_num -textvariable deviceNum -width 5
316
pack .console.jtag.scan .console.jtag.select \
317
     .console.jtag.cable .console.jtag.cable_num \
318
     .console.jtag.devic .console.jtag.devic_num \
319
     .console.jtag.deselect \
320
     -side left -ipadx 0
321 2 ash_riple
 
322
# set the inclusive address entries
323
frame .console.f1 -relief groove -borderwidth 5
324
pack .console.f1
325 6 ash_riple
label .console.f1.incl_addr -text {Inclusive Addr:}
326
entry .console.f1.address_span1 -textvariable address_span1 -width 8
327
entry .console.f1.address_span2 -textvariable address_span2 -width 8
328
entry .console.f1.address_span3 -textvariable address_span3 -width 8
329
entry .console.f1.address_span4 -textvariable address_span4 -width 8
330
entry .console.f1.address_span5 -textvariable address_span5 -width 8
331
entry .console.f1.address_span6 -textvariable address_span6 -width 8
332
entry .console.f1.address_span7 -textvariable address_span7 -width 8
333
entry .console.f1.address_span8 -textvariable address_span8 -width 8
334
checkbutton .console.f1.address_span_en1 -variable address_span_en1
335
checkbutton .console.f1.address_span_en2 -variable address_span_en2
336
checkbutton .console.f1.address_span_en3 -variable address_span_en3
337
checkbutton .console.f1.address_span_en4 -variable address_span_en4
338
checkbutton .console.f1.address_span_en5 -variable address_span_en5
339
checkbutton .console.f1.address_span_en6 -variable address_span_en6
340
checkbutton .console.f1.address_span_en7 -variable address_span_en7
341
checkbutton .console.f1.address_span_en8 -variable address_span_en8
342
pack .console.f1.incl_addr \
343
     .console.f1.address_span_en1 .console.f1.address_span1 \
344
     .console.f1.address_span_en2 .console.f1.address_span2 \
345
     .console.f1.address_span_en3 .console.f1.address_span3 \
346
     .console.f1.address_span_en4 .console.f1.address_span4 \
347
     .console.f1.address_span_en5 .console.f1.address_span5 \
348
     .console.f1.address_span_en6 .console.f1.address_span6 \
349
     .console.f1.address_span_en7 .console.f1.address_span7 \
350
     .console.f1.address_span_en8 .console.f1.address_span8 \
351
     -side left -ipadx 0
352 2 ash_riple
 
353
# set the exclusive address entries
354
frame .console.f2 -relief groove -borderwidth 5
355
pack .console.f2
356 6 ash_riple
label .console.f2.excl_addr -text {Exclusive Addr:}
357
entry .console.f2.address_span9  -textvariable address_span9  -width 8
358
entry .console.f2.address_span10 -textvariable address_span10 -width 8
359
entry .console.f2.address_span11 -textvariable address_span11 -width 8
360
entry .console.f2.address_span12 -textvariable address_span12 -width 8
361
entry .console.f2.address_span13 -textvariable address_span13 -width 8
362
entry .console.f2.address_span14 -textvariable address_span14 -width 8
363
entry .console.f2.address_span15 -textvariable address_span15 -width 8
364
entry .console.f2.address_span16 -textvariable address_span16 -width 8
365
checkbutton .console.f2.address_span_en9  -variable address_span_en9
366
checkbutton .console.f2.address_span_en10 -variable address_span_en10
367
checkbutton .console.f2.address_span_en11 -variable address_span_en11
368
checkbutton .console.f2.address_span_en12 -variable address_span_en12
369
checkbutton .console.f2.address_span_en13 -variable address_span_en13
370
checkbutton .console.f2.address_span_en14 -variable address_span_en14
371
checkbutton .console.f2.address_span_en15 -variable address_span_en15
372
checkbutton .console.f2.address_span_en16 -variable address_span_en16
373
pack .console.f2.excl_addr \
374
     .console.f2.address_span_en9  .console.f2.address_span9  \
375
     .console.f2.address_span_en10 .console.f2.address_span10 \
376
     .console.f2.address_span_en11 .console.f2.address_span11 \
377
     .console.f2.address_span_en12 .console.f2.address_span12 \
378
     .console.f2.address_span_en13 .console.f2.address_span13 \
379
     .console.f2.address_span_en14 .console.f2.address_span14 \
380
     .console.f2.address_span_en15 .console.f2.address_span15 \
381
     .console.f2.address_span_en16 .console.f2.address_span16 \
382
     -side left -ipadx 0
383
initAddrConfig
384
 
385
# set the address configuration buttons
386
frame .console.addr_cnfg -relief groove -borderwidth 5
387
pack .console.addr_cnfg
388
checkbutton .console.addr_cnfg.wren -text {WR} -variable addr_wren
389
checkbutton .console.addr_cnfg.rden -text {RD} -variable addr_rden
390
button .console.addr_cnfg.config -text {Apply Address Filter} -command {updateAddrConfig}
391
pack .console.addr_cnfg.wren .console.addr_cnfg.rden .console.addr_cnfg.config \
392
     -side left -ipadx 0
393
 
394 2 ash_riple
# set the transaction trigger controls
395 6 ash_riple
frame .console.trig -relief groove -borderwidth 5
396
pack .console.trig
397
button .console.trig.starttrig -text {Apply Trigger Condition} -command {startTrigger}
398
entry .console.trig.trigvalue_addr -textvar triggerAddr -width 4
399
entry .console.trig.trigvalue_data -textvar triggerData -width 8
400
checkbutton .console.trig.trigaddr -text {@Addr:} -variable trig_aden
401
checkbutton .console.trig.trigdata -text {@Data:} -variable trig_daen
402
checkbutton .console.trig.wren -text {@WR} -variable trig_wren
403
checkbutton .console.trig.rden -text {@RD} -variable trig_rden
404 11 ash_riple
label .console.trig.pnum -text {Pre-Capture:}
405
entry .console.trig.trigvalue_pnum -textvar triggerPnum -width 4
406
pack .console.trig.pnum .console.trig.trigvalue_pnum \
407
     .console.trig.wren .console.trig.rden \
408 6 ash_riple
     .console.trig.trigaddr .console.trig.trigvalue_addr \
409
     .console.trig.trigdata .console.trig.trigvalue_data \
410
     .console.trig.starttrig \
411
     -side left -ipadx 0
412 11 ash_riple
initTrigConfig
413 2 ash_riple
 
414
# set the control buttons
415 6 ash_riple
frame .console.fifo -relief groove -borderwidth 5
416
pack .console.fifo
417
button .console.fifo.reset -text {Reset FIFO} -command {reset_fifo_ptr}
418
button .console.fifo.loop -text {Query Used Word} -command {query_fifo_usedw}
419
label .console.fifo.usedw  -textvariable fifoUsedw -relief sunken -width 4
420
button .console.fifo.read       -text {Read FIFO} -command {read_fifo_content}
421
button .console.fifo.clear -text {Clear Log} -command {clear_log}
422
button .console.fifo.quit -text {Quit} -command {quit}
423
pack .console.fifo.reset .console.fifo.loop .console.fifo.usedw .console.fifo.read .console.fifo.clear .console.fifo.quit \
424
     -side left -ipadx 0
425 2 ash_riple
 
426
# set the log window
427
frame .console.log -relief groove -borderwidth 5
428 6 ash_riple
set log [text .console.log.text -width 80 -height 25 \
429 2 ash_riple
        -borderwidth 2 -relief sunken -setgrid true \
430
        -yscrollcommand {.console.log.scroll set}]
431
scrollbar .console.log.scroll -command {.console.log.text yview}
432
pack .console.log.scroll -side right -fill y
433
pack .console.log.text -side left -fill both -expand true
434
pack .console.log -side top -fill both -expand true
435
 
436
# make the program wait for exit signal
437
vwait exit_console
438
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.