1 |
2 |
ash_riple |
proc reset_fifo {{jtag_index_0 0}} {
|
2 |
|
|
device_lock -timeout 10000
|
3 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 2 -no_captured_ir_value
|
4 |
|
|
device_virtual_dr_shift -instance_index $jtag_index_0 -length 32 -dr_value 00000000 -value_in_hex -no_captured_dr_value
|
5 |
|
|
device_unlock
|
6 |
|
|
return 0
|
7 |
|
|
}
|
8 |
|
|
|
9 |
|
|
proc query_usedw {{jtag_index_0 0}} {
|
10 |
|
|
global fifoUsedw
|
11 |
|
|
device_lock -timeout 10000
|
12 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
|
13 |
|
|
set usedw [device_virtual_dr_shift -instance_index $jtag_index_0 -length 9 -value_in_hex]
|
14 |
|
|
device_unlock
|
15 |
|
|
set tmp 0x
|
16 |
|
|
append tmp $usedw
|
17 |
|
|
set usedw [format "%i" $tmp]
|
18 |
|
|
set fifoUsedw $usedw
|
19 |
|
|
return $usedw
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
proc read_fifo {{jtag_index_0 0}} {
|
23 |
|
|
device_lock -timeout 10000
|
24 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
|
25 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 3 -no_captured_ir_value
|
26 |
|
|
set fifo_data [device_virtual_dr_shift -instance_index $jtag_index_0 -length 48 -value_in_hex]
|
27 |
|
|
device_unlock
|
28 |
|
|
return $fifo_data
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
proc config_addr {{jtag_index_1 1} {mask_1 100000000}} {
|
32 |
|
|
device_lock -timeout 10000
|
33 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_1 -ir_value 1 -no_captured_ir_value
|
34 |
|
|
set addr_mask [device_virtual_dr_shift -instance_index $jtag_index_1 -dr_value $mask_1 -length 36 -value_in_hex]
|
35 |
|
|
device_unlock
|
36 |
|
|
return $addr_mask
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
proc config_trig {{jtag_index_2 2} {trig_1 0000000000000}} {
|
40 |
|
|
device_lock -timeout 10000
|
41 |
|
|
device_virtual_ir_shift -instance_index $jtag_index_2 -ir_value 1 -no_captured_ir_value
|
42 |
|
|
set addr_trig [device_virtual_dr_shift -instance_index $jtag_index_2 -dr_value $trig_1 -length 50 -value_in_hex]
|
43 |
|
|
device_unlock
|
44 |
|
|
return $addr_trig
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
proc open_jtag_device {{test_cable "USB-Blaster [USB-0]"} {test_device "@2: EP2SGX90 (0x020E30DD)"}} {
|
48 |
|
|
open_device -hardware_name $test_cable -device_name $test_device
|
49 |
|
|
# Retrieve device id code.
|
50 |
|
|
device_lock -timeout 10000
|
51 |
|
|
device_ir_shift -ir_value 6 -no_captured_ir_value
|
52 |
|
|
set idcode "0x[device_dr_shift -length 32 -value_in_hex]"
|
53 |
|
|
device_unlock
|
54 |
|
|
return $idcode
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
proc close_jtag_device {} {
|
58 |
|
|
close_device
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
proc scan_chain {} {
|
62 |
|
|
global log
|
63 |
|
|
$log insert end "JTAG Chain Scanning report:\n"
|
64 |
|
|
$log insert end "****************************************\n"
|
65 |
|
|
set blaster_cables [get_hardware_names]
|
66 |
|
|
set cable_num 0
|
67 |
|
|
foreach blaster_cable $blaster_cables {
|
68 |
|
|
incr cable_num
|
69 |
|
|
$log insert end "@$cable_num: $blaster_cable\n"
|
70 |
|
|
}
|
71 |
|
|
$log insert end "\n****************************************\n"
|
72 |
|
|
global device_list
|
73 |
|
|
set device_list ""
|
74 |
|
|
foreach blaster_cable $blaster_cables {
|
75 |
|
|
$log insert end "$blaster_cable:\n"
|
76 |
|
|
lappend device_list $blaster_cable
|
77 |
|
|
if [catch {get_device_names -hardware_name $blaster_cable} error_msg] {
|
78 |
|
|
$log insert end $error_msg
|
79 |
|
|
lappend device_list $error_msg
|
80 |
|
|
} else {
|
81 |
|
|
foreach test_device [get_device_names -hardware_name $blaster_cable] {
|
82 |
|
|
$log insert end "$test_device\n"
|
83 |
|
|
}
|
84 |
|
|
lappend device_list [get_device_names -hardware_name $blaster_cable]
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
proc select_device {{cableNum 1} {deviceNum 1}} {
|
90 |
|
|
global log
|
91 |
|
|
global device_list
|
92 |
|
|
$log insert end "\n****************************************\n"
|
93 |
|
|
set test_cable [lindex $device_list [expr 2*$cableNum-2]]
|
94 |
|
|
$log insert end "Selected Cable : $test_cable\n"
|
95 |
|
|
set test_device [lindex [lindex $device_list [expr 2*$cableNum-1]] [expr $deviceNum-1]]
|
96 |
|
|
$log insert end "Selected Device: $test_device\n"
|
97 |
|
|
set jtagIdCode [open_jtag_device $test_cable $test_device]
|
98 |
|
|
$log insert end "Device ID code : $jtagIdCode\n"
|
99 |
|
|
updateAddrConfig
|
100 |
|
|
reset_fifo 0
|
101 |
|
|
query_usedw 0
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
proc inclusiveAddrConfig {} {
|
105 |
|
|
global address_span1
|
106 |
|
|
global address_span2
|
107 |
|
|
global address_span3
|
108 |
|
|
global address_span4
|
109 |
|
|
global address_span5
|
110 |
|
|
global address_span6
|
111 |
|
|
global address_span7
|
112 |
|
|
global address_span8
|
113 |
|
|
for {set i 1} {$i<=8} {incr i} {
|
114 |
|
|
set mask [format "%1X" [expr $i-1]]
|
115 |
|
|
append mask [set address_span$i]
|
116 |
|
|
config_addr 1 $mask
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
proc exclusiveAddrConfig {} {
|
121 |
|
|
global address_span9
|
122 |
|
|
global address_span10
|
123 |
|
|
global address_span11
|
124 |
|
|
global address_span12
|
125 |
|
|
global address_span13
|
126 |
|
|
global address_span14
|
127 |
|
|
global address_span15
|
128 |
|
|
global address_span16
|
129 |
|
|
for {set i 9} {$i<=16} {incr i} {
|
130 |
|
|
set mask [format "%1X" [expr $i-1]]
|
131 |
|
|
append mask [set address_span$i]
|
132 |
|
|
config_addr 1 $mask
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
proc updateAddrConfig {} {
|
137 |
|
|
global log
|
138 |
|
|
global address_span1
|
139 |
|
|
global address_span2
|
140 |
|
|
global address_span3
|
141 |
|
|
global address_span4
|
142 |
|
|
global address_span5
|
143 |
|
|
global address_span6
|
144 |
|
|
global address_span7
|
145 |
|
|
global address_span8
|
146 |
|
|
global address_span9
|
147 |
|
|
global address_span10
|
148 |
|
|
global address_span11
|
149 |
|
|
global address_span12
|
150 |
|
|
global address_span13
|
151 |
|
|
global address_span14
|
152 |
|
|
global address_span15
|
153 |
|
|
global address_span16
|
154 |
|
|
for {set i 1} {$i<=8} {incr i} {
|
155 |
|
|
set address_span$i ffff0000
|
156 |
|
|
}
|
157 |
|
|
for {set i 9} {$i<=16} {incr i} {
|
158 |
|
|
set address_span$i 00000000
|
159 |
|
|
}
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
proc enableTrigger {} {
|
163 |
|
|
global triggerAddr
|
164 |
|
|
global triggerData
|
165 |
|
|
# enable but stop triggering
|
166 |
|
|
set triggerValue 2
|
167 |
|
|
append triggerValue $triggerAddr
|
168 |
|
|
append triggerValue $triggerData
|
169 |
|
|
config_trig 2 $triggerValue
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
proc disableTrigger {} {
|
173 |
|
|
global triggerAddr
|
174 |
|
|
global triggerData
|
175 |
|
|
# disable and stop triggering
|
176 |
|
|
set triggerValue 0
|
177 |
|
|
append triggerValue $triggerAddr
|
178 |
|
|
append triggerValue $triggerData
|
179 |
|
|
config_trig 2 $triggerValue
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
proc startTrigger {} {
|
183 |
|
|
global triggerAddr
|
184 |
|
|
global triggerData
|
185 |
|
|
# enable and start triggering
|
186 |
|
|
set triggerValue 3
|
187 |
|
|
append triggerValue $triggerAddr
|
188 |
|
|
append triggerValue $triggerData
|
189 |
|
|
config_trig 2 $triggerValue
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
proc stopTrigger {} {
|
193 |
|
|
global triggerAddr
|
194 |
|
|
global triggerData
|
195 |
|
|
# enable and stop triggering
|
196 |
|
|
set triggerValue 2
|
197 |
|
|
append triggerValue $triggerAddr
|
198 |
|
|
append triggerValue $triggerData
|
199 |
|
|
config_trig 2 $triggerValue
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
proc reset_fifo_ptr {} {
|
203 |
|
|
reset_fifo 0
|
204 |
|
|
query_usedw 0
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
proc query_fifo_usedw {} {
|
208 |
|
|
query_usedw 0
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
proc read_fifo_content {} {
|
212 |
|
|
global log
|
213 |
|
|
global fifoUsedw
|
214 |
|
|
$log insert end "\n****************************************\n"
|
215 |
|
|
for {set i 0} {$i<$fifoUsedw} {incr i} {
|
216 |
|
|
set fifoContent [read_fifo 0]
|
217 |
|
|
$log insert end "wr [string range $fifoContent 0 3] [string range $fifoContent 4 11]\n"
|
218 |
|
|
}
|
219 |
|
|
query_usedw 0
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
proc clear_log {} {
|
223 |
|
|
global log
|
224 |
|
|
$log delete insert end
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
proc quit {} {
|
228 |
|
|
global exit_console
|
229 |
|
|
destroy .console
|
230 |
|
|
set exit_console 1
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
# set the QuartusII special Tk command
|
234 |
|
|
init_tk
|
235 |
|
|
set exit_console 0
|
236 |
|
|
|
237 |
|
|
# set the main window
|
238 |
|
|
toplevel .console
|
239 |
|
|
wm title .console "Virtual JTAG: uP transaction monitor"
|
240 |
|
|
pack propagate .console true
|
241 |
|
|
|
242 |
|
|
# set the JTAG utility
|
243 |
|
|
frame .console.fig -bg white
|
244 |
|
|
pack .console.fig -expand true -fill both
|
245 |
|
|
|
246 |
|
|
button .console.fig.scan -text {Scan JTAG Chain} -command {scan_chain}
|
247 |
|
|
button .console.fig.select -text {Select JTAG Device :} -command {select_device $cableNum $deviceNum}
|
248 |
|
|
button .console.fig.deselect -text {DeSelect JTAG Device} -command {close_jtag_device}
|
249 |
|
|
label .console.fig.cable -text {Cable No.}
|
250 |
|
|
label .console.fig.devic -text {Device No.}
|
251 |
|
|
entry .console.fig.cable_num -textvariable cableNum -width 2
|
252 |
|
|
entry .console.fig.devic_num -textvariable deviceNum -width 2
|
253 |
|
|
pack .console.fig.scan .console.fig.select \
|
254 |
|
|
.console.fig.cable .console.fig.cable_num \
|
255 |
|
|
.console.fig.devic .console.fig.devic_num \
|
256 |
|
|
.console.fig.deselect \
|
257 |
|
|
-side left -ipadx 10
|
258 |
|
|
|
259 |
|
|
# set the inclusive address entries
|
260 |
|
|
frame .console.f1 -relief groove -borderwidth 5
|
261 |
|
|
pack .console.f1
|
262 |
|
|
entry .console.f1.address_span1 -textvariable address_span1 -width 5
|
263 |
|
|
entry .console.f1.address_span2 -textvariable address_span2 -width 5
|
264 |
|
|
entry .console.f1.address_span3 -textvariable address_span3 -width 5
|
265 |
|
|
entry .console.f1.address_span4 -textvariable address_span4 -width 5
|
266 |
|
|
entry .console.f1.address_span5 -textvariable address_span5 -width 5
|
267 |
|
|
entry .console.f1.address_span6 -textvariable address_span6 -width 5
|
268 |
|
|
entry .console.f1.address_span7 -textvariable address_span7 -width 5
|
269 |
|
|
entry .console.f1.address_span8 -textvariable address_span8 -width 5
|
270 |
|
|
button .console.f1.config -text {Included Address Filter} -command {inclusiveAddrConfig}
|
271 |
|
|
pack .console.f1.address_span1 .console.f1.address_span2 .console.f1.address_span3 .console.f1.address_span4 \
|
272 |
|
|
.console.f1.address_span5 .console.f1.address_span6 .console.f1.address_span7 .console.f1.address_span8 \
|
273 |
|
|
.console.f1.config -side left -ipadx 10
|
274 |
|
|
|
275 |
|
|
# set the exclusive address entries
|
276 |
|
|
frame .console.f2 -relief groove -borderwidth 5
|
277 |
|
|
pack .console.f2
|
278 |
|
|
entry .console.f2.address_span9 -textvariable address_span9 -width 5
|
279 |
|
|
entry .console.f2.address_span10 -textvariable address_span10 -width 5
|
280 |
|
|
entry .console.f2.address_span11 -textvariable address_span11 -width 5
|
281 |
|
|
entry .console.f2.address_span12 -textvariable address_span12 -width 5
|
282 |
|
|
entry .console.f2.address_span13 -textvariable address_span13 -width 5
|
283 |
|
|
entry .console.f2.address_span14 -textvariable address_span14 -width 5
|
284 |
|
|
entry .console.f2.address_span15 -textvariable address_span15 -width 5
|
285 |
|
|
entry .console.f2.address_span16 -textvariable address_span16 -width 5
|
286 |
|
|
button .console.f2.config -text {Excluded Address Filter} -command {exclusiveAddrConfig}
|
287 |
|
|
pack .console.f2.address_span9 .console.f2.address_span10 .console.f2.address_span11 .console.f2.address_span12 \
|
288 |
|
|
.console.f2.address_span13 .console.f2.address_span14 .console.f2.address_span15 .console.f2.address_span16 \
|
289 |
|
|
.console.f2.config -side left -ipadx 10
|
290 |
|
|
|
291 |
|
|
# set the transaction trigger controls
|
292 |
|
|
frame .console.f3 -relief groove -borderwidth 5
|
293 |
|
|
pack .console.f3
|
294 |
|
|
button .console.f3.enabletrig -text {Enable Trigger} -command {enableTrigger}
|
295 |
|
|
button .console.f3.disabletrig -text {Disable Trigger} -command {disableTrigger}
|
296 |
|
|
button .console.f3.starttrig -text {Start Trigger} -command {startTrigger}
|
297 |
|
|
button .console.f3.stoptrig -text {Stop Trigger} -command {stopTrigger}
|
298 |
|
|
entry .console.f3.trigvalue_addr -textvar triggerAddr -width 2
|
299 |
|
|
set triggerAddr ffff
|
300 |
|
|
entry .console.f3.trigvalue_data -textvar triggerData -width 6
|
301 |
|
|
set triggerData a5a5a5a5
|
302 |
|
|
label .console.f3.trigaddr -text {@Address :}
|
303 |
|
|
label .console.f3.trigdata -text {@Data :}
|
304 |
|
|
pack .console.f3.enabletrig .console.f3.starttrig .console.f3.trigaddr .console.f3.trigvalue_addr \
|
305 |
|
|
.console.f3.trigdata .console.f3.trigvalue_data .console.f3.stoptrig .console.f3.disabletrig \
|
306 |
|
|
-side left -ipadx 8
|
307 |
|
|
|
308 |
|
|
# set the control buttons
|
309 |
|
|
frame .console.f0 -relief groove -borderwidth 5
|
310 |
|
|
pack .console.f0
|
311 |
|
|
button .console.f0.reset -text {Reset FIFO} -command {reset_fifo_ptr}
|
312 |
|
|
button .console.f0.loop -text {Query Used Word} -command {query_fifo_usedw}
|
313 |
|
|
label .console.f0.usedw -textvariable fifoUsedw -relief sunken
|
314 |
|
|
button .console.f0.read -text {Read FIFO} -command {read_fifo_content}
|
315 |
|
|
button .console.f0.clear -text {Clear Log} -command {clear_log}
|
316 |
|
|
button .console.f0.quit -text {Quit} -command {quit}
|
317 |
|
|
pack .console.f0.reset .console.f0.loop .console.f0.usedw .console.f0.read .console.f0.clear .console.f0.quit \
|
318 |
|
|
-side left -ipadx 10
|
319 |
|
|
|
320 |
|
|
# set the log window
|
321 |
|
|
frame .console.log -relief groove -borderwidth 5
|
322 |
|
|
set log [text .console.log.text -width 80 -height 40 \
|
323 |
|
|
-borderwidth 2 -relief sunken -setgrid true \
|
324 |
|
|
-yscrollcommand {.console.log.scroll set}]
|
325 |
|
|
scrollbar .console.log.scroll -command {.console.log.text yview}
|
326 |
|
|
pack .console.log.scroll -side right -fill y
|
327 |
|
|
pack .console.log.text -side left -fill both -expand true
|
328 |
|
|
pack .console.log -side top -fill both -expand true
|
329 |
|
|
|
330 |
|
|
# make the program wait for exit signal
|
331 |
|
|
vwait exit_console
|
332 |
|
|
|