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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 wfjm
# $Id: test_fifo.tcl 662 2015-04-05 08:02:54Z 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; use estaterr
17 27 wfjm
# 2014-11-09   603   2.0    use rlink v4 address layout and iface
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 rbtest 1.0
23
 
24
package require rutiltpp
25
package require rutil
26
package require rlink
27
 
28
namespace eval rbtest {
29
  #
30
  # Basic tests with cntl and fifo registers.
31
  #
32
  proc test_fifo {} {
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 30 wfjm
    rlc exec \
45 10 wfjm
      -wreg te.fifo 0x0000 \
46 30 wfjm
      -rreg te.fifo -estat 0x00
47 10 wfjm
    # three words
48 30 wfjm
    rlc exec \
49 10 wfjm
      -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 30 wfjm
    rlc log "  test 2: fifo write/read with wblk/rblk and -edone"
58 10 wfjm
    # two words
59
    set blk {0x1111 0x2222}
60 30 wfjm
    rlc exec \
61
      -wblk te.fifo $blk -edone [llength $blk] \
62
      -rblk te.fifo [llength $blk] -edata $blk -edone [llength $blk]
63 10 wfjm
    # six words
64
    set blk {0x3333 0x4444 0x5555 0x6666 0x7777 0x8888}
65 30 wfjm
    rlc exec \
66
      -wblk te.fifo $blk -edone [llength $blk] \
67
      -rblk te.fifo [llength $blk] -edata $blk -edone [llength $blk]
68 10 wfjm
    #
69
    #-------------------------------------------------------------------------
70 30 wfjm
    rlc log "  test 3a: fifo read error (write 3, read 4) and -edone"
71 10 wfjm
    set blk {0xdead 0xbeaf 0x1234}
72 30 wfjm
    rlc exec \
73
      -wblk te.fifo $blk -edone [llength $blk] \
74
      -rblk te.fifo 4 -edata $blk -edone 3 -estaterr
75 10 wfjm
    #
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 30 wfjm
    rlc exec \
83
      -wblk te.fifo $blk -edone 16 -estaterr \
84
      -rblk te.fifo 16 -edata [lrange $blk 0 15] -edone 16
85 10 wfjm
    #
86
    #-------------------------------------------------------------------------
87 27 wfjm
    rlc log "  test 4a: verify that init 100 clears fifo and not cntl&data"
88 10 wfjm
    # check fifo empty; write a value; clear fifo via init; check fifo empty
89
    # check that cntl and data not affected
90 30 wfjm
    rlc exec \
91 27 wfjm
      -wreg te.cntl [regbld rbtest::CNTL {nbusy 0x1}] \
92 10 wfjm
      -wreg te.data 0x1234 \
93 30 wfjm
      -rreg te.fifo -estaterr \
94 10 wfjm
      -wreg te.fifo 0x4321 \
95
      -init te.cntl [regbld rbtest::INIT fifo] \
96 30 wfjm
      -rreg te.fifo -estaterr \
97 27 wfjm
      -rreg te.cntl -edata [regbld rbtest::CNTL {nbusy 0x1}] \
98 10 wfjm
      -rreg te.data -edata 0x1234
99
    #
100
    #-------------------------------------------------------------------------
101 27 wfjm
    rlc log "  test 6: test that te.ncyc returns # of cycles for te.fifo w&r"
102 10 wfjm
    foreach nbusy {0x03 0x07 0x0f 0x1f 0x00} {
103
      set valc [regbld rbtest::CNTL [list nbusy $nbusy]]
104 30 wfjm
      rlc exec \
105 10 wfjm
        -wreg te.cntl $valc \
106 21 wfjm
        -wreg te.fifo [expr {$nbusy | ( $nbusy << 8 ) }] \
107 27 wfjm
        -rreg te.ncyc -edata [expr {$nbusy + 1 }] \
108 21 wfjm
        -rreg te.fifo -edata [expr {$nbusy | ( $nbusy << 8 ) }] \
109 27 wfjm
        -rreg te.ncyc -edata [expr {$nbusy + 1 }]
110 10 wfjm
    }
111
    #
112
    #-------------------------------------------------------------------------
113
    rlc log "  test 7: verify escaping (all 256 byte codes transported)"
114
    for {set i 0} {$i < 8} {incr i} {
115
      set blk {}
116
      for {set j 0} {$j < 16} {incr j} {
117 21 wfjm
        set bcode [expr {32 * $i + 2 * $j}]
118
        lappend blk [expr {( $bcode << 8 ) | ( $bcode + 1 )}]
119 10 wfjm
      }
120 30 wfjm
      rlc exec \
121 10 wfjm
        -wblk te.fifo $blk \
122
        -rblk te.fifo [llength $blk] -edata $blk
123
    }
124
    #
125
    #-------------------------------------------------------------------------
126
    rlc log "rbtest::test_fifo - cleanup: clear cntl, data, and fifo"
127
    rlc exec -init te.cntl [regbld rbtest::INIT fifo data cntl]
128
    #
129
    incr errcnt [rlc errcnt -clear]
130
    return $errcnt
131
  }
132
}

powered by: WebSVN 2.1.0

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