1 |
30 |
wfjm |
# $Id: test_rbtest.tcl 661 2015-04-03 18:28:41Z mueller $
|
2 |
10 |
wfjm |
#
|
3 |
30 |
wfjm |
# Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
10 |
wfjm |
#
|
5 |
|
|
# This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
# the terms of the GNU General Public License as published by the Free
|
7 |
|
|
# Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful, but
|
10 |
|
|
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
# for complete details.
|
13 |
|
|
#
|
14 |
|
|
# Revision History:
|
15 |
|
|
# Date Rev Version Comment
|
16 |
30 |
wfjm |
# 2015-04-03 661 2.1 drop estatdef; fix test 5 (wrong regs accessed)
|
17 |
28 |
wfjm |
# 2014-12-22 619 2.0 adopt to new rbd_rbmon and rlink v4
|
18 |
10 |
wfjm |
# 2011-03-27 374 1.0 Initial version
|
19 |
|
|
# 2011-03-13 369 0.1 First Draft
|
20 |
|
|
#
|
21 |
|
|
|
22 |
|
|
package provide rbmoni 1.0
|
23 |
|
|
|
24 |
|
|
package require rutiltpp
|
25 |
|
|
package require rutil
|
26 |
|
|
package require rlink
|
27 |
|
|
package require rbtest
|
28 |
|
|
|
29 |
|
|
namespace eval rbmoni {
|
30 |
|
|
#
|
31 |
|
|
# Basic tests with rbtester registers
|
32 |
|
|
#
|
33 |
|
|
proc test_rbtest {{print 0}} {
|
34 |
|
|
#
|
35 |
|
|
set errcnt 0
|
36 |
|
|
rlc errcnt -clear
|
37 |
|
|
#
|
38 |
|
|
rlc log "rbmoni::test_rbtest - init"
|
39 |
|
|
rbmoni::init
|
40 |
|
|
rbtest::init
|
41 |
|
|
#
|
42 |
|
|
set atecntl [rlc amap te.cntl]
|
43 |
28 |
wfjm |
set atestat [rlc amap te.stat]
|
44 |
|
|
set ateattn [rlc amap te.attn]
|
45 |
|
|
set atencyc [rlc amap te.ncyc]
|
46 |
10 |
wfjm |
set atedata [rlc amap te.data]
|
47 |
28 |
wfjm |
set atedinc [rlc amap te.dinc]
|
48 |
10 |
wfjm |
set atefifo [rlc amap te.fifo]
|
49 |
28 |
wfjm |
set atelnak [rlc amap te.lnak]
|
50 |
|
|
|
51 |
10 |
wfjm |
#
|
52 |
|
|
#-------------------------------------------------------------------------
|
53 |
|
|
rlc log " test 1: exercise monitor data access via data/addr regs"
|
54 |
|
|
|
55 |
28 |
wfjm |
set vtestat 0xf
|
56 |
10 |
wfjm |
set vtedata 0x1234
|
57 |
|
|
|
58 |
28 |
wfjm |
# write/read te.stat and te.data with rbmoni on; check that 4 lines aquired
|
59 |
30 |
wfjm |
rlc exec \
|
60 |
28 |
wfjm |
-wreg rm.cntl [regbld rbmoni::CNTL start] \
|
61 |
|
|
-wreg te.stat $vtestat \
|
62 |
|
|
-wreg te.data $vtedata \
|
63 |
|
|
-rreg te.stat -edata $vtestat \
|
64 |
10 |
wfjm |
-rreg te.data -edata $vtedata \
|
65 |
28 |
wfjm |
-wreg rm.cntl [regbld rbmoni::CNTL stop] \
|
66 |
|
|
-rreg rm.addr -edata [regbld rbmoni::ADDR {laddr 4}]
|
67 |
10 |
wfjm |
|
68 |
28 |
wfjm |
if {$print} {puts [print]}
|
69 |
|
|
rlc exec -wreg te.stat 0x0; # clear stat to simplify later stat tests
|
70 |
|
|
|
71 |
10 |
wfjm |
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
72 |
|
|
raw_edata edat emsk \
|
73 |
28 |
wfjm |
[list [regbld rbmoni::FLAGS ack we] $atestat $vtestat 0] \
|
74 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atedata $vtedata 0] \
|
75 |
|
|
[list [regbld rbmoni::FLAGS ack] $atestat $vtestat 0] \
|
76 |
|
|
[list [regbld rbmoni::FLAGS ack] $atedata $vtedata 0]
|
77 |
10 |
wfjm |
|
78 |
|
|
#
|
79 |
|
|
#-------------------------------------------------------------------------
|
80 |
|
|
rlc log " test 1a: read all in one rblk"
|
81 |
30 |
wfjm |
rlc exec \
|
82 |
10 |
wfjm |
-wreg rm.addr 0x0000 \
|
83 |
28 |
wfjm |
-rblk rm.data 16 -edata $edat $emsk \
|
84 |
|
|
-rreg rm.addr -edata 16
|
85 |
|
|
|
86 |
10 |
wfjm |
#
|
87 |
|
|
#-------------------------------------------------------------------------
|
88 |
|
|
rlc log " test 1b: random address with rreg"
|
89 |
28 |
wfjm |
foreach addr {0x1 0x3 0x5 0x7 0x6 0x4 0x2 0x0 \
|
90 |
|
|
0x9 0xb 0xd 0xf 0xe 0xc 0xa 0x8} {
|
91 |
30 |
wfjm |
rlc exec \
|
92 |
10 |
wfjm |
-wreg rm.addr $addr \
|
93 |
|
|
-rreg rm.data -edata [lindex $edat $addr] [lindex $emsk $addr] \
|
94 |
21 |
wfjm |
-rreg rm.addr -edata [expr {$addr + 1}]
|
95 |
10 |
wfjm |
}
|
96 |
28 |
wfjm |
|
97 |
10 |
wfjm |
#
|
98 |
|
|
#-------------------------------------------------------------------------
|
99 |
|
|
rlc log " test 1c: random address with rblk length 2"
|
100 |
28 |
wfjm |
foreach addr {0x1 0x3 0x5 0x7 0x6 0x4 0x2 0x0 \
|
101 |
|
|
0x9 0xb 0xd 0xe 0xc 0xa 0x8} {
|
102 |
30 |
wfjm |
rlc exec \
|
103 |
10 |
wfjm |
-wreg rm.addr $addr \
|
104 |
21 |
wfjm |
-rblk rm.data 2 -edata [lrange $edat $addr [expr {$addr + 1}] ] \
|
105 |
|
|
[lrange $emsk $addr [expr {$addr + 1}] ] \
|
106 |
|
|
-rreg rm.addr -edata [expr {$addr + 2}]
|
107 |
10 |
wfjm |
}
|
108 |
28 |
wfjm |
|
109 |
10 |
wfjm |
#
|
110 |
|
|
#-------------------------------------------------------------------------
|
111 |
|
|
rlc log " test 2a: test rreg,wreg capture (ncyc=0); ack, we flags"
|
112 |
|
|
set vtedata 0x4321
|
113 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
114 |
|
|
raw_edata edat emsk \
|
115 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atedata $vtedata 0] \
|
116 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atedata $vtedata 0]
|
117 |
|
|
#
|
118 |
|
|
rbmoni::start
|
119 |
30 |
wfjm |
rlc exec \
|
120 |
10 |
wfjm |
-wreg te.data $vtedata \
|
121 |
|
|
-rreg te.data -edata $vtedata
|
122 |
|
|
rbmoni::stop
|
123 |
|
|
if {$print} {puts [print]}
|
124 |
|
|
raw_check $edat $emsk
|
125 |
|
|
|
126 |
|
|
#
|
127 |
|
|
#-------------------------------------------------------------------------
|
128 |
|
|
rlc log " test 2b: test rreg,wreg capture (ncyc=1,4); busy flag and nbusy"
|
129 |
|
|
set nbusy_1 [regbld rbtest::CNTL {nbusy 1}]
|
130 |
|
|
set nbusy_4 [regbld rbtest::CNTL {nbusy 4}]
|
131 |
|
|
set vtedata 0xbeaf
|
132 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
133 |
|
|
raw_edata edat emsk \
|
134 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_1 0] \
|
135 |
|
|
[list [regbld rbmoni::FLAGS ack busy we] $atedata $vtedata 1] \
|
136 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_4 0] \
|
137 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atedata $vtedata 4] \
|
138 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
139 |
|
|
#
|
140 |
|
|
rbmoni::start
|
141 |
30 |
wfjm |
rlc exec \
|
142 |
10 |
wfjm |
-wreg te.cntl $nbusy_1 \
|
143 |
|
|
-wreg te.data $vtedata \
|
144 |
|
|
-wreg te.cntl $nbusy_4 \
|
145 |
|
|
-rreg te.data -edata $vtedata \
|
146 |
|
|
-wreg te.cntl 0
|
147 |
|
|
rbmoni::stop
|
148 |
|
|
if {$print} {puts [print]}
|
149 |
|
|
raw_check $edat $emsk
|
150 |
|
|
|
151 |
|
|
#
|
152 |
|
|
#-------------------------------------------------------------------------
|
153 |
|
|
rlc log " test 2c: test rreg,wreg capture (timeout); busy,tout flag"
|
154 |
|
|
set vtecntl [regbld rbtest::CNTL {nbusy -1}]
|
155 |
|
|
set vtedata 0xdead
|
156 |
|
|
set nmax [rbtest::nbusymax]
|
157 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
158 |
|
|
raw_edata edat emsk \
|
159 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
160 |
|
|
[list [regbld rbmoni::FLAGS ack busy tout we] $atedata $vtedata $nmax] \
|
161 |
|
|
[list [regbld rbmoni::FLAGS ack busy tout ] $atedata 0x5555 $nmax] \
|
162 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
163 |
|
|
#
|
164 |
|
|
rbmoni::start
|
165 |
30 |
wfjm |
rlc exec \
|
166 |
10 |
wfjm |
-wreg te.cntl $vtecntl \
|
167 |
28 |
wfjm |
-wreg te.data $vtedata -estat [regbld rlink::STAT rbtout] \
|
168 |
|
|
-rreg te.data -edata 0x5555 -estat [regbld rlink::STAT rbtout] \
|
169 |
10 |
wfjm |
-wreg te.cntl 0
|
170 |
|
|
rbmoni::stop
|
171 |
|
|
if {$print} {puts [print]}
|
172 |
|
|
raw_check $edat $emsk
|
173 |
|
|
|
174 |
|
|
#
|
175 |
|
|
#-------------------------------------------------------------------------
|
176 |
|
|
rlc log " test 2d: test rreg,wreg capture (prompt nak); nak flag"
|
177 |
28 |
wfjm |
set vtelnak 0xdead
|
178 |
10 |
wfjm |
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
179 |
|
|
raw_edata edat emsk \
|
180 |
28 |
wfjm |
[list [regbld rbmoni::FLAGS nak we] $atelnak $vtelnak 0] \
|
181 |
|
|
[list [regbld rbmoni::FLAGS nak ] $atelnak {} 0]
|
182 |
10 |
wfjm |
#
|
183 |
|
|
rbmoni::start
|
184 |
30 |
wfjm |
rlc exec \
|
185 |
28 |
wfjm |
-wreg te.lnak $vtelnak -estat [regbld rlink::STAT rbnak] \
|
186 |
|
|
-rreg te.lnak -estat [regbld rlink::STAT rbnak]
|
187 |
10 |
wfjm |
rbmoni::stop
|
188 |
|
|
if {$print} {puts [print]}
|
189 |
|
|
raw_check $edat $emsk
|
190 |
|
|
|
191 |
|
|
#
|
192 |
|
|
#-------------------------------------------------------------------------
|
193 |
|
|
rlc log " test 2e: test rreg,wreg capture (delayed nak); nak flag"
|
194 |
28 |
wfjm |
set vtecntl [regbld rbtest::CNTL {nbusy 7}]
|
195 |
|
|
set vtelnak 0xdead
|
196 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
197 |
10 |
wfjm |
raw_edata edat emsk \
|
198 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
199 |
28 |
wfjm |
[list [regbld rbmoni::FLAGS ack busy nak we] $atelnak $vtelnak 7] \
|
200 |
|
|
[list [regbld rbmoni::FLAGS ack busy nak ] $atelnak {} 7] \
|
201 |
10 |
wfjm |
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
202 |
|
|
#
|
203 |
|
|
rbmoni::start
|
204 |
30 |
wfjm |
rlc exec \
|
205 |
10 |
wfjm |
-wreg te.cntl $vtecntl \
|
206 |
28 |
wfjm |
-wreg te.lnak $vtelnak -estat [regbld rlink::STAT rbnak] \
|
207 |
|
|
-rreg te.lnak -estat [regbld rlink::STAT rbnak] \
|
208 |
10 |
wfjm |
-wreg te.cntl 0
|
209 |
|
|
rbmoni::stop
|
210 |
|
|
if {$print} {puts [print]}
|
211 |
|
|
raw_check $edat $emsk
|
212 |
|
|
|
213 |
|
|
#
|
214 |
|
|
#-------------------------------------------------------------------------
|
215 |
|
|
rlc log " test 2f: test rreg,wreg capture (prompt rbus err); err flag"
|
216 |
|
|
set vtefifo 0x1357
|
217 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
218 |
|
|
raw_edata edat emsk \
|
219 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo $vtefifo 0] \
|
220 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atefifo $vtefifo 0] \
|
221 |
|
|
[list [regbld rbmoni::FLAGS ack err ] $atefifo {} 0]
|
222 |
|
|
#
|
223 |
|
|
rbmoni::start
|
224 |
30 |
wfjm |
rlc exec \
|
225 |
10 |
wfjm |
-wreg te.fifo $vtefifo \
|
226 |
|
|
-rreg te.fifo -edata $vtefifo \
|
227 |
|
|
-rreg te.fifo -estat [regbld rlink::STAT rberr]
|
228 |
|
|
rbmoni::stop
|
229 |
|
|
if {$print} {puts [print]}
|
230 |
|
|
raw_check $edat $emsk
|
231 |
|
|
|
232 |
|
|
#
|
233 |
|
|
#-------------------------------------------------------------------------
|
234 |
|
|
rlc log " test 2g: test rreg,wreg capture (delayed rbus err); err flag"
|
235 |
|
|
set vtecntl [regbld rbtest::CNTL {nbusy 5}]
|
236 |
|
|
set vtefifo 0x1357
|
237 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
238 |
|
|
raw_edata edat emsk \
|
239 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
240 |
|
|
[list [regbld rbmoni::FLAGS ack busy we] $atefifo $vtefifo 5] \
|
241 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo $vtefifo 5] \
|
242 |
|
|
[list [regbld rbmoni::FLAGS ack busy err ] $atefifo {} 5] \
|
243 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
244 |
|
|
#
|
245 |
|
|
rbmoni::start
|
246 |
30 |
wfjm |
rlc exec \
|
247 |
10 |
wfjm |
-wreg te.cntl $vtecntl \
|
248 |
|
|
-wreg te.fifo $vtefifo \
|
249 |
|
|
-rreg te.fifo -edata $vtefifo \
|
250 |
30 |
wfjm |
-rreg te.fifo -estaterr \
|
251 |
10 |
wfjm |
-wreg te.cntl 0x0
|
252 |
|
|
rbmoni::stop
|
253 |
|
|
if {$print} {puts [print]}
|
254 |
|
|
raw_check $edat $emsk
|
255 |
28 |
wfjm |
|
256 |
10 |
wfjm |
#
|
257 |
|
|
#-------------------------------------------------------------------------
|
258 |
|
|
rlc log " test 3: test init capture; init flag"
|
259 |
28 |
wfjm |
set vtecntl [regbld rbtest::CNTL {nbusy 2}]
|
260 |
|
|
set vteinit [regbld rbtest::INIT cntl]
|
261 |
10 |
wfjm |
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
262 |
|
|
raw_edata edat emsk \
|
263 |
|
|
[list [regbld rbmoni::FLAGS ack we ] $atecntl $vtecntl 0] \
|
264 |
28 |
wfjm |
[list [regbld rbmoni::FLAGS nak init ] $atecntl $vteinit 0] \
|
265 |
10 |
wfjm |
[list [regbld rbmoni::FLAGS ack ] $atecntl 0 0]
|
266 |
|
|
#
|
267 |
|
|
rbmoni::start
|
268 |
30 |
wfjm |
rlc exec \
|
269 |
10 |
wfjm |
-wreg te.cntl $vtecntl \
|
270 |
|
|
-init te.cntl $vteinit \
|
271 |
|
|
-rreg te.cntl -edata 0
|
272 |
|
|
rbmoni::stop
|
273 |
|
|
if {$print} {puts [print]}
|
274 |
|
|
raw_check $edat $emsk
|
275 |
|
|
|
276 |
|
|
#
|
277 |
|
|
#-------------------------------------------------------------------------
|
278 |
|
|
rlc log " test 4: test rblk,wblk capture (ncyc=2 on read)"
|
279 |
28 |
wfjm |
set vteinit [regbld rbtest::INIT cntl]
|
280 |
10 |
wfjm |
set nbusy_2 [regbld rbtest::CNTL {nbusy 2}]
|
281 |
|
|
set vtefifo {0xdead 0xbeaf 0x4711}
|
282 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
283 |
|
|
raw_edata edat emsk \
|
284 |
28 |
wfjm |
[list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0] \
|
285 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo 0xdead 0] \
|
286 |
|
|
[list [regbld rbmoni::FLAGS burst ack we] $atefifo 0xbeaf 0] \
|
287 |
|
|
[list [regbld rbmoni::FLAGS burst ack we] $atefifo 0x4711 0] \
|
288 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_2 0] \
|
289 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo 0xdead 2] \
|
290 |
|
|
[list [regbld rbmoni::FLAGS burst ack busy ] $atefifo 0xbeaf 2] \
|
291 |
|
|
[list [regbld rbmoni::FLAGS burst ack busy ] $atefifo 0x4711 2] \
|
292 |
|
|
[list [regbld rbmoni::FLAGS nak init] $atecntl $vteinit 0]
|
293 |
10 |
wfjm |
#
|
294 |
|
|
rbmoni::start
|
295 |
30 |
wfjm |
rlc exec \
|
296 |
10 |
wfjm |
-init te.cntl $vteinit \
|
297 |
|
|
-wblk te.fifo $vtefifo \
|
298 |
|
|
-wreg te.cntl $nbusy_2 \
|
299 |
|
|
-rblk te.fifo [llength $vtefifo] -edata $vtefifo \
|
300 |
|
|
-init te.cntl $vteinit
|
301 |
|
|
rbmoni::stop
|
302 |
|
|
if {$print} {puts [print]}
|
303 |
|
|
raw_check $edat $emsk
|
304 |
|
|
|
305 |
|
|
#
|
306 |
|
|
#-------------------------------------------------------------------------
|
307 |
28 |
wfjm |
rlc log " test 5: test lolim,hilim"
|
308 |
|
|
# set window to te.ncyc to te.dinc, thus exclude cntl,stat,attn,fifo,lnak
|
309 |
|
|
rlc exec -wreg rm.lolim $atencyc \
|
310 |
|
|
-wreg rm.hilim $atedinc
|
311 |
|
|
|
312 |
30 |
wfjm |
# now access all regs (except attn,lnak), but only ncyc,data,dinc recorded
|
313 |
28 |
wfjm |
raw_edata edat emsk \
|
314 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atencyc 0x0001 0] \
|
315 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atedata 0x2345 0] \
|
316 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atedinc 0x2345 0] \
|
317 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atedata 0x2346 0]
|
318 |
|
|
#
|
319 |
|
|
rbmoni::start
|
320 |
|
|
rlc exec -rreg te.cntl \
|
321 |
|
|
-rreg te.stat \
|
322 |
|
|
-rreg te.ncyc \
|
323 |
|
|
-wreg te.data 0x2345 \
|
324 |
|
|
-wreg te.fifo 0xbeaf \
|
325 |
|
|
-rreg te.dinc -edata 0x2345 \
|
326 |
|
|
-rreg te.fifo -edata 0xbeaf \
|
327 |
30 |
wfjm |
-rreg te.data -edata 0x2346
|
328 |
28 |
wfjm |
rbmoni::stop
|
329 |
|
|
if {$print} {puts [print]}
|
330 |
|
|
raw_check $edat $emsk
|
331 |
|
|
rbmoni::init
|
332 |
|
|
|
333 |
|
|
#
|
334 |
|
|
#-------------------------------------------------------------------------
|
335 |
10 |
wfjm |
rlc log "rbmoni::test_rbtest - cleanup:"
|
336 |
|
|
rbtest::init
|
337 |
|
|
rbmoni::init
|
338 |
|
|
#
|
339 |
|
|
incr errcnt [rlc errcnt -clear]
|
340 |
|
|
return $errcnt
|
341 |
|
|
}
|
342 |
|
|
}
|