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 17

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 17 ash_riple
        global log
243
        if {[expr $trig_wren+$trig_rden]==2} {
244
                $log insert end "\nWarning: @WR & @RD, unreachable trigger condition.\n"
245
        }
246 6 ash_riple
        set trigEnable [expr $trig_wren+$trig_rden+$trig_aden+$trig_daen]
247
        if {$trigEnable>0} {
248
                updateTrigger 2
249
                reset_fifo 0
250
                query_usedw 0
251
                updateTrigger 3
252
        } else {
253
                updateTrigger 0
254
        }
255 2 ash_riple
}
256
 
257
proc reset_fifo_ptr {} {
258
        reset_fifo 0
259
        query_usedw 0
260
}
261
 
262
proc query_fifo_usedw {} {
263
        query_usedw 0
264
}
265
 
266
proc read_fifo_content {} {
267
        global log
268
        global fifoUsedw
269
        $log insert end "\n****************************************\n"
270
        for {set i 0} {$i<$fifoUsedw} {incr i} {
271
                set fifoContent [read_fifo 0]
272 6 ash_riple
                set ok_trig [expr [format "%d" 0x[string index $fifoContent 0]]/2]
273
                set wr_cptr [expr [format "%d" 0x[string index $fifoContent 0]]%2]
274 12 ash_riple
                set tm_cptr [format "%d"       0x[string range $fifoContent  1  8]]
275
                set ad_cptr                      [string range $fifoContent  9 12]
276
                set da_cptr                      [string range $fifoContent 13 20]
277 6 ash_riple
                if $ok_trig {
278
                        $log insert end "@@@@@@@@@@@@@@@@@@@@\n"
279
                }
280
                if $wr_cptr {
281 12 ash_riple
                        $log insert end "wr $ad_cptr $da_cptr @$tm_cptr\n"
282 6 ash_riple
                } else {
283 12 ash_riple
                        $log insert end "rd $ad_cptr $da_cptr @$tm_cptr\n"
284 6 ash_riple
                }
285 2 ash_riple
        }
286
        query_usedw 0
287
}
288
 
289
proc clear_log {} {
290
        global log
291
        $log delete insert end
292
}
293
 
294
proc quit {} {
295
        global exit_console
296
        destroy .console
297
        set exit_console 1
298
}
299
 
300
# set the QuartusII special Tk command
301
init_tk
302
set exit_console 0
303
 
304
# set the main window
305
toplevel .console
306 6 ash_riple
wm title .console "www.OpenCores.org: uP Transaction Monitor"
307 2 ash_riple
pack propagate .console true
308
 
309 6 ash_riple
# set the www.OpenCores.org logo
310 2 ash_riple
frame .console.fig -bg white
311
pack .console.fig -expand true -fill both
312 6 ash_riple
image create photo logo -format gif -file "../common/OpenCores.gif"
313
label .console.fig.logo -image logo -bg white
314
pack .console.fig.logo
315 2 ash_riple
 
316 6 ash_riple
# set the JTAG utility
317
frame .console.jtag -relief groove -borderwidth 5
318
pack .console.jtag
319
button .console.jtag.scan -text {Scan JTAG Chain} -command {scan_chain}
320
button .console.jtag.select -text {Select JTAG Device :} -command {select_device $cableNum $deviceNum}
321
button .console.jtag.deselect -text {DeSelect JTAG Device} -command {close_jtag_device}
322
label .console.jtag.cable -text {Cable @}
323
label .console.jtag.devic -text {Device @}
324
entry .console.jtag.cable_num -textvariable cableNum -width 5
325
entry .console.jtag.devic_num -textvariable deviceNum -width 5
326
pack .console.jtag.scan .console.jtag.select \
327
     .console.jtag.cable .console.jtag.cable_num \
328
     .console.jtag.devic .console.jtag.devic_num \
329
     .console.jtag.deselect \
330
     -side left -ipadx 0
331 2 ash_riple
 
332
# set the inclusive address entries
333
frame .console.f1 -relief groove -borderwidth 5
334
pack .console.f1
335 6 ash_riple
label .console.f1.incl_addr -text {Inclusive Addr:}
336
entry .console.f1.address_span1 -textvariable address_span1 -width 8
337
entry .console.f1.address_span2 -textvariable address_span2 -width 8
338
entry .console.f1.address_span3 -textvariable address_span3 -width 8
339
entry .console.f1.address_span4 -textvariable address_span4 -width 8
340
entry .console.f1.address_span5 -textvariable address_span5 -width 8
341
entry .console.f1.address_span6 -textvariable address_span6 -width 8
342
entry .console.f1.address_span7 -textvariable address_span7 -width 8
343
entry .console.f1.address_span8 -textvariable address_span8 -width 8
344
checkbutton .console.f1.address_span_en1 -variable address_span_en1
345
checkbutton .console.f1.address_span_en2 -variable address_span_en2
346
checkbutton .console.f1.address_span_en3 -variable address_span_en3
347
checkbutton .console.f1.address_span_en4 -variable address_span_en4
348
checkbutton .console.f1.address_span_en5 -variable address_span_en5
349
checkbutton .console.f1.address_span_en6 -variable address_span_en6
350
checkbutton .console.f1.address_span_en7 -variable address_span_en7
351
checkbutton .console.f1.address_span_en8 -variable address_span_en8
352
pack .console.f1.incl_addr \
353
     .console.f1.address_span_en1 .console.f1.address_span1 \
354
     .console.f1.address_span_en2 .console.f1.address_span2 \
355
     .console.f1.address_span_en3 .console.f1.address_span3 \
356
     .console.f1.address_span_en4 .console.f1.address_span4 \
357
     .console.f1.address_span_en5 .console.f1.address_span5 \
358
     .console.f1.address_span_en6 .console.f1.address_span6 \
