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

#include <MachineValidator.hh>

Collaboration diagram for MachineValidator:
Collaboration graph

Public Types

enum  ErrorCode {
  GCU_MISSING , GCU_AS_MISSING , USED_IO_NOT_BOUND , DIFFERENT_PORT_FOR_JUMP_AND_CALL ,
  PC_PORT_MISSING , RA_PORT_MISSING , PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH , IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC ,
  FU_NO_VALID_OPERATIONS , FU_PORT_MISSING
}
 Error codes for different errors. More...
 

Public Member Functions

 MachineValidator (const TTAMachine::Machine &machine)
 
virtual ~MachineValidator ()
 
MachineValidatorResultsvalidate (const std::set< ErrorCode > &errorsToCheck) const
 

Private Member Functions

void checkGCUExists (MachineValidatorResults &results) const
 
void checkGCUHasAddressSpace (MachineValidatorResults &results) const
 
void checkOperandBindings (MachineValidatorResults &results) const
 
void checkJumpAndCallOperandBindings (MachineValidatorResults &results) const
 
void checkProgramCounterPort (MachineValidatorResults &results) const
 
void checkReturnAddressPort (MachineValidatorResults &results) const
 
void checkRAPortHasSameWidthAsPCPort (MachineValidatorResults &results) const
 
void checkIMemAddrWidth (MachineValidatorResults &results) const
 
void checkFUConnections (MachineValidatorResults &results) const
 

Private Attributes

const TTAMachine::Machinemachine_
 The machine to validate.
 

Detailed Description

Validator of target architecture definitions (machines). It tests a given machine against various criteria (completeness, implementation-dependent restrictions to structure, synthesisability).

Definition at line 52 of file MachineValidator.hh.

Member Enumeration Documentation

◆ ErrorCode

Error codes for different errors.

Enumerator
GCU_MISSING 

GCU missing in machine.

GCU_AS_MISSING 

Address space missing in GCU.

USED_IO_NOT_BOUND 

Pipeline uses an IO which is not bound.

DIFFERENT_PORT_FOR_JUMP_AND_CALL 

JUMP and CALL uses different port in GCU.

PC_PORT_MISSING 

PC port missing in GCU.

RA_PORT_MISSING 

RA port missing in GCU.

PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH 

RA and PC ports have unequal width.

IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC 

Instruction memory address width differs from PC/RA port width.

FU_NO_VALID_OPERATIONS 

FU has no operations with a trigger.

FU_PORT_MISSING 

FU is missing ports.

Definition at line 55 of file MachineValidator.hh.

55 {
56 /// GCU missing in machine.
58 /// Address space missing in GCU.
60 /// Pipeline uses an IO which is not bound.
62 /// JUMP and CALL uses different port in GCU.
64 /// PC port missing in GCU.
66 /// RA port missing in GCU.
68 /// RA and PC ports have unequal width.
70 /// Instruction memory address width differs from PC/RA port width.
72 /// FU has no operations with a trigger
74 /// FU is missing ports
76 };
@ PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH
RA and PC ports have unequal width.
@ IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC
Instruction memory address width differs from PC/RA port width.
@ GCU_AS_MISSING
Address space missing in GCU.
@ DIFFERENT_PORT_FOR_JUMP_AND_CALL
JUMP and CALL uses different port in GCU.
@ RA_PORT_MISSING
RA port missing in GCU.
@ FU_PORT_MISSING
FU is missing ports.
@ USED_IO_NOT_BOUND
Pipeline uses an IO which is not bound.
@ FU_NO_VALID_OPERATIONS
FU has no operations with a trigger.
@ GCU_MISSING
GCU missing in machine.
@ PC_PORT_MISSING
PC port missing in GCU.

Constructor & Destructor Documentation

◆ MachineValidator()

MachineValidator::MachineValidator ( const TTAMachine::Machine machine)

The constructor.

Parameters
machineThe machine to validate.

Definition at line 62 of file MachineValidator.cc.

62 :
64}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
const TTAMachine::Machine & machine_
The machine to validate.

◆ ~MachineValidator()

MachineValidator::~MachineValidator ( )
virtual

The destructor.

Definition at line 70 of file MachineValidator.cc.

70 {
71}

Member Function Documentation

◆ checkFUConnections()

void MachineValidator::checkFUConnections ( MachineValidatorResults results) const
private

Checks that the every FU has all the input and output ports that it needs.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 362 of file MachineValidator.cc.

