-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathxlreg
453 lines (389 loc) · 11.8 KB
/
xlreg
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
define set_node_type
sysreg read $tap 1 0x0
set $version = $sysregval & 0xff
set $revision = ($sysregval >> 8) & 0xff
set $identifier = ($sysregval >> 24) & 0xff
set $is_xs1g = 0
set $is_analog_node = 0
if ($version == 0 && $identifier == 0)
set $is_xs1g = 1
else
if ($version == 0 && $identifier == 0xf)
set $is_analog_node = 1
end
end
end
define xlreg_node
set_node_type
if ($is_analog_node)
printf "Analog Tile (Tap %d)\n", $tap
printf " SSwitch\n"
else
printf "Node #%d (Tap %d)\n", $node, $tap
printf " SSwitch\n"
sysreg read $tap 1 0x5
printf " Node id 0x%04x\n", $sysregval
if (!$is_xs1g)
sysreg read $tap 1 0x6
set $pllod = ($sysregval) >> 23 & 0x7
set $pllf = ($sysregval) >> 8 & 0x7FF
set $pllr = ($sysregval) >> 0 & 0x7F
set $pllratio = ((float)$pllf+1)/2/($pllr+1)/($pllod+1)
printf " PLL reg 0x%08x [OD=%d+1 F=(%d+1)/2 R=%d+1]\n ratio %f [%d/%d/%d @20/24/25 Mhz]\n", $sysregval, $pllod, $pllf, $pllr, $pllratio, 20*$pllratio, 24 * $pllratio, 25*$pllratio
end
sysreg read $tap 1 0x0
set $bootconfig = ( $sysregval >> 16 ) & 0xff
printf " BootMode: "
showbootconfig($bootconfig)
end
if ($is_analog_node)
set $num_plinks_per_tile = 0
set $num_tiles = 0
set $num_xlinks = 1
else
sysreg read $tap 1 0x1
set $num_plinks_per_tile = ($sysregval) & 0xff
set $num_tiles = ($sysregval >> 8) & 0xff
set $num_xlinks = ($sysregval >> 16) & 0xff
end
set $num_plinks = $num_tiles * $num_plinks_per_tile
if (!$is_xs1g && !$is_analog_node)
sysreg read $tap 1 0xc
set $dir1 = $sysregval
sysreg read $tap 1 0xd
set $dir2 = $sysregval
printf " Dirs: %08x%08x\n", $dir2, $dir1
end
set $linknum = 0
while ($linknum < $num_xlinks)
if (!$is_analog_node)
set $regnum = 0x20 + $linknum
sysreg read $tap 1 $regnum
set $srcinuse = ($sysregval >> 0) & 1
set $dstinuse = ($sysregval >> 1) & 1
set $junked = ($sysregval >> 2) & 1
set $network = ($sysregval >> 4) & 0x3
set $direction = ($sysregval >> 8) & 0xff
set $srctargetid = ($sysregval >> 17) & 0xff
set $srctargettype = ($sysregval >> 25) & 0x3
end
set $regnum = 0x80 + $linknum
sysreg read $tap 1 $regnum
if ($is_xs1g)
set $t1 = ( $sysregval ) & 0xf
set $t2 = ( $sysregval >> 4 ) & 0xf
else
set $t1 = ( $sysregval ) & 0x7ff
set $t2 = ( $sysregval >> 11 ) & 0x7ff
set $cansend = ( $sysregval >> 25 ) & 0x1
set $canrecv = ( $sysregval >> 26 ) & 0x1
end
if ($is_analog_node)
set $width = 1
set $enabled = 1
else
set $width = ( $sysregval >> 30 ) & 0x1
set $enabled = ( $sysregval >> 31 ) & 0x1
end
printf " Link %d ", $linknum
if ($enabled == 1)
if (!$is_analog_node)
printf " siu:"
showbool $srcinuse
printf " diu:"
showbool $dstinuse
printf " junk:"
showbool $junked
printf " net:%d", $network
printf " srctargetid:%u srctargettype:%u", $srctargetid, $srctargettype
printf "d:%d ", $direction
end
printf " %dw ", ($width==0)?2:5
printf "%d/%d ", $t1, $t2
if (!$is_xs1g)
printf "snd:"
showbool $cansend
printf " rec:"
showbool $canrecv
end
else
printf " not enabled"
end
printf "\n"
set $linknum = $linknum + 1
end
set $linknum = 0
while ($linknum < $num_plinks)
set $regnum = 0x40 + $linknum
sysreg read $tap 1 $regnum
set $srcinuse = ($sysregval >> 0) & 1
set $dstinuse = ($sysregval >> 1) & 1
set $junked = ($sysregval >> 2) & 1
set $network = ($sysregval >> 4) & 0x3
set $srctargetid = ($sysregval >> 16) & 0xff
set $srctargettype = ($sysregval >> 24) & 0x3
printf " PLink %d", $linknum
printf " siu:"
showbool $srcinuse
printf " diu:"
showbool $dstinuse
printf " junk:"
showbool $junked
printf " net:%d", $network
printf " srctargetid:%u srctargettype:%u", $srctargetid, $srctargettype
set $linknum = $linknum + 1
printf "\n"
end
set $tilenum = 0
while ($tilenum < $num_tiles)
printf " PSwitch %d\n", $tilenum
set $linknum = 0
while ($linknum < $num_plinks_per_tile)
set $regnum = 0x10 + $linknum
sysreg read $tap 2 + tilenum $regnum
set $srcinuse = ($sysregval >> 0) & 1
set $dstinuse = ($sysregval >> 1) & 1
set $junked = ($sysregval >> 2) & 1
set $network = ($sysregval >> 4) & 0x3
set $srctargetid = ($sysregval >> 16) & 0xff
set $srctargettype = ($sysregval >> 24) & 0x3
printf " PLink %d", $linknum
printf " siu:"
showbool $srcinuse
printf " diu:"
showbool $dstinuse
printf " junk:"
showbool $junked
printf " net:%d", $network
printf " srctargetid:%u srctargettype:%u", $srctargetid, $srctargettype
set $linknum = $linknum + 1
printf "\n"
end
set $tilenum = $tilenum + 1
end
end
define jtag_chain_node_iterate
set_node_type
if ($is_analog_node)
set $tap = $tap + 1
else
set $tap = $tap + 2
end
end
define xlreg_discover_loop
set_node_type
# Skip analog nodes
while ($is_analog_node)
set $num_nodes = $num_nodes + 1
jtag_chain_node_iterate
set_node_type
end
sysreg read $tap 1 0x1
set $tiles_per_node = ($sysregval >> 8) & 0xff
set $tile_count = $tile_count + 1
if ($tile_count >= $tiles_per_node)
set $num_nodes = $num_nodes + 1
jtag_chain_node_iterate
set $tile_count = 0
end
end
define get_tap_for_node
set $tap = 0
set $node_index = 0
while ($node_index < $node)
jtag_chain_node_iterate
set $node_index = $node_index + 1
end
end
define xlreg_L_series
set $tap = 0
set $tile_count = 0
set $num_nodes = 0
xcore apply all xlreg_discover_loop
set $node = 0
while ($node < $num_nodes)
get_tap_for_node
xlreg_node
set $node = $node + 1
end
end
define xlreg_200
set $num_tiles = 0
xcore apply all set $num_tiles = $num_tiles + 1
set $num_nodes = $num_tiles / 2
set $sswitch = 1
set $tile0 = 2
set $tile1 = 3
set $node = 0
while ($num_nodes > 0)
printf "\n"
printf "Node 0x%04x\n", $node
sysreg read $node $sswitch 0x5
printf " Routing ID 0x%04x\n", $sysregval
sysreg read $node $sswitch 0x6
set $pllod = ($sysregval) >> 23 & 0x7
set $pllf = ($sysregval) >> 8 & 0x7FF
set $pllr = ($sysregval) >> 0 & 0x7F
set $pllratio = ((float)$pllf+1)/2/($pllr+1)/($pllod+1)
printf " PLL reg 0x%08x [OD=%d+1 F=(%d+1)/2 R=%d+1]\n ratio %f [%d/%d/%d @20/24/25 Mhz]\n", $sysregval, $pllod, $pllf, $pllr, $pllratio, 20*$pllratio, 24 * $pllratio, 25*$pllratio
sysreg read $node $sswitch 0x8
printf " Reference Clock Divider 0x%04x\n", $sysregval
sysreg read $node $sswitch 0x0
set $bootmode = ( $sysregval >> 16 ) & 0xff
printf " BootMode : 0x%04x\n", $bootmode
sysreg read $node $sswitch 0xc
set $dir1 = $sysregval
sysreg read $node $sswitch 0xd
set $dir2 = $sysregval
printf " Dirs: %08x%08x\n", $dir2, $dir1
set $linknum = 0
while( $linknum < 9 )
set $regnum = 0x20 + $linknum
sysreg read $node 1 $regnum
set $direction = ( $sysregval >> 8 ) & 0xff
set $srcinuse = ( $sysregval >> 0 ) & 1
set $dstinuse = ( $sysregval >> 1 ) & 1
set $junked = ( $sysregval >> 2 ) & 1
set $network = ( $sysregval >> 4 ) & 0x3
set $srctargetid = ( $sysregval >> 17 ) & 0xff
set $srctargettype = ( $sysregval >> 25 ) & 0x3
set $regnum = 0x80 + $linknum
sysreg read $node 1 $regnum
set $t1 = ( $sysregval ) & 0x7ff
set $t2 = ( $sysregval >> 11 ) & 0x7ff
set $cansend = ( $sysregval >> 25 ) & 0x1
set $canrecv = ( $sysregval >> 26 ) & 0x1
set $width = ( $sysregval >> 30 ) & 0x1
set $enabled = ( $sysregval >> 31 ) & 0x1
printf " Link %d ", $linknum
if( $enabled == 1 )
printf " siu:"
showbool $srcinuse
printf " diu:"
showbool $dstinuse
printf " junk:"
showbool $junked
printf " net:%d", $network
printf " srctargetid:%u srctargettype:%u", $srctargetid, $srctargettype
printf " %dw ", ($width==0)?2:5
printf "%d/%d ", $t1, $t2
printf "d:%d ", $direction
printf "snd:"
showbool $cansend
printf " rec:"
showbool $canrecv
else
printf " not enabled"
end
printf "\n"
set $linknum = $linknum + 1
end
set $tile = 0
while ($tile < 2)
if ($tile == 0)
set $tileoffset = $tile0
set $startregnum = 0x40
else
set $tileoffset = $tile1
set $startregnum = 0x44
end
sysreg read $node $sswitch 0x5
printf " Tile routing ID 0x%04x\n", $sysregval | $tile
set $regnum = 0x06
sysreg read $node $tileoffset $regnum
printf " PLL clock divider %d\n", $sysregval
set $linknum = 0
while( $linknum < 4 )
set $regnum = $startregnum + $linknum
sysreg read $node $sswitch $regnum
set $srcinuse = ( $sysregval >> 0 ) & 1
set $dstinuse = ( $sysregval >> 1 ) & 1
set $junked = ( $sysregval >> 2 ) & 1
set $network = ( $sysregval >> 4 ) & 0x3
set $srctargetid = ( $sysregval >> 16 ) & 0xff
set $srctargettype = ( $sysregval >> 24 ) & 0x3
printf " PLink %d", $linknum
printf " siu:"
showbool $srcinuse
printf " diu:"
showbool $dstinuse
printf " junk:"
showbool $junked
printf " net:%d", $network
printf " srctargetid:%u srctargettype:%u", $srctargetid, $srctargettype
set $linknum = $linknum + 1
printf "\n"
end
set $tile = $tile + 1
end
set $node = $node + 1
set $num_nodes = $num_nodes - 1
end
end
define xlreg
set $xCOREL = 0x2633
set $xCORE200 = 0x5633
set $chiptap = 8
sysreg read 0 $chiptap 0x3
if ($sysregval == $xCOREL)
xlreg_L_series
end
if ($sysregval == $xCORE200)
xlreg_200
end
end
define showbool
set $bool = ($arg0)
if( $bool == 0 )
printf "F"
else
printf "T"
end
end
define showbootconfig
set $bootconfig = ($arg0)
# Display raw value.
printf "0x%02x", $bootconfig
if ($is_xs1g)
# TODO
else
# Extract bootmode
set $bootmode = ($bootconfig >> 2) & 0x1f
if ($bootmode == 0)
printf " (JTAG)"
else
if ($bootmode == 1)
printf " (Test)"
else
if ($bootmode == 2)
printf " (Channels, enabling internal links only)"
else
if ($bootmode == 3)
printf " (Channels, enabling internal links only)"
else
if ($bootmode == 4)
printf " (JTAG)"
else
if ($bootmode == 5)
printf " (Test)"
else
if ($bootmode == 6)
printf " (Channels, enabling internal links and XLB)"
else
if ($bootmode == 7)
printf " (SPI)"
else
if ($bootmode == 8)
printf " (RAM)"
end
end
end
end
end
end
end
end
end
end
printf "\n"
end