OpenASIP
2.0
src
procgen
HDBEditor
TestHDB.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2010 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file TestHDB.cc
26
*
27
* HDB tester utility program
28
*
29
* @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30
* @note rating: red
31
*/
32
33
#include <cstdlib>
34
#include <iostream>
35
#include <string>
36
#include "
HDBTester.hh
"
37
#include "
TestHDBCmdLineOptions.hh
"
38
using
std::string;
39
40
const
string
GHDL_SIM
=
"ghdl"
;
41
const
string
VSIM_SIM
=
"modelsim"
;
42
43
int
main
(
int
argc,
char
* argv[]) {
44
45
TestHDBCmdLineOptions
options
;
46
try
{
47
options
.
parse
(argv, argc);
48
}
catch
(
ParserStopRequest
) {
49
return
EXIT_SUCCESS;
50
}
catch
(
const
IllegalCommandLine
& exception) {
51
std::cerr << exception.
errorMessage
() << std::endl;
52
return
EXIT_FAILURE;
53
}
54
string
hdbFile =
""
;
55
if
(
options
.
numberOfArguments
() < 1) {
56
std::cerr <<
"HDB file was not given"
<< std::endl;
57
options
.
printHelp
();
58
return
EXIT_FAILURE;
59
}
else
if
(
options
.
numberOfArguments
() > 1) {
60
std::cerr <<
"Illegal arguments"
<< std::endl;
61
options
.
printHelp
();
62
return
EXIT_FAILURE;
63
}
else
{
64
hdbFile =
options
.hdbFile();
65
}
66
67
string
simulator =
options
.vhdlSim();
68
VhdlSim
sim =
SIM_GHDL
;
69
if
(simulator ==
VSIM_SIM
) {
70
sim =
SIM_MODELSIM
;
71
}
else
if
(simulator ==
GHDL_SIM
|| simulator.empty()) {
72
sim =
SIM_GHDL
;
73
}
else
{
74
std::cerr <<
"Unknown HDL simulator"
<< simulator << std::endl;
75
options
.
printHelp
();
76
return
EXIT_FAILURE;
77
}
78
79
bool
verbose =
options
.verbose();
80
bool
leaveDirty =
options
.leaveDirty();
81
82
HDBTester
tester(std::cout, std::cerr, sim, verbose, leaveDirty);
83
84
bool
testAll =
true
;
85
if
(
options
.isFUEntryIDGiven()) {
86
testAll =
false
;
87
int
entryID =
options
.fuEntryID();
88
if
(!tester.
testOneFU
(hdbFile, entryID)) {
89
return
EXIT_FAILURE;
90
}
91
}
92
if
(
options
.isRFEntryIDGiven()) {
93
testAll =
false
;
94
int
entryID =
options
.rfEntryID();
95
if
(!tester.
testOneRF
(hdbFile, entryID)) {
96
return
EXIT_FAILURE;
97
}
98
}
99
if
(testAll) {
100
if
(!tester.
testAllEntries
(hdbFile)) {
101
return
EXIT_FAILURE;
102
}
103
}
104
105
return
EXIT_SUCCESS;
106
}
MachInfoCmdLineOptions::printHelp
virtual void printHelp() const
Definition:
MachInfoCmdLineOptions.cc:89
TestHDBCmdLineOptions.hh
ParserStopRequest
Definition:
Exception.hh:491
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
GHDL_SIM
const string GHDL_SIM
Definition:
TestHDB.cc:40
IllegalCommandLine
Definition:
Exception.hh:438
HDBTester.hh
main
int main(int argc, char *argv[])
Definition:
TestHDB.cc:43
SIM_GHDL
@ SIM_GHDL
Definition:
ImplementationTester.hh:48
VhdlSim
VhdlSim
Definition:
ImplementationTester.hh:47
HDBTester
Definition:
HDBTester.hh:39
HDBTester::testOneRF
bool testOneRF(std::string hdbFile, int entryId)
Definition:
HDBTester.cc:92
Exception::errorMessage
std::string errorMessage() const
Definition:
Exception.cc:123
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition:
CmdLineOptions.cc:107
options
static MachInfoCmdLineOptions options
Definition:
MachInfo.cc:46
HDBTester::testAllEntries
bool testAllEntries(std::string hdbFile)
Definition:
HDBTester.cc:62
TestHDBCmdLineOptions
Definition:
TestHDBCmdLineOptions.hh:39
HDBTester::testOneFU
bool testOneFU(std::string hdbFile, int entryId)
Definition:
HDBTester.cc:110
VSIM_SIM
const string VSIM_SIM
Definition:
TestHDB.cc:41
SIM_MODELSIM
@ SIM_MODELSIM
Definition:
ImplementationTester.hh:49
Generated by
1.8.17