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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.3.0/] [testbench/] [mc_ssram.c] - Blame information for rev 403

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

Line No. Rev Author Line
1 19 jeremybenn
/* mc_ssram.c - Memory Controller testbench SSRAM 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_ssram.h"
25
#include "../peripheral/mc.h"
26
#include "../peripheral/gpio.h"
27
#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
REGISTER rgpio_out     = (unsigned long*)(GPIO_BASE + RGPIO_OUT);
36
REGISTER rgpio_in      = (unsigned long*)(GPIO_BASE + RGPIO_IN);
37
 
38
unsigned long lpoc;
39
unsigned char mc_cs;
40
 
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_SSRAM_CSMASK && (0x01 << ch) ) {
50
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
51
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_ssram_cs[ch].M);
52
            SET_FLAG(*mc_csc, MC_CSC, EN);
53
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
54
        }
55
    }
56
 
57
    return 0;
58
}
59
 
60
unsigned long get_config()
61
{
62
  REGISTER mc_csc;
63
  REGISTER mc_tms;
64
  unsigned char ch;
65
 
66
  mc_cs = 0;
67
  for (ch=0; ch<8; ch++) {
68
    mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
69
    mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
70
    if ( (GET_FIELD(*mc_csc, MC_CSC, MEMTYPE) == 1) &&
71
         (TEST_FLAG(*mc_csc, MC_CSC, EN) == 1     ) ) {
72
      mc_ssram_cs[ch].M  = GET_FIELD(*mc_csc, MC_CSC, SEL);
73
      mc_cs |= (1 << ch);
74
 
75
      printf("get_config(%d) : M=0x%0lx\n", ch,
76
             mc_ssram_cs[ch].M);
77
    }
78
  }
79
  printf("get_config() : cs=0x%0x\n", mc_cs);
80
  return 0;
81
}
82
 
83
int main()
84
{
85
    unsigned long ret;
86
    unsigned char ch;
87
 
88
    unsigned long test;
89
    unsigned long gpio_pat;
90
 
91
    unsigned long nAddress;
92
    unsigned long nMemSize;
93
    unsigned long mc_sel;
94
 
95
    REGISTER mc_tms;
96
    REGISTER mc_csc;
97
 
98
    *rgpio_out = 0xFFFFFFFF;
99
 
100
#ifdef MC_READ_CONF
101
    if (get_config()) {
102
      printf("Error reading MC configuration\n");
103
      report(0x000000001);
104
      return(1);
105
    }
106
#else
107
    mc_cs = MC_SSRAM_CSMASK;
108
#endif
109
 
110
    *rgpio_out = 0;
111
    for (ch=0; ch<8; ch++) {
112
        if (mc_cs & (0x01 << ch) ) {
113
            printf ("--- Begin Test on CS%d ---\n", ch);
114
 
115
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
116
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
117
            mc_sel = GET_FIELD(*mc_csc, MC_CSC, SEL);
118
 
119
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
120
                    *mc_csc, *mc_tms);
121
 
122
            for (test=0; test<4; test++) {
123
                /* configure MC*/
124
                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
 
128
                switch (test) {
129
                case 0:
130
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST0) != MC_SSRAM_TEST0)
131
                        continue;
132
                    break;
133
                case 1:
134
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST1) != MC_SSRAM_TEST1)
135
                        continue;
136
                    SET_FLAG(*mc_csc, MC_CSC, PEN); /* parity */
137
                    break;
138
                case 2:
139
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST2) != MC_SSRAM_TEST2)
140
                        continue;
141
                    SET_FLAG(*mc_csc, MC_CSC, BAS); /* bank after row */
142
                    break;
143
                case 3:
144
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST3) != MC_SSRAM_TEST3)
145
                        continue;
146
                    SET_FLAG(*mc_csc, MC_CSC, WP);  /* RO */
147
                    break;
148
                } /*switch test*/
149
 
150
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_csc, *mc_tms);
151
 
152
                nAddress = mc_sel << 21;
153
                nAddress |= MC_MEM_BASE;
154
                nMemSize = ( ((*mc_ba_mask && 0x000000FF) + 1) << 21);
155
 
156
                gpio_pat ^= 0x00000008;
157
                *rgpio_out = gpio_pat;
158
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_SSRAM_FLAGS);
159
 
160
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
161
 
162
                if (ret) {
163
                    gpio_pat ^= 0x00000080;
164
                    *rgpio_out = gpio_pat;
165
                    report(ret);
166
                    return ret;
167
                }
168
 
169
            } /*for test*/
170
        } /*if*/
171
    } /*for CS*/
172
    printf("--- End SSRAM tests ---\n");
173
    report(0xDEADDEAD);
174
 
175
    gpio_pat ^= 0x00000020;
176
    *rgpio_out = gpio_pat;
177
 
178
    return 0;
179
} /* main */

powered by: WebSVN 2.1.0

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