OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [tcl/] [rbtest/] [test_fifo.tcl] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 wfjm
# $Id: test_fifo.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 fifo registers.
29
  #
30
  proc test_fifo {} {
31
    set esdval 0x00
32
    set esdmsk [regbld rlink::STAT {stat -1}]
33
    #
34
    set errcnt 0
35
    rlc errcnt -clear
36
    #
37
    rlc log "rbtest::test_fifo - init: clear cntl, data, and fifo"
38
    # Note: fifo clear via init is tested later, used here 'speculatively'
39
    rlc exec -init te.cntl [regbld rbtest::INIT fifo data cntl]
40
    #
41
    #-------------------------------------------------------------------------
42
    rlc log "  test 1: fifo write/read with wreg/rreg"
43
    # single word
44
    rlc exec -estatdef $esdval $esdmsk \
45
      -wreg te.fifo 0x0000 \
46
      -rreg te.fifo -estat 0x0000
47
    # three words
48
    rlc exec -estatdef $esdval $esdmsk \
49
      -wreg te.fifo 0xdead \
50
      -wreg te.fifo 0xbeaf \
51
      -wreg te.fifo 0x1234 \
52
      -rreg te.fifo -edata 0xdead \
53
      -rreg te.fifo -edata 0xbeaf \
54
      -rreg te.fifo -edata 0x1234
55
    #
56
    #-------------------------------------------------------------------------
57
    rlc log "  test 2: fifo write/read with wblk/rblk"
58
    # two words
59
    set blk {0x1111 0x2222}
60
    rlc exec -estatdef $esdval $esdmsk \
61
      -wblk te.fifo $blk \
62
      -rblk te.fifo [llength $blk] -edata $blk
63
    # six words
64
    set blk {0x3333 0x4444 0x5555 0x6666 0x7777 0x8888}
65
    rlc exec -estatdef $esdval $esdmsk \
66
      -wblk te.fifo $blk \
67
      -rblk te.fifo [llength $blk] -edata $blk
68
    #
69
    #-------------------------------------------------------------------------
70
    rlc log "  test 3a: fifo read error (write 3, read 4)"
71
    set blk {0xdead 0xbeaf 0x1234}
72
    rlc exec -estatdef $esdval $esdmsk \
73
      -wblk te.fifo $blk \
74
      -rblk te.fifo 4 -edata $blk -estat [regbld rlink::STAT rberr] $esdmsk
75
    #
76
    #
77
    rlc log "  test 3b: fifo write error (write 17, read 16)"
78
    set blk {}
79
    for { set i 0 } { $i < 17 } { incr i } {
80 21 wfjm
      lappend blk [expr {$i | ( $i << 8 ) }]
81 10 wfjm
    }
82
    rlc exec -estatdef $esdval $esdmsk \
83
      -wblk te.fifo $blk -estat [regbld rlink::STAT rberr] $esdmsk \
84
      -rblk te.fifo 16 -edata [lrange $blk 0 15]
85
    #
86
    #-------------------------------------------------------------------------
87
    rlc log "  test 4a: verify that init 100 clears fifo ant not cntl&data"
88
    # check fifo empty; write a value; clear fifo via init; check fifo empty
89
    # check that cntl and data not affected
90
    rlc exec -estatdef $esdval $esdmsk \
91
      -wreg te.cntl [regbld rbtest::CNTL {stat 0x7}] \
92
      -wreg te.data 0x1234 \
93
      -rreg te.fifo -estat [regbld rlink::STAT rberr] $esdmsk \
94
      -wreg te.fifo 0x4321 \
95
      -init te.cntl [regbld rbtest::INIT fifo] \
96
      -rreg te.fifo -estat [regbld rlink::STAT rberr] $esdmsk \
97
      -rreg te.cntl -edata [regbld rbtest::CNTL {stat 0x7}] \
98
      -rreg te.data -edata 0x1234
99
    #
100
    #
101
    rlc log "  test 4b: verify fifo clear via nofifo flag in cntl"
102
    # write a value; set and clear nofifo flag in cntl; ckeck fifo empty
103
    rlc exec -estatdef $esdval $esdmsk \
104
      -wreg te.fifo 0x4321 \
105
      -wreg te.cntl [regbld rbtest::CNTL nofifo] \
106
      -wreg te.cntl 0x0000 \
107
      -rreg te.fifo -estat [regbld rlink::STAT rberr] $esdmsk
108
    #
109
    #-------------------------------------------------------------------------
110
    rlc log "  test 5: verify that nofifo causes a rbnak on fifo access"
111
    # write fifo; set nofifo in cntl; write/read fifo(->rbnak);
112
    #   clr nofifo in cntl; read fifo(->rberr)
113
    rlc exec -estatdef $esdval $esdmsk \
114
      -wreg te.fifo 0x12ab \
115
      -wreg te.cntl [regbld rbtest::CNTL nofifo] \
116
      -wreg te.fifo 0x12cd -estat [regbld rlink::STAT rbnak] $esdmsk \
117
      -rreg te.fifo        -estat [regbld rlink::STAT rbnak] $esdmsk \
118
      -wreg te.cntl 0x0000 \
119
      -rreg te.fifo        -estat [regbld rlink::STAT rberr] $esdmsk
120
    #
121
    #-------------------------------------------------------------------------
122
    rlc log "  test 6: test that te.attn returns # of cycles for te.fifo w&r"
123
    foreach nbusy {0x03 0x07 0x0f 0x1f 0x00} {
124
      set valc [regbld rbtest::CNTL [list nbusy $nbusy]]
125
      rlc exec -estatdef $esdval $esdmsk \
126
        -wreg te.cntl $valc \
127 21 wfjm
        -wreg te.fifo [expr {$nbusy | ( $nbusy << 8 ) }] \
128
        -rreg te.attn -edata [expr {$nbusy + 1 }] \
129
        -rreg te.fifo -edata [expr {$nbusy | ( $nbusy << 8 ) }] \
130
        -rreg te.attn -edata [expr {$nbusy + 1 }]
131 10 wfjm
    }
132
    #
133
    #-------------------------------------------------------------------------
134
    rlc log "  test 7: verify escaping (all 256 byte codes transported)"
135
    for {set i 0} {$i < 8} {incr i} {
136
      set blk {}
137
      for {set j 0} {$j < 16} {incr j} {
138 21 wfjm
        set bcode [expr {32 * $i + 2 * $j}]
139
        lappend blk [expr {( $bcode << 8 ) | ( $bcode + 1 )}]
140 10 wfjm
      }
141
      rlc exec -estatdef $esdval $esdmsk \
142
        -wblk te.fifo $blk \
143
        -rblk te.fifo [llength $blk] -edata $blk
144
    }
145
    #
146
    # -------------------------------------------------------------------------
147
    rlc log "  test 8: verify stat command after te.data wblk & rblk"
148
    set blk {0x1234 0x2345}
149
    set rlist [rlc exec -rlist -estatdef $esdval $esdmsk \
150
                 -wblk te.fifo $blk \
151
                 -stat ]
152
    #puts $rlist
153
    #rlist like: {wblk 99 23 0} {stat 4 39 0 99 65279}
154
    set xreg_ccode [lindex $rlist 0 1]
155
    set stat_ccode [lindex $rlist 1 4]
156
    if {$xreg_ccode != $stat_ccode} {
157
      rlc log " ---- stat ccmd mismatch, d=[pbvi o8 $xreg_ccode]! D=[pbvi o8 $stat_ccode] FAIL"
158
      incr errcnt
159
    }
160
    set rlist [rlc exec -rlist -estatdef $esdval $esdmsk \
161
                 -rblk te.fifo [llength $blk] -edata $blk \
162
                 -stat -edata 0x2345]
163
    #puts $rlist
164
    #{rblk 97 23 0 {4660 9029}} {stat 12 39 0 97 9029}
165
    set xreg_ccode [lindex $rlist 0 1]
166
    set stat_ccode [lindex $rlist 1 4]
167
    if {$xreg_ccode != $stat_ccode} {
168
      rlc log " ---- stat ccmd mismatch, d=[pbvi o8 $xreg_ccode]! D=[pbvi o8 $stat_ccode] FAIL"
169
      incr errcnt
170
    }
171
    #
172
    #-------------------------------------------------------------------------
173
    rlc log "rbtest::test_fifo - cleanup: clear cntl, data, and fifo"
174
    rlc exec -init te.cntl [regbld rbtest::INIT fifo data cntl]
175
    #
176
    incr errcnt [rlc errcnt -clear]
177
    return $errcnt
178
  }
179
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.