362 {
365
366 for (int i = 0; i < fuNav.count(); i++) {
367 FunctionUnit& fu = *fuNav.item(i);
368 for (int p = 0; p < fu.operationPortCount(); p++) {
369 FUPort& port = *fu.operationPort(p);
370 if (port.socketCount() == 0) {
371 string errorMsg = "The machine has an FU with missing ports.";
372 results.addError(FU_PORT_MISSING, errorMsg);
373 }
374 }
375 }
376}
void addError(MachineValidator::ErrorCode code, const std::string &errorMsg)
virtual FUPort * operationPort(const std::string &name) const
virtual int operationPortCount() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual int socketCount() const
Definition Port.cc:375

References MachineValidatorResults::addError(), TTAMachine::Machine::Navigator< ComponentType >::count(), FU_PORT_MISSING, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), and TTAMachine::Port::socketCount().

Referenced by validate().

Here is the call graph for this function:

◆ checkGCUExists()

void MachineValidator::checkGCUExists ( MachineValidatorResults results) const
private

Checks that the machine has a control unit.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 120 of file MachineValidator.cc.

120 {
121 if (machine_.controlUnit() == NULL) {
122 string errorMsg = "The machine does not have a GCU.";
123 results.addError(GCU_MISSING, errorMsg);
124 }
125}
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References MachineValidatorResults::addError(), TTAMachine::Machine::controlUnit(), GCU_MISSING, and machine_.

Referenced by validate().

Here is the call graph for this function:

◆ checkGCUHasAddressSpace()

void MachineValidator::checkGCUHasAddressSpace ( MachineValidatorResults results) const
private

Checks that the GCU has an address space.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 134 of file MachineValidator.cc.

135 {
136
138 if (gcu == NULL) {
139 return;
140 }
141 if (gcu->addressSpace() == NULL) {
142 string errorMsg = "The GCU does not have an address space.";
143 results.addError(GCU_AS_MISSING, errorMsg);
144 }
145}
virtual AddressSpace * addressSpace() const

References MachineValidatorResults::addError(), TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::controlUnit(), GCU_AS_MISSING, and machine_.

Referenced by validate().

Here is the call graph for this function:

◆ checkIMemAddrWidth()

void MachineValidator::checkIMemAddrWidth ( MachineValidatorResults results) const
private

Checks that the address width of instruction memory is the same as PC and RA port width.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 309 of file MachineValidator.cc.

