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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [mem-test/] [mem-test.c] - Blame information for rev 609

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

Line No. Rev Author Line
1 90 jeremybenn
/* mem-test.c. Simple memory test for Or1ksim
2
 
3
   Copyright (C) 1999-2006 OpenCores
4
   Copyright (C) 2010 Embecosm Limited
5
 
6
   Contributors various OpenCores participants
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see <http:  www.gnu.org/licenses/>.  */
23
 
24
/* ----------------------------------------------------------------------------
25
   This code is commented throughout for use with Doxygen.
26
   --------------------------------------------------------------------------*/
27
 
28
/* Simple test, which tests whether memory accesses are performed correctly.
29
   WARNING: Requires big endian host!!! */
30
 
31
#include "support.h"
32
 
33
unsigned long _ul, *pul;
34
unsigned short *pus;
35
unsigned char *puc;
36
 
37
int main ()
38
{
39
  unsigned long cnt = 0;
40
  _ul = 0x12345678;
41
  pul = &_ul;
42
  report (*pul);
43
  cnt = (cnt + *pul) << 1;
44
 
45
  pus = (unsigned short *)&_ul;
46
  report (*pus);
47
  cnt = (cnt + *pus) << 1;
48
  pus++;
49
  report (*pus);
50
  cnt = (cnt + *pus) << 1;
51
 
52
  puc = (unsigned char *)&_ul;
53
  report (*puc);
54
  cnt = (cnt + *puc) << 1;
55
  puc++;
56
  report (*puc);
57
  cnt = (cnt + *puc) << 1;
58
  puc++;
59
  report (*puc);
60
  cnt = (cnt + *puc) << 1;
61
  puc++;
62
  report (*puc);
63
  cnt = (cnt + *puc) << 1;
64
 
65
  *pul = 0xdeaddead;
66
  report (*pul);
67
  cnt = (cnt + *pul) << 1;
68
 
69
  pus = (unsigned short *)&_ul;
70
  *pus = 0x5678;
71
  report (*pul);
72
  cnt = (cnt + *pul) << 1;
73
  pus++;
74
  *pus = 0x1234;
75
  report (*pul);
76
  cnt = (cnt + *pul) << 1;
77
 
78
  puc = (unsigned char *)&_ul;
79
  *puc = 0xdd;
80
  report (*pul);
81
  cnt = (cnt + *pul) << 1;
82
  puc++;
83
  *puc = 0xcc;
84
  report (*pul);
85
  cnt = (cnt + *pul) << 1;
86
  puc++;
87
  *puc = 0xbb;
88
  report (*pul);
89
  cnt = (cnt + *pul) << 1;
90
  puc++;
91
  *puc = 0xaa;
92
  report (*pul);
93
  cnt = (cnt + *pul) << 1;
94
 
95
  report (cnt);
96
  cnt ^= 0xdeaddead ^ 0xda25e544;
97
  report(cnt);
98
  return (cnt != 0xdeaddead);
99
}

powered by: WebSVN 2.1.0

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