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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [mc_async.c] - Blame information for rev 472

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
#include "../peripheral/fields.h"
27
 
28
typedef volatile unsigned long *REGISTER;
29
 
30
REGISTER mc_poc        = (unsigned long*)(MC_BASE + MC_POC);
31
REGISTER mc_csr        = (unsigned long*)(MC_BASE + MC_CSR);
32
REGISTER mc_ba_mask    = (unsigned long*)(MC_BASE + MC_BA_MASK);
33
 
34
unsigned long lpoc;
35
 
36
unsigned long set_config()
37
{
38
    REGISTER mc_csc;
39
    unsigned char ch;
40
 
41
    lpoc = *mc_poc;
42
 
43
    for (ch=0; ch<8; ch++) {
44
        if (MC_ASYNC_CSMASK & (0x01 << ch) ) {
45
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
46
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_async_cs[ch].M);
47
            SET_FIELD(*mc_csc, MC_CSC, BW,  mc_async_cs[ch].BW);
48
            SET_FLAG(*mc_csc, MC_CSC, EN);
49
            printf ("Channel Config %d - CSC = 0x%08lX\n", ch, *mc_csc);
50
        }
51
    }
52
 
53
    return 0;
54
}
55
 
56
int main()
57
{
58
    unsigned long ret;
59
    unsigned char ch;
60
 
61
    unsigned long test;
62
 
63
    unsigned long nAddress;
64
    unsigned long nMemSize;
65
    unsigned long mc_sel;
66
    REGISTER mc_tms;
67
    REGISTER mc_cs;
68
 
69
    /* set configuration */
70 472 ivang
    /* MC initialization done in except_mc.S prior to execution of main()
71
    if ( (ret = set_config()) != 0) {
72
        exit(ret);
73
    }
74
    */
75 454 ivang
 
76
    for (ch=0; ch<8; ch++) {
77
        if (MC_ASYNC_CSMASK & (0x01 << ch) ) {
78
            printf ("--- Begin Test on CS%d ---\n", ch);
79
 
80
            mc_cs  = (unsigned long*)(MC_BASE + MC_CSC(ch));
81
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
82
            mc_sel = GET_FIELD(*mc_cs, MC_CSC, SEL);
83
 
84
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
85
                    *mc_cs, *mc_tms);
86
 
87
            for (test=0; test<4; test++) {
88
                /* configure MC*/
89
                CLEAR_FLAG(*mc_cs, MC_CSC, PEN); /* no parity */
90
                CLEAR_FLAG(*mc_cs, MC_CSC, BAS); /* bank after column */
91
                CLEAR_FLAG(*mc_cs, MC_CSC, WP);  /* write enable */
92
 
93
                switch (test) {
94
                case 0:
95
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST0) != MC_ASYNC_TEST0)
96
                        continue;
97
                    break;
98
                case 1:
99
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST1) != MC_ASYNC_TEST1)
100
                        continue;
101
                    SET_FLAG(*mc_cs, MC_CSC, PEN); /* parity */
102
                    break;
103
                case 2:
104
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST2) != MC_ASYNC_TEST2)
105
                        continue;
106
                    SET_FLAG(*mc_cs, MC_CSC, BAS); /* bank after row */
107
                    break;
108
                case 3:
109
                    if ((MC_ASYNC_TESTS & MC_ASYNC_TEST3) != MC_ASYNC_TEST3)
110
                        continue;
111
                    SET_FLAG(*mc_cs, MC_CSC, WP);  /* RO */
112
                    break;
113
                } /*switch test*/
114
 
115
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_cs, *mc_tms);
116
 
117
                nAddress = mc_sel << 21;
118
                nAddress |= MC_MEM_BASE;
119
                nMemSize = ( ((*mc_ba_mask & 0x000000FF) + 1) << 21);
120
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_ASYNC_FLAGS);
121
 
122
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
123
 
124
                if (ret) {
125
                    return ret;
126
                }
127
 
128
            } /*for test*/
129
        } /*if*/
130
    } /*for CS*/
131
    printf("--- End ASYNC tests ---\n");
132
    return 0;
133
} /* main */

powered by: WebSVN 2.1.0

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