310 {
311
313 if (gcu == NULL) {
314 return;
315 }
316
317 AddressSpace* imem = gcu->addressSpace();
318 if (imem == NULL) {
319 return;
320 }
321
322 int addrWidth = MathTools::requiredBits(imem->end());
323
324 if (gcu->hasReturnAddressPort()) {
325 SpecialRegisterPort* raPort = gcu->returnAddressPort();
326 if (raPort->width() != addrWidth) {
327 string errorMsg =
328 "Return address port has different width than "
329 "instruction memory address.";
330 results.addError(
332 }
333 } else {
334 FUPort* pcPort = NULL;
335 if (gcu->hasOperation(JUMP)) {
336 HWOperation* jumpOp = gcu->operation(JUMP);
337 pcPort = jumpOp->port(1);
338 }
339 if (pcPort == NULL && gcu->hasOperation(CALL)) {
340 HWOperation* callOp = gcu->operation(CALL);
341 pcPort = callOp->port(1);
342 }
343
344 if (pcPort != NULL && pcPort->width() != addrWidth) {
345 string errorMsg =
346 "Program counter port has different width than instruction "
347 "memory address.";
348 results.addError(
350 }
351 }
352}
const string JUMP
const string CALL
static int requiredBits(unsigned long int number)
virtual ULongWord end() const
virtual int width() const
SpecialRegisterPort * returnAddressPort() const
bool hasReturnAddressPort() const
virtual HWOperation * operation(const std::string &name) const
virtual bool hasOperation(const std::string &name) const
virtual FUPort * port(int operand) const

References MachineValidatorResults::addError(), TTAMachine::FunctionUnit::addressSpace(), CALL, TTAMachine::Machine::controlUnit(), TTAMachine::AddressSpace::end(), TTAMachine::FunctionUnit::hasOperation(), TTAMachine::ControlUnit::hasReturnAddressPort(), IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC, JUMP, machine_, TTAMachine::FunctionUnit::operation(), TTAMachine::HWOperation::port(), MathTools::requiredBits(), TTAMachine::ControlUnit::returnAddressPort(), and TTAMachine::BaseFUPort::width().

Referenced by validate().

Here is the call graph for this function:

◆ checkJumpAndCallOperandBindings()

void MachineValidator::checkJumpAndCallOperandBindings ( MachineValidatorResults results) const
private

Checks that the operands of JUMP and CALL operations are bound to the same port in GCU.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 179 of file MachineValidator.cc.

180 {
181
183 if (gcu == NULL) {
184 return;
185 }
186
187 if (gcu->hasOperation(CALL) && gcu->hasOperation(JUMP)) {
188 HWOperation* callOp = gcu->operation(CALL);
189 HWOperation* jumpOp = gcu->operation(JUMP);
190 FUPort* pcPort1 = callOp->port(1);
191 FUPort* pcPort2 = jumpOp->port(1);
192
193 if (pcPort1 != NULL && pcPort2 != NULL && pcPort1 != pcPort2) {
194 string errorMsg =
195 "Operands of JUMP and CALL operations are not bound to the "
196 "same port in GCU.";
198 }
199 }
200}

References MachineValidatorResults::addError(), CALL, TTAMachine::Machine::controlUnit(), DIFFERENT_PORT_FOR_JUMP_AND_CALL, TTAMachine::FunctionUnit::hasOperation(), JUMP, machine_, TTAMachine::FunctionUnit::operation(), and TTAMachine::HWOperation::port().

Referenced by validate().

Here is the call graph for this function:

◆ checkOperandBindings()

void MachineValidator::checkOperandBindings ( MachineValidatorResults results) const
private

Checks that all the used operands of operations are bound to some port in function units.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 155 of file MachineValidator.cc.

156 {
157
159 for (int i = 0; i < fuNav.count(); i++) {
160 FunctionUnit* fu = fuNav.item(i);
162 }
163
164 // check GCU too
166 if (gcu != NULL) {
168 }
169}
static void checkOperandBindings(const TTAMachine::FunctionUnit &fu, MachineValidatorResults &results)

References FUValidator::checkOperandBindings(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and machine_.

Referenced by validate().

Here is the call graph for this function:

◆ checkProgramCounterPort()

void MachineValidator::checkProgramCounterPort ( MachineValidatorResults results) const
private

Checks that the GCU has a PC port if it has JUMP or CALL operation.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 209 of file MachineValidator.cc.

210 {
211
213 if (gcu == NULL) {
214 return;
215 }
216
217 if (gcu->hasOperation(CALL)) {
218 HWOperation* callOp = gcu->operation(CALL);
219 FUPort* pcPort = callOp->port(1);
220 if (pcPort == NULL) {
221 string errorMsg =
222 "Operand 1 of CALL operation is not bound to any port.";
223 results.addError(PC_PORT_MISSING, errorMsg);
224 }
225 }
226
227 if (gcu->hasOperation(JUMP)) {
228 HWOperation* jumpOp = gcu->operation(JUMP);
229 FUPort* pcPort = jumpOp->port(1);
230 if (pcPort == NULL) {
231 string errorMsg =
232 "Operand 1 of JUMP operation is not bound to any port.";
233 results.addError(PC_PORT_MISSING, errorMsg);
234 }
235 }
236}

References MachineValidatorResults::addError(), CALL, TTAMachine::Machine::controlUnit(), TTAMachine::FunctionUnit::hasOperation(), JUMP, machine_, TTAMachine::FunctionUnit::operation(), PC_PORT_MISSING, and TTAMachine::HWOperation::port().

Referenced by validate().

Here is the call graph for this function:

◆ checkRAPortHasSameWidthAsPCPort()

void MachineValidator::checkRAPortHasSameWidthAsPCPort ( MachineValidatorResults results) const
private

Checks that the return address port has the same width as program counter port if both exists.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 271 of file MachineValidator.cc.

272 {
273
275 if (gcu == NULL) {
276 return;
277 }
278 if (!gcu->hasReturnAddressPort()) {
279 return;
280 }
281
282 SpecialRegisterPort* raPort = gcu->returnAddressPort();
283 if (gcu->hasOperation(CALL)) {
284 FUPort* pcPort = gcu->operation(CALL)->port(1);
285 if (pcPort != NULL && pcPort->width() != raPort->width()) {
286 string errorMsg = "PC and RA ports have unequal width.";
288 return;
289 }
290 }
291 if (gcu->hasOperation(JUMP)) {
292 FUPort* pcPort = gcu->operation(JUMP)->port(1);
293 if (pcPort != NULL && pcPort->width() != raPort->width()) {
294 string errorMsg = "PC and RA ports have unequal width.";
296 return;
297 }
298 }
299}

References MachineValidatorResults::addError(), CALL, TTAMachine::Machine::controlUnit(), TTAMachine::FunctionUnit::hasOperation(), TTAMachine::ControlUnit::hasReturnAddressPort(), JUMP, machine_, TTAMachine::FunctionUnit::operation(), PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH, TTAMachine::HWOperation::port(), TTAMachine::ControlUnit::returnAddressPort(), and TTAMachine::BaseFUPort::width().

Referenced by validate().

Here is the call graph for this function:

◆ checkReturnAddressPort()

void MachineValidator::checkReturnAddressPort ( MachineValidatorResults results) const
private

Checks that the GCU has return address port if it has CALL operation.

Parameters
resultsResults of the validation are added to the given instance.

Definition at line 245 of file MachineValidator.cc.

246 {
247
249 if (gcu == NULL) {
250 return;
251 }
252
253 if (gcu->hasOperation(CALL)) {
254 if (!gcu->hasReturnAddressPort()) {
255 string errorMsg =
256 "GCU does not have return address port which is needed by "
257 "CALL operation.";
258 results.addError(RA_PORT_MISSING, errorMsg);
259 }
260 }
261}

References MachineValidatorResults::addError(), CALL, TTAMachine::Machine::controlUnit(), TTAMachine::FunctionUnit::hasOperation(), TTAMachine::ControlUnit::hasReturnAddressPort(), machine_, and RA_PORT_MISSING.

Referenced by validate().

Here is the call graph for this function:

◆ validate()

MachineValidatorResults * MachineValidator::validate ( const std::set< ErrorCode > &  errorsToCheck) const

Validates the machine.

Parameters
errorsToCheckContains the error codes for the errors to check.
Returns
Results of the validation.

Definition at line 81 of file MachineValidator.cc.

81 {
82
84 for (std::set<ErrorCode>::const_iterator iter = errorsToCheck.begin();
85 iter != errorsToCheck.end(); iter++) {
86 ErrorCode code = *iter;
87 if (code == GCU_MISSING) {
88 checkGCUExists(*results);
89 } else if (code == GCU_AS_MISSING) {
91 } else if (code == USED_IO_NOT_BOUND) {
92 checkOperandBindings(*results);
93 } else if (code == DIFFERENT_PORT_FOR_JUMP_AND_CALL) {
95 } else if (code == PC_PORT_MISSING) {
97 } else if (code == RA_PORT_MISSING) {
98 checkReturnAddressPort(*results);
99 } else if (code == PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH) {
101 } else if (code == IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC) {
102 checkIMemAddrWidth(*results);
103 } else if (code == FU_PORT_MISSING) {
104 checkFUConnections(*results);
105 } else {
106 assert(false);
107 }
108 }
109
110 return results;
111}
#define assert(condition)
void checkProgramCounterPort(MachineValidatorResults &results) const
void checkGCUHasAddressSpace(MachineValidatorResults &results) const
void checkReturnAddressPort(MachineValidatorResults &results) const
void checkOperandBindings(MachineValidatorResults &results) const
void checkFUConnections(MachineValidatorResults &results) const
void checkRAPortHasSameWidthAsPCPort(MachineValidatorResults &results) const
void checkGCUExists(MachineValidatorResults &results) const
ErrorCode
Error codes for different errors.
void checkIMemAddrWidth(MachineValidatorResults &results) const
void checkJumpAndCallOperandBindings(MachineValidatorResults &results) const

References assert, checkFUConnections(), checkGCUExists(), checkGCUHasAddressSpace(), checkIMemAddrWidth(), checkJumpAndCallOperandBindings(), checkOperandBindings(), checkProgramCounterPort(), checkRAPortHasSameWidthAsPCPort(), checkReturnAddressPort(), DIFFERENT_PORT_FOR_JUMP_AND_CALL, FU_PORT_MISSING, GCU_AS_MISSING, GCU_MISSING, IMEM_ADDR_WIDTH_DIFFERS_FROM_RA_AND_PC, PC_AND_RA_PORTS_HAVE_UNEQUAL_WIDTH, PC_PORT_MISSING, RA_PORT_MISSING, and USED_IO_NOT_BOUND.

Referenced by LLVMBackend::compile(), ProgrammabilityValidator::ProgrammabilityValidator(), and ProGe::ProcessorGenerator::validateMachine().

Here is the call graph for this function:

Member Data Documentation

◆ machine_

const TTAMachine::Machine& MachineValidator::machine_
private

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