URL
https://opencores.org/ocsvn/aemb/aemb/trunk
Subversion Repositories aemb
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 140 to Rev 141
- ↔ Reverse comparison
Rev 140 → Rev 141
/trunk/sw/cc/corefunc.hh
0,0 → 1,97
/* $Id: corefunc.hh,v 1.1 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB Function Verification C++ Testbench |
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net> |
** |
** This file is part of AEMB. |
** |
** AEMB is free software: you can redistribute it and/or modify it |
** under the terms of the GNU General Public License as published by |
** the Free Software Foundation, either version 3 of the License, or |
** (at your option) any later version. |
** |
** AEMB is distributed in the hope that it will be useful, but WITHOUT |
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
** License for more details. |
** |
** You should have received a copy of the GNU General Public License |
** along with AEMB. If not, see <http://www.gnu.org/licenses/>. |
*/ |
/** |
AEMB Software Verification |
@file corefunc.hh |
|
These are custom functions written to test certain hardware functions |
that cannot be tested through numerical algorithms. |
*/ |
|
#ifndef COREFUNC_HH |
#define COREFUNC_HH |
|
#define MAGIC 0xAE63AE63 // magic number |
|
volatile int intr = -1; |
|
void __attribute__ ((interrupt_handler)) interruptHandler() |
{ |
intr = 0; // flag the interrupt service routine |
} |
|
int interruptTest(int timeout) |
{ |
enableInterrupts(); |
int timer; |
for (timer=0; (timer < timeout * 100) && (intr == -1); ++timer); // delay loop |
disableInterrupts(); |
return (intr == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
} |
|
|
/** |
FSL TEST ROUTINE |
*/ |
|
int xslTest (int code) |
{ |
// TEST FSL1 ONLY |
int FSL = code; |
|
asm ("PUT %0, RFSL0" :: "r"(FSL)); |
asm ("GET %0, RFSL0" : "=r"(FSL)); |
|
if (FSL != code) return EXIT_FAILURE; |
|
asm ("PUT %0, RFSL31" :: "r"(FSL)); |
asm ("GET %0, RFSL31" : "=r"(FSL)); |
|
if (FSL != code) return EXIT_FAILURE; |
|
return EXIT_SUCCESS; |
} |
|
/** |
MALLOC TEST |
Works well with newlib malloc routine. Do some patterned tests. |
*/ |
|
int memoryTest(int size) |
{ |
volatile void *alloc; |
int magic; |
|
alloc = malloc(size * sizeof(int)); // allocate 32 byte |
if (alloc == NULL) |
return EXIT_FAILURE; |
|
*(int *)alloc = MAGIC; // write to memory |
magic = *(int *)alloc; // read from memory |
|
return (magic == MAGIC) ? EXIT_SUCCESS : EXIT_FAILURE; |
} |
|
#endif |
|
/* |
$Log: not supported by cvs2svn $ |
*/ |
/trunk/sw/cc/testbench.cc
1,4 → 1,4
/* $Id: testbench.cc,v 1.5 2008-04-26 19:32:00 sybreon Exp $ |
/* $Id: testbench.cc,v 1.6 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB Function Verification C++ Testbench |
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net> |
18,51 → 18,84
** You should have received a copy of the GNU General Public License |
** along with AEMB. If not, see <http://www.gnu.org/licenses/>. |
*/ |
/** |
AEMB Software Verification |
@file testbench.cc |
|
This programme performs numerical and functional verification of the |
AEMB. It can be compiled by the GCC compiler. |
*/ |
|
#include <stdio.h> |
#include <stdlib.h> |
#include "aemb/core.hh" |
#include "literate.hh" |
#include "simboard.hh" |
#include "corefunc.hh" |
|
#define MAX_TEST 3 |
|
// run tests |
int main() |
void checkcode(int code) |
{ |
iprintf("AEMB2 32-bit Microprocessor Core\n"); |
if (code == EXIT_SUCCESS) |
iprintf("\t\t-PASS-\n"); |
else |
iprintf("\t\t*FAIL*\n"); |
} |
|
iprintf("\nNumerical Tests\n"); |
void printtest(char *msg) |
{ |
static int count = 1; |
iprintf("\t%d. %s\n",count++, msg); |
} |
|
void numtests() |
{ |
// *** 1. FIBONACCI *** |
if (fibonacciTest(MAX_TEST) != EXIT_SUCCESS) trap(-1); |
iprintf("1.\tBasic Integer\tPASS\n"); |
printtest("Integer Arithmetic"); |
checkcode(fibonacciTest(MAX_TEST)); |
|
// *** 2. EUCLIDEAN *** |
if (euclideanTest(MAX_TEST) != EXIT_SUCCESS) trap(-2); |
iprintf("2.\tExtra Integer\tPASS\n"); |
printtest("Integer Factorisation"); |
checkcode(euclideanTest(MAX_TEST)); |
|
// *** 3. NEWTON-RHAPSON *** |
if (newtonTest(MAX_TEST) != EXIT_SUCCESS) trap(-3); |
iprintf("3.\tFloating Point\tPASS\n"); |
printtest("Floating Point Arithmetic"); |
checkcode(newtonTest(MAX_TEST)); |
|
iprintf("\nFunctional Tests\n"); |
} |
|
void coretests() |
{ |
// *** 4. MEMORY-ALLOC *** |
if (memoryTest(MAX_TEST) != EXIT_SUCCESS) trap(-4); |
iprintf("4.\tMemory Alloc\tPASS\n"); |
printtest("Memory Allocation"); |
checkcode(memoryTest(MAX_TEST)); |
|
// *** 5. INTERRUPT *** |
iprintf("5.\tInterrupt\tPASS\n"); |
|
printtest("Hardware Interrupts"); |
checkcode(interruptTest(MAX_TEST)); |
|
// *** 6. EXTENSION *** |
iprintf("6.\tExtension\tPASS\n"); |
printtest("Accellerator Link"); |
checkcode(xslTest(MAX_TEST)); |
} |
|
// *** 9. PASSED *** |
iprintf("\n*** PASSED ***\n"); |
// run tests |
int main() |
{ |
iprintf("AEMB2 32-bit Microprocessor Core Tests\n"); |
|
numtests(); |
coretests(); |
|
return EXIT_SUCCESS; |
} |
|
/* |
$Log: not supported by cvs2svn $ |
Revision 1.5 2008/04/26 19:32:00 sybreon |
Made headers C compatible. |
|
Revision 1.4 2008/04/26 18:08:12 sybreon |
Made single-thread compatible. |
|
/trunk/sw/cc/aemb/stack.hh
1,4 → 1,4
/* $Id: stack.hh,v 1.5 2008-04-26 19:31:35 sybreon Exp $ |
/* $Id: stack.hh,v 1.6 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB2 HI-PERFORMANCE CPU |
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net> |
100,7 → 100,7
@param endp end of the stack |
*/ |
|
inline void dupStack(int *newp, int *oldp, int *endp) |
inline void dupStack(unsigned int *newp, unsigned int *oldp, unsigned int *endp) |
{ |
while (oldp < endp) |
{ |
121,6 → 121,9
|
/* |
$Log: not supported by cvs2svn $ |
Revision 1.5 2008/04/26 19:31:35 sybreon |
Made headers C compatible. |
|
Revision 1.4 2008/04/26 18:04:31 sybreon |
Updated software to freeze T0 and run T1. |
|
/trunk/sw/cc/aemb/hook.hh
1,4 → 1,4
/* $Id: hook.hh,v 1.7 2008-04-26 19:31:35 sybreon Exp $ |
/* $Id: hook.hh,v 1.8 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB2 HI-PERFORMANCE CPU |
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net> |
90,9 → 90,11
if (isThread0()) // main thread |
{ |
// NOTE: Dupe the stack otherwise it will FAIL! |
dupStack((int *)setStack(getStack() - (getStackSize() >> 1)), |
(int *)getStack(), |
(int *)getStackTop); |
int oldstk = getStack(); |
int newstk = setStack(getStack() - (getStackSize() >> 1)); |
dupStack((unsigned int *)newstk, |
(unsigned int *)oldstk, |
(unsigned int *)getStackTop()); |
signalMutex(); // exit critical section |
while (1) asm volatile ("nop"); // lock thread |
} |
136,11 → 138,14
// The main programme needs to be compiled with optimisations turned |
// on (at least -O1). If not, the MUTEX value will be written to the |
// same RAM location, giving both threads the same value. |
OPTIMISATION_REQUIRED XXX |
OPTIMISATION_REQUIRED OPTIMISATION_REQUIRED |
#endif |
|
/* |
$Log: not supported by cvs2svn $ |
Revision 1.7 2008/04/26 19:31:35 sybreon |
Made headers C compatible. |
|
Revision 1.6 2008/04/26 18:04:31 sybreon |
Updated software to freeze T0 and run T1. |
|
/trunk/sw/cc/literate.hh
1,4 → 1,4
/* $Id: literate.hh,v 1.4 2008-04-26 18:07:19 sybreon Exp $ |
/* $Id: literate.hh,v 1.5 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB Function Verification C++ Testbench |
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net> |
225,5 → 225,5
#endif |
|
/* |
$log$ |
$Log: not supported by cvs2svn $ |
*/ |
/trunk/sw/cc/simboard.hh
1,4 → 1,4
/* $Id: simboard.hh,v 1.4 2008-04-26 19:32:00 sybreon Exp $ |
/* $Id: simboard.hh,v 1.5 2008-04-27 16:04:42 sybreon Exp $ |
** |
** AEMB Function Verification C++ Testbench |
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net> |
38,57 → 38,6
using namespace aemb; |
#endif |
|
volatile int intr = -1; |
|
void __attribute__ ((interrupt_handler)) interruptHandler() |
{ |
intr = 0; // flag the interrupt service routine |
} |
|
int interruptTest(int timeout) |
{ |
enableInterrupts(); |
int timer; |
for (timer=0; (timer < timeout) && (intr == -1); ++timer); // delay loop |
disableInterrupts(); |
return (intr == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
} |
|
|
/** |
FSL TEST ROUTINE |
*/ |
|
int xslTest (int code) |
{ |
// TEST FSL1 ONLY |
int FSL = code; |
|
asm ("PUT %0, RFSL1" :: "r"(FSL)); |
asm ("GET %0, RFSL1" : "=r"(FSL)); |
|
if (FSL != code) return EXIT_FAILURE; |
|
asm ("PUT %0, RFSL31" :: "r"(FSL)); |
asm ("GET %0, RFSL31" : "=r"(FSL)); |
|
if (FSL != code) return EXIT_FAILURE; |
|
return EXIT_SUCCESS; |
} |
|
/** |
MALLOC TEST |
Works well with newlib malloc routine. Do some patterned tests. |
*/ |
|
int memoryTest(int size) |
{ |
void *alloc; |
alloc = malloc(size * sizeof(int)); // allocate 32 byte |
return (alloc == NULL) ? EXIT_FAILURE : EXIT_SUCCESS; |
} |
|
/* |
I/O FUNCTIONS |
*/ |
127,6 → 76,9
|
/* |
$Log: not supported by cvs2svn $ |
Revision 1.4 2008/04/26 19:32:00 sybreon |
Made headers C compatible. |
|
Revision 1.3 2008/04/26 18:07:19 sybreon |
Minor cosmetic changes. |
|