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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [simboard.hh] - Blame information for rev 139

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

Line No. Rev Author Line
1 139 sybreon
/* $Id: simboard.hh,v 1.4 2008-04-26 19:32:00 sybreon Exp $
2 113 sybreon
**
3
** AEMB Function Verification C++ Testbench
4
** Copyright (C) 2004-2008 Shawn Tan 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU General Public License as published by
10
** the Free Software Foundation, either version 3 of the License, or
11
** (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
** License for more details.
17
**
18
** You should have received a copy of the GNU General Public License
19
** along with AEMB.  If not, see .
20
*/
21
 
22
#include "aemb/msr.hh"
23 137 sybreon
#include 
24
#include 
25 113 sybreon
 
26
#ifndef SIMBOARD_HH
27
#define SIMBOARD_HH
28
 
29
#define CODE_FAIL 0xDEADBEEF
30
#define CODE_PASS 0xCAFEF00D
31
 
32
 
33
/*
34
INTERRUPT TESTS
35
*/
36
 
37 139 sybreon
#ifdef __cplusplus
38
using namespace aemb;
39
#endif
40
 
41 113 sybreon
volatile int intr = -1;
42
 
43
void __attribute__ ((interrupt_handler)) interruptHandler()
44
{
45 139 sybreon
  intr = 0; // flag the interrupt service routine
46 113 sybreon
}
47
 
48
int interruptTest(int timeout)
49
{
50 139 sybreon
  enableInterrupts();
51
  int timer;
52
  for (timer=0; (timer < timeout) && (intr == -1); ++timer); // delay loop
53
  disableInterrupts();
54 113 sybreon
  return (intr == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
55
}
56
 
57
 
58
/**
59
   FSL TEST ROUTINE
60
*/
61
 
62
int xslTest (int code)
63
{
64
  // TEST FSL1 ONLY
65
  int FSL = code;
66
 
67
  asm ("PUT %0, RFSL1" :: "r"(FSL));
68
  asm ("GET %0, RFSL1" : "=r"(FSL));
69
 
70
  if (FSL != code) return EXIT_FAILURE;
71
 
72
  asm ("PUT %0, RFSL31" :: "r"(FSL));
73
  asm ("GET %0, RFSL31" : "=r"(FSL));
74
 
75
  if (FSL != code) return EXIT_FAILURE;
76
 
77
  return EXIT_SUCCESS;
78
}
79
 
80
/**
81
   MALLOC TEST
82
   Works well with newlib malloc routine. Do some patterned tests.
83
*/
84
 
85
int memoryTest(int size)
86
{
87
  void *alloc;
88
  alloc = malloc(size * sizeof(int)); // allocate 32 byte
89
  return (alloc == NULL) ? EXIT_FAILURE : EXIT_SUCCESS;
90
}
91
 
92
/*
93
I/O FUNCTIONS
94
*/
95
void outbyte(char c)
96
{
97
  volatile char *COUT = (char *) 0xFFFFFFC0;
98
  *COUT = c;
99
}
100
 
101 137 sybreon
char inbyte()
102
{
103
  return 0;
104
}
105
 
106 125 sybreon
void outfloat(float f)
107
{
108
  volatile float *FOUT = (float *) 0xFFFFFFD0;
109
  *FOUT = f;
110
}
111
 
112 113 sybreon
void outword(long l)
113
{
114
  volatile long *DOUT = (long *) 0xFFFFFFD0;
115
  *DOUT = l;
116
}
117
 
118
void trap(long e)
119
{
120
  outword(e);
121
  outword(CODE_FAIL);
122
  // hang the machine
123 125 sybreon
  exit(e);
124 113 sybreon
}
125
 
126
#endif
127
 
128
/*
129
$Log: not supported by cvs2svn $
130 139 sybreon
Revision 1.3  2008/04/26 18:07:19  sybreon
131
Minor cosmetic changes.
132
 
133 137 sybreon
Revision 1.2  2008/04/21 12:13:12  sybreon
134
Passes arithmetic tests with single thread.
135
 
136 125 sybreon
Revision 1.1  2008/04/11 15:32:28  sybreon
137
initial checkin
138
 
139 113 sybreon
*/

powered by: WebSVN 2.1.0

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