OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HDBTester Class Reference

#include <HDBTester.hh>

Collaboration diagram for HDBTester:
Collaboration graph

Public Member Functions

 HDBTester ()
 
 HDBTester (std::ostream &infoStream, std::ostream &errorStream, VhdlSim simulator, bool verbose, bool leaveDirty)
 
virtual ~HDBTester ()
 
bool testAllEntries (std::string hdbFile)
 
bool testOneRF (std::string hdbFile, int entryId)
 
bool testOneFU (std::string hdbFile, int entryId)
 

Private Member Functions

ImplementationTesterinitializeTester (std::string hdbFile)
 
bool testFU (int id, ImplementationTester *tester)
 
bool testRF (int id, ImplementationTester *tester)
 

Private Attributes

std::ostream * infoStream_
 
std::ostream * errorStream_
 
VhdlSim sim_
 
bool verbose_
 
bool leaveDirty_
 

Detailed Description

Definition at line 39 of file HDBTester.hh.

Constructor & Destructor Documentation

◆ HDBTester() [1/2]

HDBTester::HDBTester ( )

Definition at line 43 of file HDBTester.cc.

43  : infoStream_(NULL), errorStream_(NULL), sim_(SIM_GHDL),
44  verbose_(false), leaveDirty_(false) {
45 }

◆ HDBTester() [2/2]

HDBTester::HDBTester ( std::ostream &  infoStream,
std::ostream &  errorStream,
VhdlSim  simulator,
bool  verbose,
bool  leaveDirty 
)

Definition at line 47 of file HDBTester.cc.

50  :
51  infoStream_(&infoStream), errorStream_(&errorStream), sim_(simulator),
52  verbose_(verbose), leaveDirty_(leaveDirty) {
53 }

◆ ~HDBTester()

HDBTester::~HDBTester ( )
virtual

Definition at line 55 of file HDBTester.cc.

55  {
56  // clear hdb cache
58  delete registry;
59 }

References HDB::HDBRegistry::instance().

Here is the call graph for this function:

Member Function Documentation

◆ initializeTester()

ImplementationTester * HDBTester::initializeTester ( std::string  hdbFile)
private

Definition at line 128 of file HDBTester.cc.

128  {
129 
130  ImplementationTester* tester = NULL;
131  try {
132  tester =
134  } catch (Exception& e) {
135  if (errorStream_ != NULL) {
136  *errorStream_ << "Failed to create implementation tester: "
137  << e.errorMessage() << std::endl;
138  }
139  return NULL;
140  }
141  return tester;
142 }

References Exception::errorMessage(), errorStream_, leaveDirty_, sim_, and verbose_.

Referenced by testAllEntries(), testOneFU(), and testOneRF().

Here is the call graph for this function:

◆ testAllEntries()

bool HDBTester::testAllEntries ( std::string  hdbFile)

Definition at line 62 of file HDBTester.cc.

62  {
63 
64  ImplementationTester* implTester = initializeTester(hdbFile);
65  if (implTester == NULL) {
66  return false;
67  }
68 
69  bool noFailures = true;
70  set<int> fus = implTester->fuEntryIDs();
71  for (set<int>::iterator iter = fus.begin(); iter != fus.end(); iter++) {
72  if (!testFU(*iter, implTester)) {
73  noFailures = false;
74  std::cerr << "FU Entry " << *iter << " from " << hdbFile
75  << " failed." << std::endl;
76  }
77  }
78 
79  set<int> rfs = implTester->rfEntryIDs();
80  for (set<int>::iterator iter = rfs.begin(); iter != rfs.end(); iter++) {
81  if (!testRF(*iter, implTester)) {
82  noFailures = false;
83  std::cerr << "RF Entry " << *iter << " from " << hdbFile
84  << " failed." << std::endl;
85  }
86  }
87  delete implTester;
88  return noFailures;
89 }

References ImplementationTester::fuEntryIDs(), initializeTester(), ImplementationTester::rfEntryIDs(), testFU(), and testRF().

Referenced by main().

Here is the call graph for this function:

◆ testFU()

bool HDBTester::testFU ( int  id,
ImplementationTester tester 
)
private

Definition at line 145 of file HDBTester.cc.

145  {
146 
147  string reason = "";
148  if (!tester->canTestFU(id, reason)) {
149  if (infoStream_ != NULL) {
150  *infoStream_ << "Cannot test FU id " << id << " because: "
151  << reason << std::endl;
152  }
153  // this is not failure
154  return true;
155  }
156  vector<string> errors;
157  bool success = false;
158  try {
159  success = tester->validateFU(id, errors);
160  } catch (Exception& e) {
161  if (errorStream_ != NULL) {
162  *errorStream_
163  << "Runtime error: " << e.errorMessage() << std::endl;
164  }
165  return false;
166  }
167  if (!errors.empty()) {
168  if (errorStream_ != NULL) {
169  for (unsigned int i = 0; i < errors.size(); i++) {
170  *errorStream_ << errors.at(i);
171  }
172  }
173  success = false;
174  }
175  return success;
176 }

References ImplementationTester::canTestFU(), Exception::errorMessage(), errorStream_, infoStream_, and ImplementationTester::validateFU().

Referenced by testAllEntries(), and testOneFU().

Here is the call graph for this function:

◆ testOneFU()

bool HDBTester::testOneFU ( std::string  hdbFile,
int  entryId 
)

