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 15

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

powered by: WebSVN 2.1.0

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