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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [mc-async/] [mc-async.c] - Blame information for rev 90

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 90 jeremybenn
/* mc_async.c - Memory Controller testbench ASYNCdevice test
2
 
3
   Copyright (C) 2001 Ivan Guzvinec
4
   Copyright (C) 2010 Embecosm Limited
5
 
6
   Contributor Ivan Guzvinec <ivang@opencores.org>
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see <http:  www.gnu.org/licenses/>.  */
23
 
24
/* ----------------------------------------------------------------------------
25
   This code is commented throughout for use with Doxygen.
26
   --------------------------------------------------------------------------*/
27
 
28
#include "support.h"
29
 
30
#include "mc-common.h"
31
#include "mc-async.h"
32
 
33
#include "config.h"
34
#include "mc.h"
35
#include "gpio.h"
36
#include "fields.h"
37
 
38
typedef volatile unsigned long *REGISTER;
39
 
40
REGISTER mc_poc        = (unsigned long*)(MC_BASE + MC_POC);
41
REGISTER mc_csr        = (unsigned long*)(MC_BASE + MC_CSR);
42
REGISTER mc_ba_mask    = (unsigned long*)(MC_BASE + MC_BA_MASK);
43
 
44
REGISTER rgpio_out     = (unsigned long*)(GPIO_BASE + RGPIO_OUT);
45
REGISTER rgpio_in      = (unsigned long*)(GPIO_BASE + RGPIO_IN);
46
 
47
unsigned long lpoc;
48
unsigned char mc_cs;
49
 
50
unsigned long set_config()
51
{
52
    REGISTER mc_csc;
53
    unsigned char ch;
54
 
55
    lpoc = *mc_poc;
56
 
57
    for (ch=0; ch<8; ch++) {
58
        if (MC_ASYNC_CSMASK & (0x01 << ch) ) {
59
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
60
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_async_cs[ch].M);
61
            SET_FIELD(*mc_csc, MC_CSC, BW,  mc_async_cs[ch].BW);
62
            SET_FLAG(*mc_csc, MC_CSC, EN);
63
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
64
        }
65
    }
66
 
67
    return 0;
68
}
69
 
70
unsigned long get_config()
71
{
72
  REGISTER mc_csc;
73
  REGISTER mc_tms;
74
  unsigned char ch;
75
 
76
  mc_cs = 0;
77
  for (ch=0; ch<8; ch++) {
78
    mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
79
    mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
80
    if ( (GET_FIELD(*mc_csc, MC_CSC, MEMTYPE) == 2) &&
81
         (TEST_FLAG(*mc_csc, MC_CSC, EN) == 1     ) ) {
82
      mc_async_cs[ch].BW = GET_FIELD(*mc_csc, MC_CSC, BW);
83
      mc_async_cs[ch].M  = GET_FIELD(*mc_csc, MC_CSC, SEL);
84
      mc_cs |= (1 << ch);
85
 
86
      printf("get_config(%d) : BW=0x%0lx, M=0x%0lx\n", ch,
87
             mc_async_cs[ch].BW,
88
             mc_async_cs[ch].M);
89
    }
90
  }
91
  printf("get_config() : cs=0x%0x\n", mc_cs);
92
  return 0;
93
}
94
 
95
int main()
96
{
97
    unsigned long ret;
98
    unsigned char ch;
99
 
100
    unsigned long test;
101
    unsigned long gpio_pat = 0;
102
 
103
    unsigned long nAddress;
104
    unsigned long nMemSize;
105
    unsigned long mc_sel;
106
    REGISTER mc_tms;
107
    REGISTER mc_csc;
108
 
109
    *rgpio_out = 0xFFFFFFFF;
110
#ifdef MC_READ_CONF
111
    if (get_config()) {
112
      printf("Error reading MC configuration.\n");
113
      report(1);
114
      return(1);
115
    }
116
#else
117
    mc_cs = MC_ASYNC_CSMASK;
118
#endif
119
 
120
    for (ch=0; ch<8; ch++) {
121
        if (mc_cs & (0x01 << ch) ) {
122
            printf ("--- Begin Test on CS%d ---\n", ch);
123
 
124
            mc_csc  = (unsigned long*)(MC_BASE + MC_CSC(ch));
125
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
126
            mc_sel = GET_FIELD(*mc_csc, MC_CSC, SEL);
127
 
128
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
129
                    *mc_csc, *mc_tms);
130
 
131
            for (test=0; test<4; test++) {
132
                /* configure MC*/
133
                CLEAR_FLAG(*mc_csc, MC_CSC, PEN); /* no parity */
134
                CLEAR_FLAG(*mc_csc, MC_CSC, BAS); /* bank after column */
135
                CLEAR_FLAG(*mc_csc, MC_CSC, WP);  /* write enable */
136
 
137
                switch (test) {
138
                case 0:
139
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST0) != MC_ASYNC_TEST0)
140
                        continue;
141
                    break;
142
                case 1:
143
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST1) != MC_ASYNC_TEST1)
144
                        continue;
145
                    SET_FLAG(*mc_csc, MC_CSC, PEN); /* parity */
146
                    break;
147
                case 2:
148
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST2) != MC_ASYNC_TEST2)
149
                        continue;
150
                    SET_FLAG(*mc_csc, MC_CSC, BAS); /* bank after row */
151
                    break;
152
                case 3:
153
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST3) != MC_ASYNC_TEST3)
154
                        continue;
155
                    SET_FLAG(*mc_csc, MC_CSC, WP);  /* RO */
156
                    break;
157
                } /*switch test*/
158
 
159
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_csc, *mc_tms);
160
 
161
                nAddress = mc_sel << 21;
162
                nAddress |= MC_MEM_BASE;
163
                nMemSize = ( ((*mc_ba_mask & 0x000000FF) + 1) << 21);
164
 
165
                gpio_pat ^= 0x00000008;
166
                *rgpio_out = gpio_pat;
167
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_ASYNC_FLAGS);
168
 
169
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
170
 
171
                if (ret) {
172
                    gpio_pat ^= 0x00000080;
173
                    *rgpio_out = gpio_pat;
174
                    report(ret);
175
                    return ret;
176
                }
177
 
178
            } /*for test*/
179
        } /*if*/
180
    } /*for CS*/
181
    printf("--- End ASYNC tests ---\n");
182
    report(0xDEADDEAD);
183
 
184
    gpio_pat ^= 0x00000020;
185
    *rgpio_out = gpio_pat;
186
 
187
    return 0;
188
} /* main */

powered by: WebSVN 2.1.0

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