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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [mc_async.c] - Blame information for rev 997

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

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

powered by: WebSVN 2.1.0

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