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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [corefunc.hh] - Blame information for rev 161

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

Line No. Rev Author Line
1 161 sybreon
/* $Id: corefunc.hh,v 1.4 2008-05-11 13:51:50 sybreon Exp $
2 141 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
AEMB Software Verification
23
@file corefunc.hh
24
 
25
These are custom functions written to test certain hardware functions
26
that cannot be tested through numerical algorithms.
27
*/
28
 
29
#ifndef COREFUNC_HH
30
#define COREFUNC_HH
31
 
32 152 sybreon
#define MAGIC 0xAE62AE62 // magic number
33 141 sybreon
 
34 157 sybreon
volatile int intr = 0;
35 141 sybreon
 
36
void __attribute__ ((interrupt_handler)) interruptHandler()
37
{
38 157 sybreon
  int *toggle = (int *)0xFFFFFFE0;
39
  intr++; // flag the interrupt service routine
40
  *toggle = -1; // disable interrupts
41 141 sybreon
}
42
 
43 152 sybreon
/**
44
INTERRUPT TEST ROUTINE
45
*/
46
 
47 141 sybreon
int interruptTest(int timeout)
48
{
49 161 sybreon
  aembEnableInterrupts();
50
  for (int timer=0; (timer < timeout * 100); ++timer)
51
    asm volatile ("nop"); // delay loop
52 152 sybreon
  aembDisableInterrupts();
53 157 sybreon
  return (intr == 0) ? EXIT_FAILURE : EXIT_SUCCESS;
54 141 sybreon
}
55
 
56
 
57
/**
58
   FSL TEST ROUTINE
59
*/
60
 
61
int xslTest (int code)
62
{
63
  // TEST FSL1 ONLY
64
  int FSL = code;
65
 
66
  asm ("PUT %0, RFSL0" :: "r"(FSL));
67
  asm ("GET %0, RFSL0" : "=r"(FSL));
68
 
69
  if (FSL != code) return EXIT_FAILURE;
70
 
71
  asm ("PUT %0, RFSL31" :: "r"(FSL));
72
  asm ("GET %0, RFSL31" : "=r"(FSL));
73
 
74
  if (FSL != code) return EXIT_FAILURE;
75
 
76
  return EXIT_SUCCESS;
77
}
78
 
79
/**
80
   MALLOC TEST
81
   Works well with newlib malloc routine. Do some patterned tests.
82
*/
83
 
84
int memoryTest(int size)
85
{
86
  volatile void *alloc;
87
  int magic;
88
 
89
  alloc = malloc(size * sizeof(int)); // allocate 32 byte
90
  if (alloc == NULL)
91
    return EXIT_FAILURE;
92
 
93
  *(int *)alloc = MAGIC; // write to memory
94
  magic = *(int *)alloc; // read from memory
95
 
96
  return (magic == MAGIC) ? EXIT_SUCCESS : EXIT_FAILURE;
97
}
98
 
99
#endif
100
 
101
/*
102
$Log: not supported by cvs2svn $
103 161 sybreon
Revision 1.3  2008/05/01 08:37:37  sybreon
104
Added interrupt capability.
105
 
106 157 sybreon
Revision 1.2  2008/04/28 20:30:24  sybreon
107
Changed to new headers.
108
 
109 152 sybreon
Revision 1.1  2008/04/27 16:04:42  sybreon
110
Minor cosmetic changes.
111
 
112 141 sybreon
*/

powered by: WebSVN 2.1.0

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