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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [testbench/] [mem_test.c] - Blame information for rev 1767

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

Line No. Rev Author Line
1 538 markom
/* Simple test, which tests whether memory accesses are performed correctly.
2
   WARNING: Requires big endian host!!! */
3
 
4
#include "support.h"
5
 
6
unsigned long _ul, *pul;
7
unsigned short *pus;
8
unsigned char *puc;
9
 
10
int main ()
11
{
12
  unsigned long cnt = 0;
13
  _ul = 0x12345678;
14
  pul = &_ul;
15
  report (*pul);
16
  cnt = (cnt + *pul) << 1;
17
 
18
  pus = (unsigned short *)&_ul;
19
  report (*pus);
20
  cnt = (cnt + *pus) << 1;
21
  pus++;
22
  report (*pus);
23
  cnt = (cnt + *pus) << 1;
24
 
25
  puc = (unsigned char *)&_ul;
26
  report (*puc);
27
  cnt = (cnt + *puc) << 1;
28
  puc++;
29
  report (*puc);
30
  cnt = (cnt + *puc) << 1;
31
  puc++;
32
  report (*puc);
33
  cnt = (cnt + *puc) << 1;
34
  puc++;
35
  report (*puc);
36
  cnt = (cnt + *puc) << 1;
37
 
38
  *pul = 0xdeaddead;
39
  report (*pul);
40
  cnt = (cnt + *pul) << 1;
41
 
42
  pus = (unsigned short *)&_ul;
43
  *pus = 0x5678;
44
  report (*pul);
45
  cnt = (cnt + *pul) << 1;
46
  pus++;
47
  *pus = 0x1234;
48
  report (*pul);
49
  cnt = (cnt + *pul) << 1;
50
 
51
  puc = (unsigned char *)&_ul;
52
  *puc = 0xdd;
53
  report (*pul);
54
  cnt = (cnt + *pul) << 1;
55
  puc++;
56
  *puc = 0xcc;
57
  report (*pul);
58
  cnt = (cnt + *pul) << 1;
59
  puc++;
60
  *puc = 0xbb;
61
  report (*pul);
62
  cnt = (cnt + *pul) << 1;
63
  puc++;
64
  *puc = 0xaa;
65
  report (*pul);
66
  cnt = (cnt + *pul) << 1;
67
 
68
  report (cnt);
69 546 simons
  cnt ^= 0xdeaddead ^ 0xda25e544;
70 538 markom
  report(cnt);
71
  return (cnt != 0xdeaddead);
72
}

powered by: WebSVN 2.1.0

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