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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [or1ksim/] [testbench/] [mc_ssram.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 454 ivang
/* 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 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_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 1024 simons
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
54 454 ivang
        }
55
    }
56
 
57
    return 0;
58
}
59
 
60 552 ivang
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 1024 simons
      printf("get_config(%d) : M=0x%0lx\n", ch,
76 552 ivang
             mc_ssram_cs[ch].M);
77
    }
78
  }
79 1024 simons
  printf("get_config() : cs=0x%0x\n", mc_cs);
80 552 ivang
  return 0;
81
}
82
 
83 454 ivang
int main()
84
{
85
    unsigned long ret;
86
    unsigned char ch;
87
 
88
    unsigned long test;
89 544 ivang
    unsigned long gpio_pat;
90 454 ivang
 
91
    unsigned long nAddress;
92
    unsigned long nMemSize;
93
    unsigned long mc_sel;
94
 
95
    REGISTER mc_tms;
96 552 ivang
    REGISTER mc_csc;
97 454 ivang
 
98 544 ivang
    *rgpio_out = 0xFFFFFFFF;
99
 
100 552 ivang
#ifdef MC_READ_CONF
101
    if (get_config()) {
102 1024 simons
      printf("Error reading MC configuration\n");
103 552 ivang
      report(0x000000001);
104
      return(1);
105
    }
106
#else
107
    mc_cs = MC_SSRAM_CSMASK;
108
#endif
109 454 ivang
 
110 544 ivang
    *rgpio_out = 0;
111 454 ivang
    for (ch=0; ch<8; ch++) {
112 552 ivang
        if (mc_cs & (0x01 << ch) ) {
113 1024 simons
            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 1024 simons
            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_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 552 ivang
                    SET_FLAG(*mc_csc, MC_CSC, PEN); /* parity */
137 454 ivang
                    break;
138
                case 2:
139
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST2) != MC_SSRAM_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_SSRAM_TESTS & MC_SSRAM_TEST3) != MC_SSRAM_TEST3)
145
                        continue;
146 552 ivang
                    SET_FLAG(*mc_csc, MC_CSC, WP);  /* RO */
147 454 ivang
                    break;
148
                } /*switch test*/
149
 
150 1024 simons
                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_SSRAM_FLAGS);
159
 
160 1024 simons
                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 1024 simons
    printf("--- End SSRAM 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.