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

Subversion Repositories aemb

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

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

Line No. Rev Author Line
1 137 sybreon
/* $Id: simboard.hh,v 1.3 2008-04-26 18:07:19 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
volatile int intr = -1;
38
 
39
void __attribute__ ((interrupt_handler)) interruptHandler()
40
{
41
  intr = 0; // flag the interrupt
42
}
43
 
44
int interruptTest(int timeout)
45
{
46
  aemb::enableInterrupts();
47
  for (int timer=0; (timer < timeout) && (intr == -1); ++timer); // delay loop
48
  aemb::disableInterrupts();
49
  return (intr == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
50
}
51
 
52
 
53
/**
54
   FSL TEST ROUTINE
55
*/
56
 
57
int xslTest (int code)
58
{
59
  // TEST FSL1 ONLY
60
  int FSL = code;
61
 
62
  asm ("PUT %0, RFSL1" :: "r"(FSL));
63
  asm ("GET %0, RFSL1" : "=r"(FSL));
64
 
65
  if (FSL != code) return EXIT_FAILURE;
66
 
67
  asm ("PUT %0, RFSL31" :: "r"(FSL));
68
  asm ("GET %0, RFSL31" : "=r"(FSL));
69
 
70
  if (FSL != code) return EXIT_FAILURE;
71
 
72
  return EXIT_SUCCESS;
73
}
74
 
75
/**
76
   MALLOC TEST
77
   Works well with newlib malloc routine. Do some patterned tests.
78
*/
79
 
80
int memoryTest(int size)
81
{
82
  void *alloc;
83
  alloc = malloc(size * sizeof(int)); // allocate 32 byte
84
  return (alloc == NULL) ? EXIT_FAILURE : EXIT_SUCCESS;
85
}
86
 
87
/*
88
I/O FUNCTIONS
89
*/
90
void outbyte(char c)
91
{
92
  volatile char *COUT = (char *) 0xFFFFFFC0;
93
  *COUT = c;
94
}
95
 
96 137 sybreon
char inbyte()
97
{
98
  return 0;
99
}
100
 
101 125 sybreon
void outfloat(float f)
102
{
103
  volatile float *FOUT = (float *) 0xFFFFFFD0;
104
  *FOUT = f;
105
}
106
 
107 113 sybreon
void outword(long l)
108
{
109
  volatile long *DOUT = (long *) 0xFFFFFFD0;
110
  *DOUT = l;
111
}
112
 
113
void trap(long e)
114
{
115
  outword(e);
116
  outword(CODE_FAIL);
117
  // hang the machine
118 125 sybreon
  exit(e);
119 113 sybreon
}
120
 
121
#endif
122
 
123
/*
124
$Log: not supported by cvs2svn $
125 137 sybreon
Revision 1.2  2008/04/21 12:13:12  sybreon
126
Passes arithmetic tests with single thread.
127
 
128 125 sybreon
Revision 1.1  2008/04/11 15:32:28  sybreon
129
initial checkin
130
 
131 113 sybreon
*/

powered by: WebSVN 2.1.0

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