359
     .console.f1.address_span_en7 .console.f1.address_span7 \
360
     .console.f1.address_span_en8 .console.f1.address_span8 \
361
     -side left -ipadx 0
362 2 ash_riple
 
363
# set the exclusive address entries
364
frame .console.f2 -relief groove -borderwidth 5
365
pack .console.f2
366 6 ash_riple
label .console.f2.excl_addr -text {Exclusive Addr:}
367
entry .console.f2.address_span9  -textvariable address_span9  -width 8
368
entry .console.f2.address_span10 -textvariable address_span10 -width 8
369
entry .console.f2.address_span11 -textvariable address_span11 -width 8
370
entry .console.f2.address_span12 -textvariable address_span12 -width 8
371
entry .console.f2.address_span13 -textvariable address_span13 -width 8
372
entry .console.f2.address_span14 -textvariable address_span14 -width 8
373
entry .console.f2.address_span15 -textvariable address_span15 -width 8
374
entry .console.f2.address_span16 -textvariable address_span16 -width 8
375
checkbutton .console.f2.address_span_en9  -variable address_span_en9
376
checkbutton .console.f2.address_span_en10 -variable address_span_en10
377
checkbutton .console.f2.address_span_en11 -variable address_span_en11
378
checkbutton .console.f2.address_span_en12 -variable address_span_en12
379
checkbutton .console.f2.address_span_en13 -variable address_span_en13
380
checkbutton .console.f2.address_span_en14 -variable address_span_en14
381
checkbutton .console.f2.address_span_en15 -variable address_span_en15
382
checkbutton .console.f2.address_span_en16 -variable address_span_en16
383
pack .console.f2.excl_addr \
384
     .console.f2.address_span_en9  .console.f2.address_span9  \
385
     .console.f2.address_span_en10 .console.f2.address_span10 \
386
     .console.f2.address_span_en11 .console.f2.address_span11 \
387
     .console.f2.address_span_en12 .console.f2.address_span12 \
388
     .console.f2.address_span_en13 .console.f2.address_span13 \
389
     .console.f2.address_span_en14 .console.f2.address_span14 \
390
     .console.f2.address_span_en15 .console.f2.address_span15 \
391
     .console.f2.address_span_en16 .console.f2.address_span16 \
392
     -side left -ipadx 0
393
initAddrConfig
394
 
395
# set the address configuration buttons
396
frame .console.addr_cnfg -relief groove -borderwidth 5
397
pack .console.addr_cnfg
398
checkbutton .console.addr_cnfg.wren -text {WR} -variable addr_wren
399
checkbutton .console.addr_cnfg.rden -text {RD} -variable addr_rden
400
button .console.addr_cnfg.config -text {Apply Address Filter} -command {updateAddrConfig}
401
pack .console.addr_cnfg.wren .console.addr_cnfg.rden .console.addr_cnfg.config \
402
     -side left -ipadx 0
403
 
404 2 ash_riple
# set the transaction trigger controls
405 6 ash_riple
frame .console.trig -relief groove -borderwidth 5
406
pack .console.trig
407
button .console.trig.starttrig -text {Apply Trigger Condition} -command {startTrigger}
408
entry .console.trig.trigvalue_addr -textvar triggerAddr -width 4
409
entry .console.trig.trigvalue_data -textvar triggerData -width 8
410
checkbutton .console.trig.trigaddr -text {@Addr:} -variable trig_aden
411
checkbutton .console.trig.trigdata -text {@Data:} -variable trig_daen
412
checkbutton .console.trig.wren -text {@WR} -variable trig_wren
413
checkbutton .console.trig.rden -text {@RD} -variable trig_rden
414 11 ash_riple
label .console.trig.pnum -text {Pre-Capture:}
415
entry .console.trig.trigvalue_pnum -textvar triggerPnum -width 4
416
pack .console.trig.pnum .console.trig.trigvalue_pnum \
417
     .console.trig.wren .console.trig.rden \
418 6 ash_riple
     .console.trig.trigaddr .console.trig.trigvalue_addr \
419
     .console.trig.trigdata .console.trig.trigvalue_data \
420
     .console.trig.starttrig \
421
     -side left -ipadx 0
422 11 ash_riple
initTrigConfig
423 2 ash_riple
 
424
# set the control buttons
425 6 ash_riple
frame .console.fifo -relief groove -borderwidth 5
426
pack .console.fifo
427
button .console.fifo.reset -text {Reset FIFO} -command {reset_fifo_ptr}
428
button .console.fifo.loop -text {Query Used Word} -command {query_fifo_usedw}
429
label .console.fifo.usedw  -textvariable fifoUsedw -relief sunken -width 4
430
button .console.fifo.read       -text {Read FIFO} -command {read_fifo_content}
431
button .console.fifo.clear -text {Clear Log} -command {clear_log}
432
button .console.fifo.quit -text {Quit} -command {quit}
433
pack .console.fifo.reset .console.fifo.loop .console.fifo.usedw .console.fifo.read .console.fifo.clear .console.fifo.quit \
434
     -side left -ipadx 0
435 2 ash_riple
 
436
# set the log window
437
frame .console.log -relief groove -borderwidth 5
438 6 ash_riple
set log [text .console.log.text -width 80 -height 25 \
439 2 ash_riple
        -borderwidth 2 -relief sunken -setgrid true \
440
        -yscrollcommand {.console.log.scroll set}]
441
scrollbar .console.log.scroll -command {.console.log.text yview}
442
pack .console.log.scroll -side right -fill y
443
pack .console.log.text -side left -fill both -expand true
444
pack .console.log -side top -fill both -expand true
445
 
446
# make the program wait for exit signal
447
vwait exit_console
448
 

powered by: WebSVN 2.1.0

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