/* $Id: testbench.cc,v 1.6 2008-04-27 16:04:42 sybreon Exp $
|
/* $Id: testbench.cc,v 1.6 2008-04-27 16:04:42 sybreon Exp $
|
**
|
**
|
** AEMB Function Verification C++ Testbench
|
** AEMB Function Verification C++ Testbench
|
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
|
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
|
**
|
**
|
** This file is part of AEMB.
|
** This file is part of AEMB.
|
**
|
**
|
** AEMB is free software: you can redistribute it and/or modify it
|
** AEMB is free software: you can redistribute it and/or modify it
|
** under the terms of the GNU General Public License as published by
|
** under the terms of the GNU General Public License as published by
|
** the Free Software Foundation, either version 3 of the License, or
|
** the Free Software Foundation, either version 3 of the License, or
|
** (at your option) any later version.
|
** (at your option) any later version.
|
**
|
**
|
** AEMB is distributed in the hope that it will be useful, but WITHOUT
|
** AEMB is distributed in the hope that it will be useful, but WITHOUT
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
** License for more details.
|
** License for more details.
|
**
|
**
|
** You should have received a copy of the GNU General Public License
|
** You should have received a copy of the GNU General Public License
|
** along with AEMB. If not, see <http://www.gnu.org/licenses/>.
|
** along with AEMB. If not, see <http://www.gnu.org/licenses/>.
|
*/
|
*/
|
/**
|
/**
|
AEMB Software Verification
|
AEMB Software Verification
|
@file testbench.cc
|
@file testbench.cc
|
|
|
This programme performs numerical and functional verification of the
|
This programme performs numerical and functional verification of the
|
AEMB. It can be compiled by the GCC compiler.
|
AEMB. It can be compiled by the GCC compiler.
|
*/
|
*/
|
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include "aemb/core.hh"
|
#include "aemb/core.hh"
|
#include "literate.hh"
|
#include "literate.hh"
|
#include "simboard.hh"
|
#include "simboard.hh"
|
#include "corefunc.hh"
|
#include "corefunc.hh"
|
|
|
#define MAX_TEST 3
|
#define MAX_TEST 3
|
|
|
void checkcode(int code)
|
void checkcode(int code)
|
{
|
{
|
if (code == EXIT_SUCCESS)
|
if (code == EXIT_SUCCESS)
|
iprintf("\t\t-PASS-\n");
|
iprintf("\t\t-PASS-\n");
|
else
|
else
|
iprintf("\t\t*FAIL*\n");
|
iprintf("\t\t*FAIL*\n");
|
}
|
}
|
|
|
void printtest(char *msg)
|
void printtest(char *msg)
|
{
|
{
|
static int count = 1;
|
static int count = 1;
|
iprintf("\t%d. %s\n",count++, msg);
|
iprintf("\t%d. %s\n",count++, msg);
|
}
|
}
|
|
|
void numtests()
|
void numtests()
|
{
|
{
|
// *** 1. FIBONACCI ***
|
// *** 1. FIBONACCI ***
|
printtest("Integer Arithmetic");
|
printtest("Integer Arithmetic");
|
checkcode(fibonacciTest(MAX_TEST));
|
checkcode(fibonacciTest(MAX_TEST));
|
|
|
// *** 2. EUCLIDEAN ***
|
// *** 2. EUCLIDEAN ***
|
printtest("Integer Factorisation");
|
printtest("Integer Factorisation");
|
checkcode(euclideanTest(MAX_TEST));
|
checkcode(euclideanTest(MAX_TEST));
|
|
|
// *** 3. NEWTON-RHAPSON ***
|
// *** 3. NEWTON-RHAPSON ***
|
printtest("Floating Point Arithmetic");
|
printtest("Floating Point Arithmetic");
|
checkcode(newtonTest(MAX_TEST));
|
checkcode(newtonTest(MAX_TEST));
|
|
|
}
|
}
|
|
|
void coretests()
|
void coretests()
|
{
|
{
|
// *** 4. MEMORY-ALLOC ***
|
// *** 4. MEMORY-ALLOC ***
|
printtest("Memory Allocation");
|
printtest("Memory Allocation");
|
checkcode(memoryTest(MAX_TEST));
|
checkcode(memoryTest(MAX_TEST));
|
|
|
// *** 5. INTERRUPT ***
|
// *** 5. INTERRUPT ***
|
printtest("Hardware Interrupts");
|
printtest("Hardware Interrupts");
|
checkcode(interruptTest(MAX_TEST));
|
checkcode(interruptTest(MAX_TEST));
|
|
|
// *** 6. EXTENSION ***
|
// *** 6. EXCEPTIONS ***
|
|
printtest("Hardware Exceptions");
|
|
checkcode(exceptionTest(MAX_TEST));
|
|
|
|
// *** 7. EXTENSION ***
|
printtest("Accellerator Link");
|
printtest("Accellerator Link");
|
checkcode(xslTest(MAX_TEST));
|
checkcode(xslTest(MAX_TEST));
|
}
|
}
|
|
|
// run tests
|
// run tests
|
int main()
|
int main()
|
{
|
{
|
iprintf("AEMB2 32-bit Microprocessor Core Tests\n");
|
iprintf("AEMB2 32-bit Microprocessor Core Tests\n");
|
|
|
numtests();
|
numtests();
|
coretests();
|
coretests();
|
|
|
return EXIT_SUCCESS;
|
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.
|
|
|
|
Revision 1.3 2008/04/26 00:25:19 sybreon
|
|
switched printf's to iprintf's because iprintf's don't work by
|
|
-O3 for some reason.
|
|
|
|
Revision 1.2 2008/04/21 12:13:12 sybreon
|
|
Passes arithmetic tests with single thread.
|
|
*/
|
|
|
|
No newline at end of file
|
No newline at end of file
|