OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
IDFValidator Class Reference

#include <IDFValidator.hh>

Collaboration diagram for IDFValidator:
Collaboration graph

Public Member Functions

 IDFValidator (const IDF::MachineImplementation &idf, const TTAMachine::Machine &machine)
 
virtual ~IDFValidator ()
 
bool validate ()
 
int errorCount () const
 
std::string errorMessage (int index) const
 

Static Public Member Functions

static void removeUnknownImplementations (IDF::MachineImplementation &idf, const TTAMachine::Machine &machine)
 

Private Types

typedef std::vector< std::string > StringVector
 Vector type for string.
 

Private Member Functions

void checkFUImplementations ()
 
void checkRFImplementations ()
 
void checkIUImplementations ()
 

Private Attributes

const TTAMachine::Machinemachine_
 The machine.
 
const IDF::MachineImplementationidf_
 The implementation definition,.
 
StringVector errorMessages_
 Vector of error messages.
 

Detailed Description

Validates IDF files.

Definition at line 52 of file IDFValidator.hh.

Member Typedef Documentation

◆ StringVector

typedef std::vector<std::string> IDFValidator::StringVector
private

Vector type for string.

Definition at line 69 of file IDFValidator.hh.

Constructor & Destructor Documentation

◆ IDFValidator()

IDFValidator::IDFValidator ( const IDF::MachineImplementation idf,
const TTAMachine::Machine machine 
)

The constructor.

Definition at line 45 of file IDFValidator.cc.

47 :
48 machine_(machine), idf_(idf) {
49}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
const IDF::MachineImplementation & idf_
The implementation definition,.
const TTAMachine::Machine & machine_
The machine.

◆ ~IDFValidator()

IDFValidator::~IDFValidator ( )
virtual

The destructor.

Definition at line 55 of file IDFValidator.cc.

55 {
56}

Member Function Documentation

◆ checkFUImplementations()

void IDFValidator::checkFUImplementations ( )
private

Checks that the IDF defines an implementation for each FU in the machine.

If errors are found, error messages are inserted to the vector of error messages.

Definition at line 109 of file IDFValidator.cc.

109 {
110
113
114 for (int i = 0; i < fuNav.count(); i++) {
115 const FunctionUnit* fu = fuNav.item(i);
116 if (!idf_.hasFUImplementation(fu->name()) &&
117 !idf_.hasFUGeneration(fu->name())) {
118 format errorMsg(
119 "IDF does not define an implementation for "
120 " function unit %1%.");
121
122 errorMsg % fu->name();
123 errorMessages_.push_back(errorMsg.str());
124 }
125 }
126
127 for (int i = 0; i < idf_.fuImplementationCount(); i++) {
129 if (!fuNav.hasItem(fui.unitName())) {
130 format errorMsg(
131 "IDF defines implementation for unknown "
132 "function unit %1%.");
133
134 errorMsg % fui.unitName();
135 errorMessages_.push_back(errorMsg.str());
136 }
137 }
138}
StringVector errorMessages_
Vector of error messages.
FUImplementationLocation & fuImplementation(const std::string &fu) const
bool hasFUGeneration(const std::string &name) const
bool hasFUImplementation(const std::string &unitName) const
virtual TCEString name() const
ComponentType * item(int index) const
bool hasItem(const std::string &name) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380

References TTAMachine::Machine::Navigator< ComponentType >::count(), errorMessages_, IDF::MachineImplementation::fuImplementation(), IDF::MachineImplementation::fuImplementationCount(), TTAMachine::Machine::functionUnitNavigator(), IDF::MachineImplementation::hasFUGeneration(), IDF::MachineImplementation::hasFUImplementation(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), idf_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), and IDF::UnitImplementationLocation::unitName().

Referenced by validate().

Here is the call graph for this function:

◆ checkIUImplementations()

void IDFValidator::checkIUImplementations ( )
private

