OpenASIP 2.2
Loading...
Searching...
No Matches
Functions
TTAUnitTester.cc File Reference
#include <cstdlib>
#include <string>
#include <vector>
#include "MachineImplementation.hh"
#include "Machine.hh"
#include "ADFSerializer.hh"
#include "IDFSerializer.hh"
#include "IDFValidator.hh"
#include "TTAUnitTester.hh"
#include "HDBTester.hh"
#include "Exception.hh"
#include "UnitImplementationLocation.hh"
#include "TTAUnitTesterCmdLineOptions.hh"
Include dependency graph for TTAUnitTester.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 
TTAMachine::MachinereadAdf (std::string adfName)
 
IDF::MachineImplementationreadIdf (std::string idfName)
 
bool validateIdf (const IDF::MachineImplementation &idf, const TTAMachine::Machine &machine)
 
bool testUnits (const IDF::MachineImplementation &idf, VhdlSim simulator, bool verbose, bool leaveDirty)
 

Detailed Description

Implementation of TTAUnitTester utility program

Author
Otto Esko 2010 (otto.esko-no.spam-tut.fi)
Note
rating: red

Definition in file TTAUnitTester.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 48 of file TTAUnitTester.cc.

48 {
49
51 try {
52 options.parse(argv, argc);
53 } catch (ParserStopRequest const&) {
54 return EXIT_SUCCESS;
55 } catch (const IllegalCommandLine& exception) {
56 std::cerr << exception.errorMessage() << std::endl;
57 return EXIT_FAILURE;
58 }
59
60 string idfFile = "";
61 if (options.numberOfArguments() == 0) {
62 std::cerr << "IDF file was not given" << std::endl;
64 return EXIT_FAILURE;
65 } else if (options.numberOfArguments() > 1) {
66 std::cerr << "Illegal arguments" << std::endl;
68 return EXIT_FAILURE;
69 } else {
70 idfFile = options.idfFileName();
71 }
72
73 string adfFile = options.adfFileName();
74
75 string sim = options.vhdlSim();
76 VhdlSim simulator = SIM_GHDL;
77 if (sim == "modelsim") {
78 simulator = SIM_MODELSIM;
79 } else {
80 simulator = SIM_GHDL;
81 }
82
83 bool verbose = options.verbose();
84 bool leaveDirty = options.leaveDirty();
85
86 IDF::MachineImplementation* idf = readIdf(idfFile);
87 if (!idf) {
88 return EXIT_FAILURE;
89 }
90
91 // validate idf if adf was given
92 if (!adfFile.empty()) {
93 TTAMachine::Machine* mach = readAdf(adfFile);
94 if (!mach) {
95 return EXIT_FAILURE;
96 }
97 if (!validateIdf(*idf, *mach)) {
98 delete(mach);
99 delete(idf);
100 return EXIT_FAILURE;
101 }
102 delete(mach);
103 }
104
105 if (!testUnits(*idf, simulator, verbose, leaveDirty)) {
106 delete(idf);
107 return EXIT_FAILURE;
108 }
109
110 delete(idf);
111 return EXIT_SUCCESS;
112}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
TTAMachine::Machine * readAdf(std::string adfName)
IDF::MachineImplementation * readIdf(std::string idfName)
bool validateIdf(const IDF::MachineImplementation &idf, const TTAMachine::Machine &machine)
bool testUnits(const IDF::MachineImplementation &idf, VhdlSim simulator, bool verbose, bool leaveDirty)
void parse(char *argv[], int argc)
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
virtual void printHelp() const

References Exception::errorMessage(), CmdLineParser::numberOfArguments(), options, CmdLineOptions::parse(), MachInfoCmdLineOptions::printHelp(), readAdf(), readIdf(), SIM_GHDL, SIM_MODELSIM, testUnits(), and validateIdf().

Here is the call graph for this function:

◆ readAdf()

TTAMachine::Machine * readAdf ( std::string  adfName)

Definition at line 116 of file TTAUnitTester.cc.

116 {
117
118 ADFSerializer reader;
119 reader.setSourceFile(adfName);
120 TTAMachine::Machine* mach = NULL;
121 try {
122 mach = reader.readMachine();
123 } catch (Exception& e) {
124 std::cerr << "Failed to load ADF file " << adfName << ": "
125 << e.errorMessage() << std::endl;
126 return NULL;
127 }
128 return mach;
129}
TTAMachine::Machine * readMachine()
void setSourceFile(const std::string &fileName)

References Exception::errorMessage(), ADFSerializer::readMachine(), and XMLSerializer::setSourceFile().

Referenced by main().

Here is the call graph for this function:

◆ readIdf()

IDF::MachineImplementation * readIdf ( std::string  idfName)

Definition at line 133 of file TTAUnitTester.cc.

133 {
134
135 IDF::IDFSerializer reader;
136 reader.setSourceFile(idfName);
138 try {
140 } catch (Exception& e) {
141 std::cerr << "Failed to load IDF file " << idfName << ": "
142 << e.errorMessage() << std::endl;
143 return NULL;
144 }
145 return implementation;
146}
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
MachineImplementation * readMachineImplementation()

References Exception::errorMessage(), implementation, IDF::IDFSerializer::readMachineImplementation(), and XMLSerializer::setSourceFile().

Referenced by main().

Here is the call graph for this function:

◆ testUnits()

bool testUnits ( const IDF::MachineImplementation idf,
VhdlSim  simulator,
bool  verbose,
bool  leaveDirty 
)

Definition at line 167 of file TTAUnitTester.cc.

169 {
170
171 HDBTester tester(std::cout, std::cerr, simulator, verbose, leaveDirty);
172
173 bool allPassed = true;
174 for (int i = 0; i < idf.fuImplementationCount(); i++) {
176 string hdb = unit->hdbFile();
177 int entryId = unit->id();
178 if (!tester.testOneFU(hdb, entryId)) {
179 allPassed = false;
180 }
181 }
182
183 for (int i = 0; i < idf.rfImplementationCount(); i++) {
185 string hdb = unit->hdbFile();
186 int entryId = unit->id();
187 if (!tester.testOneRF(hdb, entryId)) {
188 allPassed = false;
189 }
190 }
191
192 return allPassed;
193}
RFImplementationLocation & rfImplementation(const std::string &rf) const
FUImplementationLocation & fuImplementation(const std::string &fu) const

References IDF::MachineImplementation::fuImplementation(), IDF::MachineImplementation::fuImplementationCount(), IDF::UnitImplementationLocation::hdbFile(), IDF::UnitImplementationLocation::id(), IDF::MachineImplementation::rfImplementation(), IDF::MachineImplementation::rfImplementationCount(), HDBTester::testOneFU(), and HDBTester::testOneRF().

Referenced by main().

Here is the call graph for this function:

◆ validateIdf()

bool validateIdf ( const IDF::MachineImplementation idf,
const TTAMachine::Machine machine 
)

Definition at line 150 of file TTAUnitTester.cc.

152 {
153
154 IDFValidator validator(idf, machine);
155
156 bool success = validator.validate();
157 if (!success) {
158 for (int i = 0; i < validator.errorCount(); i++) {
159 std::cerr << validator.errorMessage(i) << std::endl;
160 }
161 }
162 return success;
163}
TTAMachine::Machine * machine
the architecture definition of the estimated processor

References IDFValidator::errorCount(), IDFValidator::errorMessage(), machine, and IDFValidator::validate().

Referenced by main().

Here is the call graph for this function: