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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [testbench/] [mc_sync.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_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 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_SYNC_CSMASK & (0x01 << ch) ) {
49
            mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
50
            SET_FIELD(*mc_csc, MC_CSC, SEL, mc_async_cs[ch].M);
51
            SET_FIELD(*mc_csc, MC_CSC, BW,  2);
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
int main()
61
{
62
    unsigned long ret;
63
    unsigned char ch;
64
 
65
    unsigned long test;
66 544 ivang
    unsigned long gpio_pat = 0;
67 454 ivang
 
68
    unsigned long nAddress;
69
    unsigned long nMemSize;
70
    unsigned long mc_sel;
71
    REGISTER mc_tms;
72
    REGISTER mc_cs;
73
 
74 544 ivang
    *rgpio_out = 0xFFFFFFFF;
75 454 ivang
    /* set configuration */
76 471 ivang
    /* MC configuration set by except_mc.S prior to execution of main()
77
    if ( (ret = set_config()) != 0) {
78
        exit(ret);
79
    }
80
    */
81 454 ivang
 
82
    for (ch=0; ch<8; ch++) {
83
        if (MC_SYNC_CSMASK & (0x01 << ch) ) {
84
            printf ("--- Begin Test on CS%d ---\n", ch);
85
 
86
            mc_cs  = (unsigned long*)(MC_BASE + MC_CSC(ch));
87
            mc_tms = (unsigned long*)(MC_BASE + MC_TMS(ch));
88
            mc_sel = GET_FIELD(*mc_cs, MC_CSC, SEL);
89
 
90
            printf ("CS configuration : CSC - 0x%08lX, TMS - 0x%08lXu\n",
91
                    *mc_cs, *mc_tms);
92
 
93
            for (test=0; test<4; test++) {
94
                /* configure MC*/
95
                CLEAR_FLAG(*mc_cs, MC_CSC, PEN); /* no parity */
96
                CLEAR_FLAG(*mc_cs, MC_CSC, BAS); /* bank after column */
97
                CLEAR_FLAG(*mc_cs, MC_CSC, WP);  /* write enable */
98
 
99
                switch (test) {
100
                case 0:
101
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST0) != MC_SYNC_TEST0)
102
                        continue;
103
                    break;
104
                case 1:
105
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST1) != MC_SYNC_TEST1)
106
                        continue;
107
                    SET_FLAG(*mc_cs, MC_CSC, PEN); /* parity */
108
                    break;
109
                case 2:
110
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST2) != MC_SYNC_TEST2)
111
                        continue;
112
                    SET_FLAG(*mc_cs, MC_CSC, BAS); /* bank after row */
113
                    break;
114
                case 3:
115
                    if ((MC_SYNC_TESTS & MC_SYNC_TEST3) != MC_SYNC_TEST3)
116
                        continue;
117
                    SET_FLAG(*mc_cs, MC_CSC, WP);  /* RO */
118
                    break;
119
                } /*switch test*/
120
 
121
                printf ("Begin TEST %lu : CSC - 0x%08lX, TMS - 0x%08lX\n", test, *mc_cs, *mc_tms);
122
 
123
                nAddress = mc_sel << 21;
124
                nAddress |= MC_MEM_BASE;
125
                nMemSize = ( ((*mc_ba_mask & 0x000000FF) + 1) << 21);
126 544 ivang
 
127
                gpio_pat ^= 0x00000008;
128
                *rgpio_out = gpio_pat;
129 454 ivang
                ret = mc_test_row(nAddress, nAddress + nMemSize, MC_SYNC_FLAGS);
130
 
131
                printf("\trow tested: nAddress = 0x%08lX, ret = 0x%08lX\n", nAddress, ret);
132
 
133
                if (ret) {
134 544 ivang
                    gpio_pat ^= 0x00000080;
135
                    *rgpio_out = gpio_pat;
136
                    report(ret);
137 454 ivang
                    return ret;
138
                }
139
 
140
            } /*for test*/
141
        } /*if*/
142
    } /*for CS*/
143
    printf("--- End SYNC tests ---\n");
144 544 ivang
    report(0xDEADDEAD);
145
 
146
    gpio_pat ^= 0x00000020;
147
    *rgpio_out = gpio_pat;
148
 
149 454 ivang
    return 0;
150
} /* main */

powered by: WebSVN 2.1.0

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