Checks that the IDF defines an implementation for each IU in the machine.

If errors are found, error messages are inserted to the vector of error messages.

Definition at line 185 of file IDFValidator.cc.

185 {
186
189
190 for (int i = 0; i < iuNav.count(); i++) {
191 ImmediateUnit* iu = iuNav.item(i);
192 if (!idf_.hasIUImplementation(iu->name())) {
193 format errorMsg(
194 "IDF does not define an implementation for "
195 "immediate unit %1%.");
196
197 errorMsg % iu->name();
198 errorMessages_.push_back(errorMsg.str());
199 }
200 }
201
202 for (int i = 0; i < idf_.iuImplementationCount(); i++) {
204 if (!iuNav.hasItem(iui.unitName())) {
205 format errorMsg(
206 "IDF defines implementation for unknown immediate unit %1%.");
207
208 errorMsg % iui.unitName();
209 errorMessages_.push_back(errorMsg.str());
210 }
211 }
212}
RFImplementationLocation & iuImplementation(const std::string &iu) const
bool hasIUImplementation(const std::string &unitName) const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416

References TTAMachine::Machine::Navigator< ComponentType >::count(), errorMessages_, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), IDF::MachineImplementation::hasIUImplementation(), idf_, TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), IDF::MachineImplementation::iuImplementation(), IDF::MachineImplementation::iuImplementationCount(), machine_, TTAMachine::Component::name(), and IDF::UnitImplementationLocation::unitName().

Referenced by validate().

Here is the call graph for this function:

◆ checkRFImplementations()

void IDFValidator::checkRFImplementations ( )
private

Checks that the IDF defines an implementation for each RF in the machine.

If errors are found, error messages are inserted to the vector of error messages.

Definition at line 148 of file IDFValidator.cc.

148 {
149
152
153 for (int i = 0; i < rfNav.count(); i++) {
154 RegisterFile* rf = rfNav.item(i);
155 if (!idf_.hasRFImplementation(rf->name())) {
156 format errorMsg(
157 "IDF does not define an implementation for "
158 "register file %1%.");
159
160 errorMsg % rf->name();
161 errorMessages_.push_back(errorMsg.str());
162 }
163 }
164
165 for (int i = 0; i < idf_.rfImplementationCount(); i++) {
167 if (!rfNav.hasItem(rfi.unitName())) {
168 format errorMsg(
169 "IDF defines implementation for unknown register file %1%.");
170
171 errorMsg % rfi.unitName();
172 errorMessages_.push_back(errorMsg.str());
173 }
174 }
175}
RFImplementationLocation & rfImplementation(const std::string &rf) const
bool hasRFImplementation(const std::string &unitName) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450

References TTAMachine::Machine::Navigator< ComponentType >::count(), errorMessages_, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), IDF::MachineImplementation::hasRFImplementation(), idf_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), TTAMachine::Machine::registerFileNavigator(), IDF::MachineImplementation::rfImplementation(), IDF::MachineImplementation::rfImplementationCount(), and IDF::UnitImplementationLocation::unitName().

Referenced by validate().

Here is the call graph for this function:

◆ errorCount()

int IDFValidator::errorCount ( ) const

Returns the number of errors found in the last validation.

Returns
The error count.

Definition at line 81 of file IDFValidator.cc.

81 {
82 return errorMessages_.size();
83}

References errorMessages_.

Referenced by errorMessage(), ProcessorImplementationWindow::onGenerateProcessor(), ProcessorImplementationWindow::onLoadIDF(), validate(), and validateIdf().

◆ errorMessage()

std::string IDFValidator::errorMessage ( int  index) const

Returns an error message by the given index.

Parameters
indexThe index.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of errors.

Definition at line 94 of file IDFValidator.cc.

94 {
95 if (index < 0 || index >= errorCount()) {
96 throw OutOfRange(__FILE__, __LINE__, __func__);
97 }
98
99 return errorMessages_[index];
100}
#define __func__
int errorCount() const