Definition at line 110 of file HDBTester.cc.

110  {
111 
112  ImplementationTester* implTester = initializeTester(hdbFile);
113  if (implTester == NULL) {
114  return false;
115  }
116  bool success = testFU(entryId, implTester);
117  delete implTester;
118 
119  if (!success) {
120  std::cerr << "FU Entry " << entryId << " from " << hdbFile
121  << " failed." << std::endl;
122  }
123 
124  return success;
125 }

References initializeTester(), and testFU().

Referenced by main(), and testUnits().

Here is the call graph for this function:

◆ testOneRF()

bool HDBTester::testOneRF ( std::string  hdbFile,
int  entryId 
)

Definition at line 92 of file HDBTester.cc.

92  {
93 
94  ImplementationTester* implTester = initializeTester(hdbFile);
95  if (implTester == NULL) {
96  return false;
97  }
98  bool success = testRF(entryId, implTester);
99  delete implTester;
100 
101  if (!success) {
102  std::cerr << "RF Entry " << entryId << " from " << hdbFile
103  << " failed." << std::endl;
104  }
105 
106  return success;
107 }

References initializeTester(), and testRF().

Referenced by main(), and testUnits().

Here is the call graph for this function:

◆ testRF()

bool HDBTester::testRF ( int  id,
ImplementationTester tester 
)
private

Definition at line 179 of file HDBTester.cc.

179  {
180 
181  string reason = "";
182  if (!tester->canTestRF(id, reason)) {
183  if (infoStream_ != NULL) {
184  *infoStream_ << "Cannot test RF id " << id << " because: "
185  << reason << std::endl;
186  }
187  // this is not failure
188  return true;
189  }
190  vector<string> errors;
191  bool success = false;
192  try {
193  success = tester->validateRF(id, errors);
194  } catch (Exception& e) {
195  if (errorStream_ != NULL) {
196  *errorStream_
197  << "Runtime error: " << e.errorMessage() << std::endl;
198  }
199  return false;
200  }
201  if (!errors.empty()) {
202  if (errorStream_ != NULL) {
203  for (unsigned int i = 0; i < errors.size(); i++) {
204  *errorStream_ << errors.at(i);
205  }
206  }
207  success = false;
208  }
209  return success;
210 }

References ImplementationTester::canTestRF(), Exception::errorMessage(), errorStream_, infoStream_, and ImplementationTester::validateRF().

Referenced by testAllEntries(), and testOneRF().

Here is the call graph for this function:

Member Data Documentation

◆ errorStream_

std::ostream* HDBTester::errorStream_
private

Definition at line 65 of file HDBTester.hh.

Referenced by initializeTester(), testFU(), and testRF().

◆ infoStream_

std::ostream* HDBTester::infoStream_
private

Definition at line 64 of file HDBTester.hh.

Referenced by testFU(), and testRF().

◆ leaveDirty_

bool HDBTester::leaveDirty_
private

Definition at line 68 of file HDBTester.hh.

Referenced by initializeTester().

◆ sim_

VhdlSim HDBTester::sim_
private

Definition at line 66 of file HDBTester.hh.

Referenced by initializeTester().

◆ verbose_

bool HDBTester::verbose_
private

Definition at line 67 of file HDBTester.hh.

Referenced by initializeTester().


The documentation for this class was generated from the following files:
HDBTester::sim_
VhdlSim sim_
Definition: HDBTester.hh:66
ImplementationTester::canTestRF
bool canTestRF(const int entryID, std::string &reason)
Definition: ImplementationTester.cc:219
ImplementationTester
Definition: ImplementationTester.hh:52
ImplementationTester::canTestFU
bool canTestFU(const int entryID, std::string &reason)
Definition: ImplementationTester.cc:175
HDBTester::errorStream_
std::ostream * errorStream_
Definition: HDBTester.hh:65
HDB::HDBRegistry
Definition: HDBRegistry.hh:46
SIM_GHDL
@ SIM_GHDL
Definition: ImplementationTester.hh:48
HDBTester::infoStream_
std::ostream * infoStream_
Definition: HDBTester.hh:64
Exception
Definition: Exception.hh:54
HDBTester::testFU
bool testFU(int id, ImplementationTester *tester)
Definition: HDBTester.cc:145
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
HDBTester::verbose_
bool verbose_
Definition: HDBTester.hh:67
HDBTester::leaveDirty_
bool leaveDirty_
Definition: HDBTester.hh:68
ImplementationTester::rfEntryIDs
std::set< int > rfEntryIDs() const
Definition: ImplementationTester.cc:382
ImplementationTester::fuEntryIDs
std::set< int > fuEntryIDs() const
Definition: ImplementationTester.cc:369
HDBTester::initializeTester
ImplementationTester * initializeTester(std::string hdbFile)
Definition: HDBTester.cc:128
HDBTester::testRF
bool testRF(int id, ImplementationTester *tester)
Definition: HDBTester.cc:179
ImplementationTester::validateFU
bool validateFU(const int entryID, std::vector< std::string > &errors)
Definition: ImplementationTester.cc:263
HDB::HDBRegistry::instance
static HDBRegistry & instance()
Definition: HDBRegistry.cc:62
ImplementationTester::validateRF
bool validateRF(const int entryID, std::vector< std::string > &errors)
Definition: ImplementationTester.cc:321