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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [mc_ssram.c] - Blame information for rev 544

Go to most recent revision | 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
 
40
unsigned long set_config()
41
{
42
    REGISTER mc_csc;
43
    unsigned char ch;
44
 
45
    lpoc = *mc_poc;
46
 
47
    for (ch=0; ch<8; ch++) {
48
        if (MC_SSRAM_CSMASK && (0x01 << ch) ) {
49
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
50
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_ssram_cs[ch].M);
51
            SET_FLAG(*mc_csc, MC_CSC, EN);
52
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
53
        }
54
    }
55
 
56
    return 0;
57
}
58
 
59
int main()
60
{
61
    unsigned long ret;
62
    unsigned char ch;
63
 
64
    unsigned long test;
65 544 ivang
    unsigned long gpio_pat;
66 454 ivang
 
67
    unsigned long nAddress;
68
    unsigned long nMemSize;
69
    unsigned long mc_sel;
70
 
71
    REGISTER mc_tms;
72
    REGISTER mc_cs;
73
 
74 544 ivang
    *rgpio_out = 0xFFFFFFFF;
75
 
76 454 ivang
    /* set configuration */
77 468 ivang
    /* MC configuration set by except_mc.S prior to execution of main()
78
    if ( (ret = set_config()) != 0) {
79
        exit(ret);
80
    }
81
    */
82 454 ivang
 
83 544 ivang
    *rgpio_out = 0;
84 454 ivang
    for (ch=0; ch<8; ch++) {
85
        if (MC_SSRAM_CSMASK && (0x01 << ch) ) {
86
            printf ("--- Begin Test on CS%d ---\n", ch);
87
 
88
            mc_cs  = (unsigned long*)(MC_BASE + MC_CSC(ch));
89
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
90
            mc_sel = GET_FIELD(*mc_cs, MC_CSC, SEL);
91
 
92
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
93
                    *mc_cs, *mc_tms);
94
 
95
            for (test=0; test<4; test++) {
96
                /* configure MC*/
97
                CLEAR_FLAG(*mc_cs, MC_CSC, PEN); /* no parity */
98
                CLEAR_FLAG(*mc_cs, MC_CSC, BAS); /* bank after column */
99
                CLEAR_FLAG(*mc_cs, MC_CSC, WP);  /* write enable */
100
 
101
                switch (test) {
102
                case 0:
103
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST0) != MC_SSRAM_TEST0)
104
                        continue;
105
                    break;
106
                case 1:
107
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST1) != MC_SSRAM_TEST1)
108
                        continue;
109
                    SET_FLAG(*mc_cs, MC_CSC, PEN); /* parity */
110
                    break;
111
                case 2:
112
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST2) != MC_SSRAM_TEST2)
113
                        continue;
114
                    SET_FLAG(*mc_cs, MC_CSC, BAS); /* bank after row */
115
                    break;
116
                case 3:
117
                    if ((MC_SSRAM_TESTS & MC_SSRAM_TEST3) != MC_SSRAM_TEST3)
118
                        continue;
119
                    SET_FLAG(*mc_cs, MC_CSC, WP);  /* RO */
120
                    break;
121
                } /*switch test*/
122
 
123
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_cs, *mc_tms);
124
 
125
                nAddress = mc_sel << 21;
126
                nAddress |= MC_MEM_BASE;
127
                nMemSize = ( ((*mc_ba_mask && 0x000000FF) + 1) << 21);
128 544 ivang
 
129
                gpio_pat ^= 0x00000008;
130
                *rgpio_out = gpio_pat;
131 454 ivang
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_SSRAM_FLAGS);
132
 
133
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
134
 
135
                if (ret) {
136 544 ivang
                    gpio_pat ^= 0x00000080;
137
                    *rgpio_out = gpio_pat;
138
                    report(ret);
139 454 ivang
                    return ret;
140
                }
141
 
142
            } /*for test*/
143
        } /*if*/
144
    } /*for CS*/
145
    printf("--- End SSRAM tests ---\n");
146 544 ivang
    report(0xDEADDEAD);
147
 
148
    gpio_pat ^= 0x00000020;
149
    *rgpio_out = gpio_pat;
150
 
151 454 ivang
    return 0;
152
} /* main */

powered by: WebSVN 2.1.0

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