1 |
21 |
wfjm |
# $Id: test_data.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 rbtest 1.0
|
21 |
|
|
|
22 |
|
|
package require rutiltpp
|
23 |
|
|
package require rutil
|
24 |
|
|
package require rlink
|
25 |
|
|
|
26 |
|
|
namespace eval rbtest {
|
27 |
|
|
#
|
28 |
|
|
# Basic tests with cntl and data registers.
|
29 |
|
|
# All tests depend only on rbd_tester logic alone and not on how the
|
30 |
|
|
# rbd_tester is embedded in the design (e.g. stat and attn connections)
|
31 |
|
|
#
|
32 |
|
|
proc test_data {} {
|
33 |
|
|
set esdval 0x00
|
34 |
|
|
set esdmsk [regbld rlink::STAT {stat -1}]
|
35 |
|
|
#
|
36 |
|
|
set errcnt 0
|
37 |
|
|
rlc errcnt -clear
|
38 |
|
|
#
|
39 |
|
|
rlc log "rbtest::test_data - init: clear cntl, data, and fifo"
|
40 |
|
|
# Note: fifo clear via init is tested later, used here 'speculatively'
|
41 |
|
|
rlc exec -init te.cntl [regbld rbtest::INIT fifo data cntl]
|
42 |
|
|
#
|
43 |
|
|
#-------------------------------------------------------------------------
|
44 |
|
|
rlc log " test 1a: cntl, data are write- and read-able"
|
45 |
|
|
foreach {addr valw valr} [list te.cntl 0xffff 0xf3ff \
|
46 |
|
|
te.cntl 0x0000 0x0000 \
|
47 |
|
|
te.data 0xffff 0xffff \
|
48 |
|
|
te.data 0x0000 0x0000 ] {
|
49 |
|
|
rlc exec -wreg $addr $valw -estat $esdval $esdmsk
|
50 |
|
|
rlc exec -rreg $addr -edata $valr -estat $esdval $esdmsk
|
51 |
|
|
}
|
52 |
|
|
#
|
53 |
|
|
#
|
54 |
|
|
rlc log " test 1b: as test 1a, now use clists and check cntl/data distinct"
|
55 |
|
|
foreach {valc vald} [list 0x0000 0x0000 [regbld rbtest::CNTL nofifo] 0xffff] {
|
56 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
57 |
|
|
-wreg te.cntl $valc \
|
58 |
|
|
-wreg te.data $vald \
|
59 |
|
|
-rreg te.cntl -edata $valc \
|
60 |
|
|
-rreg te.data -edata $vald
|
61 |
|
|
}
|
62 |
|
|
#
|
63 |
|
|
#
|
64 |
|
|
rlc log " test 1c: as test 1, now cntl.stat field is used"
|
65 |
|
|
foreach stat {0x1 0x3 0x7 0x0} {
|
66 |
|
|
set valc [regbld rbtest::CNTL [list stat $stat]]
|
67 |
21 |
wfjm |
set vald [expr {$stat | ( $stat << 8 ) }]
|
68 |
10 |
wfjm |
rlc exec -estatdef $esdval $esdmsk \
|
69 |
|
|
-wreg te.cntl $valc \
|
70 |
|
|
-wreg te.data $vald \
|
71 |
|
|
-rreg te.cntl -edata $valc \
|
72 |
|
|
-rreg te.data -edata $vald
|
73 |
|
|
}
|
74 |
|
|
#
|
75 |
|
|
#-------------------------------------------------------------------------
|
76 |
|
|
rlc log " test 2: cntl.nbusy is write- and readable (last nbusy=0 again)"
|
77 |
|
|
foreach nbusy {0x00f 0x0ff 0x3ff 0x000} {
|
78 |
|
|
set valc [regbld rbtest::CNTL [list nbusy $nbusy]]
|
79 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
80 |
|
|
-wreg te.cntl $valc \
|
81 |
|
|
-rreg te.cntl -edata $valc
|
82 |
|
|
}
|
83 |
|
|
#
|
84 |
|
|
#-------------------------------------------------------------------------
|
85 |
|
|
rlc log " test 3: verify that large nbusy causes timeout"
|
86 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
87 |
|
|
-wreg te.data 0xdead \
|
88 |
|
|
-rreg te.data -edata 0xdead \
|
89 |
|
|
-wreg te.cntl [regbld rbtest::CNTL {nbusy 0x3ff}] \
|
90 |
|
|
-wreg te.data 0xbeaf -estat [regbld rlink::STAT rbnak] $esdmsk \
|
91 |
|
|
-rreg te.data -estat [regbld rlink::STAT rbnak] $esdmsk \
|
92 |
|
|
-wreg te.cntl 0x0000 \
|
93 |
|
|
-rreg te.data -edata 0xdead -edata 0xdead
|
94 |
|
|
#
|
95 |
|
|
# -------------------------------------------------------------------------
|
96 |
|
|
rlc log " test 4a: verify that init 001 clears cntl and not data"
|
97 |
|
|
set valc [regbld rbtest::CNTL nofifo {stat 0x3}]
|
98 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
99 |
|
|
-wreg te.cntl $valc \
|
100 |
|
|
-wreg te.data 0x1234 \
|
101 |
|
|
-init te.cntl [regbld rbtest::INIT cntl] \
|
102 |
|
|
-rreg te.cntl -edata 0x0 \
|
103 |
|
|
-wreg te.data 0x1234
|
104 |
|
|
rlc log " test 4b: verify that init 010 clears data and not cntl"
|
105 |
|
|
set valc [regbld rbtest::CNTL {stat 0x7}]
|
106 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
107 |
|
|
-wreg te.cntl $valc \
|
108 |
|
|
-wreg te.data 0x4321 \
|
109 |
|
|
-init te.cntl [regbld rbtest::INIT data] \
|
110 |
|
|
-rreg te.cntl -edata $valc \
|
111 |
|
|
-wreg te.data 0x0
|
112 |
|
|
rlc log " test 4c: verify that init 011 clears data and cntl"
|
113 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
114 |
|
|
-wreg te.cntl [regbld rbtest::CNTL nofifo {stat 0x7} {nbusy 2}] \
|
115 |
|
|
-wreg te.data 0xabcd \
|
116 |
|
|
-init te.cntl [regbld rbtest::INIT data cntl] \
|
117 |
|
|
-rreg te.cntl -edata 0x0 \
|
118 |
|
|
-wreg te.data 0x0
|
119 |
|
|
#
|
120 |
|
|
# -------------------------------------------------------------------------
|
121 |
|
|
rlc log " test 5: test that te.attn returns # of cycles for te.data w&r"
|
122 |
|
|
foreach nbusy {0x03 0x07 0x0f 0x1f 0x00} {
|
123 |
|
|
set valc [regbld rbtest::CNTL [list nbusy $nbusy]]
|
124 |
|
|
rlc exec -estatdef $esdval $esdmsk \
|
125 |
|
|
-wreg te.cntl $valc \
|
126 |
21 |
wfjm |
-wreg te.data [expr {$nbusy | ( $nbusy << 8 ) }] \
|
127 |
|
|
-rreg te.attn -edata [expr {$nbusy + 1 }] \
|
128 |
|
|
-rreg te.data -edata [expr {$nbusy | ( $nbusy << 8 ) }] \
|
129 |
|
|
-rreg te.attn -edata [expr {$nbusy + 1 }]
|
130 |
10 |
wfjm |
}
|
131 |
|
|
#
|
132 |
|
|
# -------------------------------------------------------------------------
|
133 |
|
|
rlc log " test 6: verify stat command after te.data wreg & rreg"
|
134 |
|
|
set rlist [rlc exec -rlist -estatdef $esdval $esdmsk \
|
135 |
|
|
-wreg te.data 0x1234 \
|
136 |
|
|
-stat ]
|
137 |
|
|
#rlist like: {wreg 90 23 0} {stat 4 39 0 90 1}
|
138 |
|
|
set xreg_ccode [lindex $rlist 0 1]
|
139 |
|
|
set stat_ccode [lindex $rlist 1 4]
|
140 |
|
|
if {$xreg_ccode != $stat_ccode} {
|
141 |
|
|
rlc log " ---- stat ccmd mismatch, d=[pbvi o8 $xreg_ccode]! D=[pbvi o8 $stat_ccode] FAIL"
|
142 |
|
|
incr errcnt
|
143 |
|
|
}
|
144 |
|
|
set rlist [rlc exec -rlist -estatdef $esdval $esdmsk \
|
145 |
|
|
-rreg te.data -edata 0x1234 \
|
146 |
|
|
-stat -edata 0x1234]
|
147 |
|
|
#rlist like: {rreg 72 23 0 4660} {stat 12 39 0 72 4660}
|
148 |
|
|
set xreg_ccode [lindex $rlist 0 1]
|
149 |
|
|
set stat_ccode [lindex $rlist 1 4]
|
150 |
|
|
if {$xreg_ccode != $stat_ccode} {
|
151 |
|
|
rlc log " ---- stat ccmd mismatch, d=[pbvi o8 $xreg_ccode]! D=[pbvi o8 $stat_ccode] FAIL"
|
152 |
|
|
incr errcnt
|
153 |
|
|
}
|
154 |
|
|
#
|
155 |
|
|
#-------------------------------------------------------------------------
|
156 |
|
|
rlc log "rbtest::test_data - cleanup: clear cntl and data"
|
157 |
|
|
rlc exec -init te.cntl [regbld rbtest::INIT data cntl]
|
158 |
|
|
#
|
159 |
|
|
incr errcnt [rlc errcnt -clear]
|
160 |
|
|
return $errcnt
|
161 |
|
|
}
|
162 |
|
|
}
|