References __func__, errorCount(), and errorMessages_.

Referenced by ProGe::ProGeUI::generateProcessor(), ProcessorImplementationWindow::onGenerateProcessor(), ProcessorImplementationWindow::onLoadIDF(), and validateIdf().

Here is the call graph for this function:

◆ removeUnknownImplementations()

void IDFValidator::removeUnknownImplementations ( IDF::MachineImplementation idf,
const TTAMachine::Machine machine 
)
static

Static helper function for removing implementations to units that don't exist in the machine.

Parameters
idfIDF to remove extraneous implementations from.
machineMachine to check the IDF against.

Definition at line 223 of file IDFValidator.cc.

225 {
226
229
232
235
236 for (int i = 0; i < idf.iuImplementationCount(); i++) {
237 const RFImplementationLocation& iui = idf.iuImplementation(i);
238 if (!iuNav.hasItem(iui.unitName())) {
240 }
241 }
242
243 for (int i = 0; i < idf.rfImplementationCount(); i++) {
244 const RFImplementationLocation& rfi = idf.rfImplementation(i);
245 if (!rfNav.hasItem(rfi.unitName())) {
247 }
248 }
249
250 for (int i = 0; i < idf.fuImplementationCount(); i++) {
251 const FUImplementationLocation& fui = idf.fuImplementation(i);
252 if (!fuNav.hasItem(fui.unitName())) {
254 }
255 }
256}
void removeFUImplementation(const std::string &unitName)
void removeIUImplementation(const std::string &unitName)
void removeRFImplementation(const std::string &unitName)

References IDF::MachineImplementation::fuImplementation(), IDF::MachineImplementation::fuImplementationCount(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateUnitNavigator(), IDF::MachineImplementation::iuImplementation(), IDF::MachineImplementation::iuImplementationCount(), machine, TTAMachine::Machine::registerFileNavigator(), IDF::MachineImplementation::removeFUImplementation(), IDF::MachineImplementation::removeIUImplementation(), IDF::MachineImplementation::removeRFImplementation(), IDF::MachineImplementation::rfImplementation(), IDF::MachineImplementation::rfImplementationCount(), and IDF::UnitImplementationLocation::unitName().

Referenced by ProcessorImplementationWindow::onLoadIDF().

Here is the call graph for this function:

◆ validate()

bool IDFValidator::validate ( )

Validates the IDF by checking that the IDF has an implementation defined for all the units of the machine.

Returns
True if the IDF is valid, otherwise false.

Definition at line 66 of file IDFValidator.cc.

66 {
67 errorMessages_.clear();
71 return errorCount() == 0;
72}
void checkRFImplementations()
void checkFUImplementations()
void checkIUImplementations()

References checkFUImplementations(), checkIUImplementations(), checkRFImplementations(), errorCount(), and errorMessages_.

Referenced by ProGe::ProGeUI::generateProcessor(), ProcessorImplementationWindow::onGenerateProcessor(), ProcessorImplementationWindow::onLoadIDF(), and validateIdf().

Here is the call graph for this function:

Member Data Documentation

◆ errorMessages_

StringVector IDFValidator::errorMessages_
private

Vector of error messages.

Definition at line 80 of file IDFValidator.hh.

Referenced by checkFUImplementations(), checkIUImplementations(), checkRFImplementations(), errorCount(), errorMessage(), and validate().

◆ idf_

const IDF::MachineImplementation& IDFValidator::idf_
private

The implementation definition,.

Definition at line 78 of file IDFValidator.hh.

Referenced by checkFUImplementations(), checkIUImplementations(), and checkRFImplementations().

◆ machine_

const TTAMachine::Machine& IDFValidator::machine_
private

The machine.

Definition at line 76 of file IDFValidator.hh.

Referenced by checkFUImplementations(), checkIUImplementations(), and checkRFImplementations().


The documentation for this class was generated from the following files: