1 |
21 |
wfjm |
# $Id: test_rbtest.tcl 516 2013-05-05 21:24:52Z mueller $
|
2 |
10 |
wfjm |
#
|
3 |
21 |
wfjm |
# Copyright 2011-2013 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 |
|
|
# 2011-03-27 374 1.0 Initial version
|
17 |
|
|
# 2011-03-13 369 0.1 First Draft
|
18 |
|
|
#
|
19 |
|
|
|
20 |
|
|
package provide rbmoni 1.0
|
21 |
|
|
|
22 |
|
|
package require rutiltpp
|
23 |
|
|
package require rutil
|
24 |
|
|
package require rlink
|
25 |
|
|
package require rbtest
|
26 |
|
|
|
27 |
|
|
namespace eval rbmoni {
|
28 |
|
|
#
|
29 |
|
|
# Basic tests with rbtester registers
|
30 |
|
|
#
|
31 |
|
|
proc test_rbtest {{print 0}} {
|
32 |
|
|
set esdval 0x00
|
33 |
|
|
set esdmsk [regbld rlink::STAT {stat -1}]
|
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 |
|
|
set atedata [rlc amap te.data]
|
44 |
|
|
set atefifo [rlc amap te.fifo]
|
45 |
|
|
#
|
46 |
|
|
#-------------------------------------------------------------------------
|
47 |
|
|
rlc log " test 1: exercise monitor data access via data/addr regs"
|
48 |
|
|
|
49 |
|
|
set vtecntl [regbld rbtest::CNTL {stat -1}]
|
50 |
|
|
set vtedata 0x1234
|
51 |
|
|
|
52 |
|
|
# setup te.cntl and te.data
|
53 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
54 |
|
|
-wreg te.cntl $vtecntl \
|
55 |
|
|
-wreg te.data $vtedata
|
56 |
|
|
|
57 |
|
|
# read te.cntl and te.data with rbmoni on; check that 2 lines aquired
|
58 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
59 |
|
|
-wreg rm.cntl [regbld rbmoni::CNTL go] \
|
60 |
|
|
-rreg te.cntl -edata $vtecntl \
|
61 |
|
|
-rreg te.data -edata $vtedata \
|
62 |
|
|
-wreg rm.cntl 0x0 \
|
63 |
|
|
-rreg rm.addr -edata [regbld rbmoni::ADDR {laddr 2}]
|
64 |
|
|
|
65 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
66 |
|
|
raw_edata edat emsk \
|
67 |
|
|
[list [regbld rbmoni::FLAGS ack] $atecntl $vtecntl 0] \
|
68 |
|
|
[list [regbld rbmoni::FLAGS ack] $atedata $vtedata 0]
|
69 |
|
|
|
70 |
|
|
#
|
71 |
|
|
#-------------------------------------------------------------------------
|
72 |
|
|
rlc log " test 1a: read all in one rblk"
|
73 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
74 |
|
|
-wreg rm.addr 0x0000 \
|
75 |
|
|
-rblk rm.data 8 -edata $edat $emsk \
|
76 |
|
|
-rreg rm.addr -edata 0x8
|
77 |
|
|
#
|
78 |
|
|
#-------------------------------------------------------------------------
|
79 |
|
|
rlc log " test 1b: random address with rreg"
|
80 |
|
|
foreach addr {0x1 0x3 0x5 0x7 0x6 0x4 0x2 0x0} {
|
81 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
82 |
|
|
-wreg rm.addr $addr \
|
83 |
|
|
-rreg rm.data -edata [lindex $edat $addr] [lindex $emsk $addr] \
|
84 |
21 |
wfjm |
-rreg rm.addr -edata [expr {$addr + 1}]
|
85 |
10 |
wfjm |
}
|
86 |
|
|
#
|
87 |
|
|
#-------------------------------------------------------------------------
|
88 |
|
|
rlc log " test 1c: random address with rblk length 2"
|
89 |
|
|
foreach addr {0x1 0x3 0x5 0x6 0x4 0x2 0x0} {
|
90 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
91 |
|
|
-wreg rm.addr $addr \
|
92 |
21 |
wfjm |
-rblk rm.data 2 -edata [lrange $edat $addr [expr {$addr + 1}] ] \
|
93 |
|
|
[lrange $emsk $addr [expr {$addr + 1}] ] \
|
94 |
|
|
-rreg rm.addr -edata [expr {$addr + 2}]
|
95 |
10 |
wfjm |
}
|
96 |
|
|
#
|
97 |
|
|
#-------------------------------------------------------------------------
|
98 |
|
|
rlc log " test 2a: test rreg,wreg capture (ncyc=0); ack, we flags"
|
99 |
|
|
set vtedata 0x4321
|
100 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
101 |
|
|
raw_edata edat emsk \
|
102 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atedata $vtedata 0] \
|
103 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atedata $vtedata 0]
|
104 |
|
|
#
|
105 |
|
|
rbmoni::start
|
106 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
107 |
|
|
-wreg te.data $vtedata \
|
108 |
|
|
-rreg te.data -edata $vtedata
|
109 |
|
|
rbmoni::stop
|
110 |
|
|
if {$print} {puts [print]}
|
111 |
|
|
raw_check $edat $emsk
|
112 |
|
|
|
113 |
|
|
#
|
114 |
|
|
#-------------------------------------------------------------------------
|
115 |
|
|
rlc log " test 2b: test rreg,wreg capture (ncyc=1,4); busy flag and nbusy"
|
116 |
|
|
set nbusy_1 [regbld rbtest::CNTL {nbusy 1}]
|
117 |
|
|
set nbusy_4 [regbld rbtest::CNTL {nbusy 4}]
|
118 |
|
|
set vtedata 0xbeaf
|
119 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
120 |
|
|
raw_edata edat emsk \
|
121 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_1 0] \
|
122 |
|
|
[list [regbld rbmoni::FLAGS ack busy we] $atedata $vtedata 1] \
|
123 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_4 0] \
|
124 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atedata $vtedata 4] \
|
125 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
126 |
|
|
#
|
127 |
|
|
rbmoni::start
|
128 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
129 |
|
|
-wreg te.cntl $nbusy_1 \
|
130 |
|
|
-wreg te.data $vtedata \
|
131 |
|
|
-wreg te.cntl $nbusy_4 \
|
132 |
|
|
-rreg te.data -edata $vtedata \
|
133 |
|
|
-wreg te.cntl 0
|
134 |
|
|
rbmoni::stop
|
135 |
|
|
if {$print} {puts [print]}
|
136 |
|
|
raw_check $edat $emsk
|
137 |
|
|
|
138 |
|
|
#
|
139 |
|
|
#-------------------------------------------------------------------------
|
140 |
|
|
rlc log " test 2c: test rreg,wreg capture (timeout); busy,tout flag"
|
141 |
|
|
set vtecntl [regbld rbtest::CNTL {nbusy -1}]
|
142 |
|
|
set vtedata 0xdead
|
143 |
|
|
set nmax [rbtest::nbusymax]
|
144 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
145 |
|
|
raw_edata edat emsk \
|
146 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
147 |
|
|
[list [regbld rbmoni::FLAGS ack busy tout we] $atedata $vtedata $nmax] \
|
148 |
|
|
[list [regbld rbmoni::FLAGS ack busy tout ] $atedata 0x5555 $nmax] \
|
149 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
150 |
|
|
#
|
151 |
|
|
rbmoni::start
|
152 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
153 |
|
|
-wreg te.cntl $vtecntl \
|
154 |
|
|
-wreg te.data $vtedata -estat [regbld rlink::STAT rbnak] \
|
155 |
|
|
-rreg te.data -edata 0x5555 -estat [regbld rlink::STAT rbnak] \
|
156 |
|
|
-wreg te.cntl 0
|
157 |
|
|
rbmoni::stop
|
158 |
|
|
if {$print} {puts [print]}
|
159 |
|
|
raw_check $edat $emsk
|
160 |
|
|
|
161 |
|
|
#
|
162 |
|
|
#-------------------------------------------------------------------------
|
163 |
|
|
rlc log " test 2d: test rreg,wreg capture (prompt nak); nak flag"
|
164 |
|
|
set vtecntl [regbld rbtest::CNTL nofifo]
|
165 |
|
|
set vtefifo 0xdead
|
166 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
167 |
|
|
raw_edata edat emsk \
|
168 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
169 |
|
|
[list [regbld rbmoni::FLAGS nak we] $atefifo $vtefifo 0] \
|
170 |
|
|
[list [regbld rbmoni::FLAGS nak ] $atefifo {} 0] \
|
171 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
172 |
|
|
#
|
173 |
|
|
rbmoni::start
|
174 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
175 |
|
|
-wreg te.cntl $vtecntl \
|
176 |
|
|
-wreg te.fifo $vtefifo -estat [regbld rlink::STAT rbnak] \
|
177 |
|
|
-rreg te.fifo -estat [regbld rlink::STAT rbnak] \
|
178 |
|
|
-wreg te.cntl 0
|
179 |
|
|
rbmoni::stop
|
180 |
|
|
if {$print} {puts [print]}
|
181 |
|
|
raw_check $edat $emsk
|
182 |
|
|
|
183 |
|
|
#
|
184 |
|
|
#-------------------------------------------------------------------------
|
185 |
|
|
rlc log " test 2e: test rreg,wreg capture (delayed nak); nak flag"
|
186 |
|
|
set vtecntl [regbld rbtest::CNTL nofifo {nbusy 7}]
|
187 |
|
|
set vtefifo 0xdead
|
188 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
189 |
|
|
raw_edata edat emsk \
|
190 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
191 |
|
|
[list [regbld rbmoni::FLAGS ack busy nak we] $atefifo $vtefifo 7] \
|
192 |
|
|
[list [regbld rbmoni::FLAGS ack busy nak ] $atefifo {} 7] \
|
193 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
194 |
|
|
#
|
195 |
|
|
rbmoni::start
|
196 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
197 |
|
|
-wreg te.cntl $vtecntl \
|
198 |
|
|
-wreg te.fifo $vtefifo -estat [regbld rlink::STAT rbnak] \
|
199 |
|
|
-rreg te.fifo -estat [regbld rlink::STAT rbnak] \
|
200 |
|
|
-wreg te.cntl 0
|
201 |
|
|
rbmoni::stop
|
202 |
|
|
if {$print} {puts [print]}
|
203 |
|
|
raw_check $edat $emsk
|
204 |
|
|
|
205 |
|
|
#
|
206 |
|
|
#-------------------------------------------------------------------------
|
207 |
|
|
rlc log " test 2f: test rreg,wreg capture (prompt rbus err); err flag"
|
208 |
|
|
set vtefifo 0x1357
|
209 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
210 |
|
|
raw_edata edat emsk \
|
211 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo $vtefifo 0] \
|
212 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atefifo $vtefifo 0] \
|
213 |
|
|
[list [regbld rbmoni::FLAGS ack err ] $atefifo {} 0]
|
214 |
|
|
#
|
215 |
|
|
rbmoni::start
|
216 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
217 |
|
|
-wreg te.fifo $vtefifo \
|
218 |
|
|
-rreg te.fifo -edata $vtefifo \
|
219 |
|
|
-rreg te.fifo -estat [regbld rlink::STAT rberr]
|
220 |
|
|
rbmoni::stop
|
221 |
|
|
if {$print} {puts [print]}
|
222 |
|
|
raw_check $edat $emsk
|
223 |
|
|
|
224 |
|
|
#
|
225 |
|
|
#-------------------------------------------------------------------------
|
226 |
|
|
rlc log " test 2g: test rreg,wreg capture (delayed rbus err); err flag"
|
227 |
|
|
set vtecntl [regbld rbtest::CNTL {nbusy 5}]
|
228 |
|
|
set vtefifo 0x1357
|
229 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
230 |
|
|
raw_edata edat emsk \
|
231 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $vtecntl 0] \
|
232 |
|
|
[list [regbld rbmoni::FLAGS ack busy we] $atefifo $vtefifo 5] \
|
233 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo $vtefifo 5] \
|
234 |
|
|
[list [regbld rbmoni::FLAGS ack busy err ] $atefifo {} 5] \
|
235 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl 0 0]
|
236 |
|
|
#
|
237 |
|
|
rbmoni::start
|
238 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
239 |
|
|
-wreg te.cntl $vtecntl \
|
240 |
|
|
-wreg te.fifo $vtefifo \
|
241 |
|
|
-rreg te.fifo -edata $vtefifo \
|
242 |
|
|
-rreg te.fifo -estat [regbld rlink::STAT rberr] \
|
243 |
|
|
-wreg te.cntl 0x0
|
244 |
|
|
rbmoni::stop
|
245 |
|
|
if {$print} {puts [print]}
|
246 |
|
|
raw_check $edat $emsk
|
247 |
|
|
|
248 |
|
|
#
|
249 |
|
|
#-------------------------------------------------------------------------
|
250 |
|
|
rlc log " test 3: test init capture; init flag"
|
251 |
|
|
set vtecntl [regbld rbtest::CNTL {nofifo}]
|
252 |
|
|
set vteinit [regbld rbtest::INIT {cntl}]
|
253 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
254 |
|
|
raw_edata edat emsk \
|
255 |
|
|
[list [regbld rbmoni::FLAGS ack we ] $atecntl $vtecntl 0] \
|
256 |
|
|
[list [regbld rbmoni::FLAGS nak init we] $atecntl $vteinit 0] \
|
257 |
|
|
[list [regbld rbmoni::FLAGS ack ] $atecntl 0 0]
|
258 |
|
|
#
|
259 |
|
|
rbmoni::start
|
260 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
261 |
|
|
-wreg te.cntl $vtecntl \
|
262 |
|
|
-init te.cntl $vteinit \
|
263 |
|
|
-rreg te.cntl -edata 0
|
264 |
|
|
rbmoni::stop
|
265 |
|
|
if {$print} {puts [print]}
|
266 |
|
|
raw_check $edat $emsk
|
267 |
|
|
|
268 |
|
|
#
|
269 |
|
|
#-------------------------------------------------------------------------
|
270 |
|
|
rlc log " test 4: test rblk,wblk capture (ncyc=2 on read)"
|
271 |
|
|
set vteinit [regbld rbtest::INIT cntl fifo]
|
272 |
|
|
set nbusy_2 [regbld rbtest::CNTL {nbusy 2}]
|
273 |
|
|
set vtefifo {0xdead 0xbeaf 0x4711}
|
274 |
|
|
# build expect list: list of {eflag eaddr edata enbusy} sublists
|
275 |
|
|
raw_edata edat emsk \
|
276 |
|
|
[list [regbld rbmoni::FLAGS nak init we] $atecntl $vteinit 0] \
|
277 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo 0xdead 0] \
|
278 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo 0xbeaf 0] \
|
279 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atefifo 0x4711 0] \
|
280 |
|
|
[list [regbld rbmoni::FLAGS ack we] $atecntl $nbusy_2 0] \
|
281 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo 0xdead 2] \
|
282 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo 0xbeaf 2] \
|
283 |
|
|
[list [regbld rbmoni::FLAGS ack busy ] $atefifo 0x4711 2] \
|
284 |
|
|
[list [regbld rbmoni::FLAGS nak init we] $atecntl $vteinit 0]
|
285 |
|
|
#
|
286 |
|
|
rbmoni::start
|
287 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
288 |
|
|
-init te.cntl $vteinit \
|
289 |
|
|
-wblk te.fifo $vtefifo \
|
290 |
|
|
-wreg te.cntl $nbusy_2 \
|
291 |
|
|
-rblk te.fifo [llength $vtefifo] -edata $vtefifo \
|
292 |
|
|
-init te.cntl $vteinit
|
293 |
|
|
rbmoni::stop
|
294 |
|
|
if {$print} {puts [print]}
|
295 |
|
|
raw_check $edat $emsk
|
296 |
|
|
|
297 |
|
|
#
|
298 |
|
|
#-------------------------------------------------------------------------
|
299 |
|
|
rlc log "rbmoni::test_rbtest - cleanup:"
|
300 |
|
|
rbtest::init
|
301 |
|
|
rbmoni::init
|
302 |
|
|
#
|
303 |
|
|
incr errcnt [rlc errcnt -clear]
|
304 |
|
|
return $errcnt
|
305 |
|
|
}
|
306 |
|
|
}
|