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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [mc_sync.c] - Blame information for rev 454

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

Line No. Rev Author Line
1 454 ivang
/* mc_sync.c - Memory Controller testbench SYNCdevice 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_sync.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_SYNC_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,  2);
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
    if ( (ret = set_config()) != 0) {
71
        exit(ret);
72
    }
73
 
74
    for (ch=0; ch<8; ch++) {
75
        if (MC_SYNC_CSMASK & (0x01 << ch) ) {
76
            printf ("--- Begin Test on CS%d ---\n", ch);
77
 
78
            mc_cs  = (unsigned long*)(MC_BASE + MC_CSC(ch));
79
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
80
            mc_sel = GET_FIELD(*mc_cs, MC_CSC, SEL);
81
 
82
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
83
                    *mc_cs, *mc_tms);
84
 
85
            for (test=0; test<4; test++) {
86
                /* configure MC*/
87
                CLEAR_FLAG(*mc_cs, MC_CSC, PEN); /* no parity */
88
                CLEAR_FLAG(*mc_cs, MC_CSC, BAS); /* bank after column */
89
                CLEAR_FLAG(*mc_cs, MC_CSC, WP);  /* write enable */
90
 
91
                switch (test) {
92
                case 0:
93
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST0) != MC_SYNC_TEST0)
94
                        continue;
95
                    break;
96
                case 1:
97
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST1) != MC_SYNC_TEST1)
98
                        continue;
99
                    SET_FLAG(*mc_cs, MC_CSC, PEN); /* parity */
100
                    break;
101
                case 2:
102
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST2) != MC_SYNC_TEST2)
103
                        continue;
104
                    SET_FLAG(*mc_cs, MC_CSC, BAS); /* bank after row */
105
                    break;
106
                case 3:
107
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST3) != MC_SYNC_TEST3)
108
                        continue;
109
                    SET_FLAG(*mc_cs, MC_CSC, WP);  /* RO */
110
                    break;
111
                } /*switch test*/
112
 
113
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_cs, *mc_tms);
114
 
115
                nAddress = mc_sel << 21;
116
                nAddress |= MC_MEM_BASE;
117
                nMemSize = ( ((*mc_ba_mask & 0x000000FF) + 1) << 21);
118
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_SYNC_FLAGS);
119
 
120
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
121
 
122
                if (ret) {
123
                    return ret;
124
                }
125
 
126
            } /*for test*/
127
        } /*if*/
128
    } /*for CS*/
129
    printf("--- End SYNC tests ---\n");
130
    return 0;
131
} /* main */

powered by: WebSVN 2.1.0

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