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

#include <BEMValidator.hh>

Collaboration diagram for BEMValidator:
Collaboration graph

Public Member Functions

 BEMValidator (const BinaryEncoding &bem, const TTAMachine::Machine &machine)
 
 ~BEMValidator ()
 
bool validate ()
 
int errorCount () const
 
std::string errorMessage (int index) const
 
int warningCount () const
 
std::string warningMessage (int index) const
 

Private Types

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

Private Member Functions

void checkMoveSlot (const TTAMachine::Bus &bus)
 
void checkDestinationField (const TTAMachine::Bus &bus)
 
void checkSourceField (const TTAMachine::Bus &bus)
 
void checkGuardField (const TTAMachine::Bus &bus)
 
void checkSocketCodeTable (const SocketEncoding &socketEnc)
 
void checkImmediateSlot (const TTAMachine::ImmediateSlot &immSlot)
 
void checkImmediateControlField ()
 
void checkLImmDstRegisterFields ()
 
void checkImemMauWidth (TTAMachine::ControlUnit &gcu)
 
bool needsSourceField (const MoveSlot &slot) const
 
bool needsSocketCodeTable (const SocketEncoding &socketEnc) const
 

Private Attributes

const BinaryEncodingbem_
 The binary encoding map. More...
 
const TTAMachine::Machinemachine_
 The machine. More...
 
StringVector errorMessages_
 Contains the error messages. More...
 
StringVector warningMessages_
 Contains the warning messages. More...
 

Detailed Description

Validates binary encoding maps against machines. Checks that the BEM contains all the required information.

Definition at line 57 of file BEMValidator.hh.

Member Typedef Documentation

◆ StringVector

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

Vector type for string.

Definition at line 72 of file BEMValidator.hh.

Constructor & Destructor Documentation

◆ BEMValidator()

BEMValidator::BEMValidator ( const BinaryEncoding bem,
const TTAMachine::Machine machine 
)

The constructor.

Parameters
bemThe binary encoding map.
machineThe machine.

Definition at line 72 of file BEMValidator.cc.

74  :
75  bem_(bem), machine_(machine) {
76 }

◆ ~BEMValidator()

BEMValidator::~BEMValidator ( )

The destructor.

Definition at line 82 of file BEMValidator.cc.

82  {
83 }

Member Function Documentation

◆ checkDestinationField()

void BEMValidator::checkDestinationField ( const TTAMachine::Bus bus)
private

Checks the destination field of the given bus for errors.

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

Definition at line 317 of file BEMValidator.cc.

317  {
318 
319  MoveSlot& moveSlot = bem_.moveSlot(bus.name());
320 
321  // collect the input sockets to a set
322  typedef std::set<Socket*> SocketSet;
323  SocketSet inputSockets;
324 
325  for (int i = 0; i < bus.segmentCount(); i++) {
326  Segment* segment = bus.segment(i);
327  for (int i = 0; i < segment->connectionCount(); i++) {
328  Socket* socket = segment->connection(i);
329  if (socket->portCount() > 0 &&
330  socket->direction() == Socket::INPUT) {
331  inputSockets.insert(socket);
332  }
333  }
334  }
335 
336  // check the destination field
337  if (inputSockets.size() > 1) {
338  if (!moveSlot.hasDestinationField()) {
339  format errorMsg(
340  "Move slot of bus %1% does not contain destination field.");
341  errorMsg % bus.name();
342  errorMessages_.push_back(errorMsg.str());
343  } else {
344  DestinationField& dstField = moveSlot.destinationField();
345  for (SocketSet::const_iterator iter = inputSockets.begin();
346  iter != inputSockets.end(); iter++) {
347  Socket* socket = *iter;
348  if (!dstField.hasSocketEncoding(socket->name())) {
349  format errorMsg(
350  "Destination field of move slot of bus %1% does not"
351  "have an encoding for socket %2%.");
352  errorMsg % bus.name() % socket->name();
353  errorMessages_.push_back(errorMsg.str());
354  } else {
355  SocketEncoding& socketEnc = dstField.socketEncoding(
356  socket->name());
357  if (needsSocketCodeTable(socketEnc)) {
358  if (!socketEnc.hasSocketCodes()) {
359  format errorMsg(
360  "Encoding of socket %1% in destination "
361  "field of move slot %2% does not refer to "
362  "any socket code table.");
363  errorMsg % socket->name() % bus.name();
364  errorMessages_.push_back(errorMsg.str());
365  } else {
366  checkSocketCodeTable(socketEnc);
367  }
368  }
369  }
370  }
371  }
372  }
373 }

References bem_, checkSocketCodeTable(), TTAMachine::Segment::connection(), TTAMachine::Segment::connectionCount(), MoveSlot::destinationField(), TTAMachine::Socket::direction(), errorMessages_, MoveSlot::hasDestinationField(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), BinaryEncoding::moveSlot(), TTAMachine::Component::name(), needsSocketCodeTable(), TTAMachine::Socket::portCount(), TTAMachine::Bus::segment(), TTAMachine::Bus::segmentCount(), and SlotField::socketEncoding().

Referenced by checkMoveSlot().

Here is the call graph for this function:

◆ checkGuardField()

void BEMValidator::checkGuardField ( const TTAMachine::Bus bus)
private

Checks the guard field of the given bus for errors.

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

Parameters
busThe bus.

Definition at line 385 of file BEMValidator.cc.

385  {
386 
387  MoveSlot& slot = bem_.moveSlot(bus.name());
388 
389  if (bus.guardCount() < 2) {
390  return;
391  } else if (!slot.hasGuardField()) {
392  format errorMsg("Move slot %1% does not contain guard field.");
393  errorMsg % bus.name();
394  errorMessages_.push_back(errorMsg.str());
395  return;
396  }
397 
398  GuardField& grdField = slot.guardField();
399 
400  for (int i = 0; i < bus.guardCount(); i++) {
401  Guard* guard = bus.guard(i);
402  UnconditionalGuard* ucGuard =
403  dynamic_cast<UnconditionalGuard*>(guard);
404  PortGuard* portGuard = dynamic_cast<PortGuard*>(guard);
405  RegisterGuard* regGuard = dynamic_cast<RegisterGuard*>(guard);
406  if (ucGuard != NULL &&
407  !grdField.hasUnconditionalGuardEncoding(ucGuard->isInverted())) {
408  format errorMsg(
409  "Guard field of move slot %1% does not have encoding "
410  "for always-%2% guard.");
411  errorMsg % bus.name();
412  if (ucGuard->isInverted()) {
413  errorMsg % "false";
414  } else {
415  errorMsg % "true";
416  }
417  errorMessages_.push_back(errorMsg.str());
418 
419  } else if (portGuard != NULL) {
420  FUPort* port = portGuard->port();
421  FunctionUnit* fu = port->parentUnit();
422  if (!grdField.hasFUGuardEncoding(
423  fu->name(), port->name(), portGuard->isInverted())) {
424  format errorMsg(
425  "Guard field of move slot %1% does not have encoding "
426  "for %2% FU port guard of port %3% of FU %4%.");
427  errorMsg % bus.name();
428  if (portGuard->isInverted()) {
429  errorMsg % "inverted";
430  } else {
431  errorMsg % "non-inverted";
432  }
433  errorMsg % port->name() % fu->name();
434  errorMessages_.push_back(errorMsg.str());
435  }
436  } else if (regGuard != NULL) {
437  string regFile = regGuard->registerFile()->name();
438  if (!grdField.hasGPRGuardEncoding(
439  regFile, regGuard->registerIndex(),
440  regGuard->isInverted())) {
441  format errorMsg(
442  "Guard field of move slot %1% does not have encoding "
443  "for %2% GPR guard of register %3% of register file "
444  "%4%.");
445  errorMsg % bus.name();
446  if (regGuard->isInverted()) {
447  errorMsg % "inverted";
448  } else {
449  errorMsg % "non-inverted";
450  }
451  errorMsg % regGuard->registerIndex() % regFile;
452  errorMessages_.push_back(errorMsg.str());
453  }
454  }
455  }
456 }

References bem_, errorMessages_, TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), MoveSlot::guardField(), GuardField::hasFUGuardEncoding(), GuardField::hasGPRGuardEncoding(), MoveSlot::hasGuardField(), GuardField::hasUnconditionalGuardEncoding(), TTAMachine::Guard::isInverted(), BinaryEncoding::moveSlot(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::PortGuard::port(), TTAMachine::RegisterGuard::registerFile(), and TTAMachine::RegisterGuard::registerIndex().

Referenced by checkMoveSlot().

Here is the call graph for this function:

◆ checkImemMauWidth()

void BEMValidator::checkImemMauWidth ( TTAMachine::ControlUnit gcu)
private

Checks that the instruction memory width (MAU) is greater or equal than the width of one instruction.

Parameters
gcuGlobal Control Unit of the machine

Definition at line 691 of file BEMValidator.cc.

691  {
692  int imemWidth = 0;
693  if (gcu.hasAddressSpace()) {
694  imemWidth = gcu.addressSpace()->width();
695  } else {
696  string errorMsg("GCU does not have an address space");
697  errorMessages_.push_back(errorMsg);
698  }
699  int instructionWidth = bem_.width();
700 
701  if (imemWidth < instructionWidth) {
702  string warningMsg(
703  "Warning: Instruction width is greater than the instruction "
704  "memory width.");
705  warningMessages_.push_back(warningMsg);
706  }
707 }

References TTAMachine::FunctionUnit::addressSpace(), bem_, errorMessages_, TTAMachine::FunctionUnit::hasAddressSpace(), warningMessages_, TTAMachine::AddressSpace::width(), and BinaryEncoding::width().

Here is the call graph for this function:

◆ checkImmediateControlField()

void BEMValidator::checkImmediateControlField ( )
private

Checks that the BEM contains a valid immediate control field.

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

Definition at line 596 of file BEMValidator.cc.

596  {
599  if (iTempNav.count() > 1) {
601  string errorMsg("BEM does not contain immediate control field.");
602  errorMessages_.push_back(errorMsg);
603  } else {
605  for (int i = 0; i < iTempNav.count(); i++) {
606  InstructionTemplate* iTemp = iTempNav.item(i);
607  if (!field.hasTemplateEncoding(iTemp->name())) {
608  format errorMsg(
609  "Immediate control field does not have encoding "
610  "for instruction template %1%.");
611  errorMsg % iTemp->name();
612  errorMessages_.push_back(errorMsg.str());
613  }
614  }
615  }
616  }
617 }

References bem_, TTAMachine::Machine::Navigator< ComponentType >::count(), errorMessages_, BinaryEncoding::hasImmediateControlField(), ImmediateControlField::hasTemplateEncoding(), BinaryEncoding::immediateControlField(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, and TTAMachine::Component::name().

Referenced by validate().

Here is the call graph for this function:

◆ checkImmediateSlot()

void BEMValidator::checkImmediateSlot ( const TTAMachine::ImmediateSlot immSlot)
private

Checks that the BEM contains a valid immediate slot field for the given immediate slot.

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

Parameters
immSlotThe immediate slot.

Definition at line 568 of file BEMValidator.cc.

568  {
569 
570  if (immSlot.width() == 0) {
571  return;
572  }
573 
574  if (!bem_.hasImmediateSlot(immSlot.name())) {
575  format errorMsg(
576  "BEM does not contain field for immediate slot %1%.");
577  errorMsg % immSlot.name();
578  errorMessages_.push_back(errorMsg.str());
579  } else {
580  ImmediateSlotField& field = bem_.immediateSlot(immSlot.name());
581  if (field.width() < immSlot.width()) {
582  format errorMsg("Immediate slot %1% is too narrow in BEM.");
583  errorMessages_.push_back(errorMsg.str());
584  }
585  }
586 }

References bem_, errorMessages_, BinaryEncoding::hasImmediateSlot(), BinaryEncoding::immediateSlot(), TTAMachine::Component::name(), TTAMachine::ImmediateSlot::width(), and ImmediateSlotField::width().

Referenced by validate().

Here is the call graph for this function:

◆ checkLImmDstRegisterFields()

void BEMValidator::checkLImmDstRegisterFields ( )
private

Checks that the BEM contains valid long immediate destination register fields.

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

Definition at line 628 of file BEMValidator.cc.

628  {
629 
634 
635  for (int i = 0; i < itNav.count(); i++) {
636 
637  InstructionTemplate* iTemp = itNav.item(i);
638  typedef std::set<std::string> StringSet;
639 
640  StringSet iTempDestinations;
641  for (int i = 0; i < iuNav.count(); i++) {
642  ImmediateUnit* iu = iuNav.item(i);
643  if (iTemp->isOneOfDestinations(*iu) &&
644  iu->numberOfRegisters() > 1) {
645  iTempDestinations.insert(iu->name());
646  }
647  }
648 
649  StringSet destinationsInBEM;
650  for (int i = 0; i < bem_.longImmDstRegisterFieldCount(); i++) {
652  if (field.usedByInstructionTemplate(iTemp->name())) {
653  string dstIU = field.immediateUnit(iTemp->name());
654  destinationsInBEM.insert(dstIU);
655  if (AssocTools::containsKey(iTempDestinations, dstIU)) {
656  ImmediateUnit* iu = iuNav.item(dstIU);
657  int regIndexWidth = MathTools::bitLength(
658  iu->numberOfRegisters() - 1);
659  if (field.width() < regIndexWidth) {
660  format errorMsg(
661  "Long immediate destination register field is "
662  "too narrow for destination %1% in instruction "
663  "template %2%.");
664  errorMsg % dstIU % iTemp->name();
665  errorMessages_.push_back(errorMsg.str());
666  }
667  }
668  }
669  }
670 
671  StringSet intersection;
673  iTempDestinations, destinationsInBEM, intersection);
674  if (intersection.size() < iTempDestinations.size()) {
675  format errorMsg(
676  "Long immediate destination register fields do not "
677  "cover all the destinations of instruction template %1%.");
678  errorMsg % iTemp->name();
679  errorMessages_.push_back(errorMsg.str());
680  }
681  }
682 }

References bem_, MathTools::bitLength(), AssocTools::containsKey(), TTAMachine::Machine::Navigator< ComponentType >::count(), errorMessages_, LImmDstRegisterField::immediateUnit(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::instructionTemplateNavigator(), SetTools::intersection(), TTAMachine::InstructionTemplate::isOneOfDestinations(), TTAMachine::Machine::Navigator< ComponentType >::item(), BinaryEncoding::longImmDstRegisterField(), BinaryEncoding::longImmDstRegisterFieldCount(), machine_, TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), LImmDstRegisterField::usedByInstructionTemplate(), and LImmDstRegisterField::width().

Referenced by validate().

Here is the call graph for this function:

◆ checkMoveSlot()

void BEMValidator::checkMoveSlot ( const TTAMachine::Bus bus)
private

Checks that the move slot for the given bus is valid in BEM.

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

Parameters
busThe bus.

Definition at line 204 of file BEMValidator.cc.

204  {
205 
206  if (!bem_.hasMoveSlot(bus.name())) {
207  format errorMsg("BEM does not contain move slot for bus %1%.");
208  errorMsg % bus.name();
209  errorMessages_.push_back(errorMsg.str());
210  return;
211  }
212 
213  checkSourceField(bus);
215  checkGuardField(bus);
216 }

References bem_, checkDestinationField(), checkGuardField(), checkSourceField(), errorMessages_, BinaryEncoding::hasMoveSlot(), and TTAMachine::Component::name().

Referenced by validate().

Here is the call graph for this function:

◆ checkSocketCodeTable()

void BEMValidator::checkSocketCodeTable ( const SocketEncoding socketEnc)
private

Checks that the socket code table of the given socket encoding is valid.

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

Parameters
socketEncThe socket encoding.

Definition at line 468 of file BEMValidator.cc.

468  {
469 
470  SlotField* slotField = socketEnc.parent();
471  bool srcField = (dynamic_cast<SourceField*>(slotField) != NULL);
472  string busName = slotField->parent()->name();
473  string socketName = socketEnc.socketName();
474 
475  assert(socketEnc.hasSocketCodes());
476  SocketCodeTable& table = socketEnc.socketCodes();
478  assert(socketNav.hasItem(socketName));
479  Socket* socket = socketNav.item(socketName);
480 
481  for (int i = 0; i < socket->portCount(); i++) {
482  Port* port = socket->port(i);
483  Unit* parentUnit = port->parentUnit();
484  FunctionUnit* fu = dynamic_cast<FunctionUnit*>(parentUnit);
485  RegisterFile* rf = dynamic_cast<RegisterFile*>(parentUnit);
486  ImmediateUnit* iu = dynamic_cast<ImmediateUnit*>(parentUnit);
487 
488  if (fu != NULL) {
489  BaseFUPort* fuPort = dynamic_cast<BaseFUPort*>(port);
490  assert(fuPort != NULL);
491  if (fuPort->isOpcodeSetting()) {
492  for (int i = 0; i < fu->operationCount(); i++) {
493  HWOperation* operation = fu->operation(i);
494  if (!table.hasFUPortCode(
495  fu->name(), port->name(), operation->name())) {
496  format errorMsg(
497  "Socket code table of socket %1% in %2% field "
498  "of move slot %3% does not contain FU port code "
499  "for operation %4% for port %5% of FU %6%.");
500  errorMsg % socketEnc.socketName();
501  if (srcField) {
502  errorMsg % "source";
503  } else {
504  errorMsg % "destination";
505  }
506  errorMsg % busName % operation->name() %
507  port->name() % fu->name();
508  errorMessages_.push_back(errorMsg.str());
509  }
510  }
511  } else {
512  if (!table.hasFUPortCode(fu->name(), port->name())) {
513  format errorMsg(
514  "Socket code table of socket %1% in %2% field of "
515  "move slot %3% does not contain FU port code for "
516  "port %4% of FU %5%.");
517  errorMsg % socketEnc.socketName();
518  if (srcField) {
519  errorMsg % "source";
520  } else {
521  errorMsg % "destination";
522  }
523  errorMsg % busName % port->name() % fu->name();
524  errorMessages_.push_back(errorMsg.str());
525  }
526  }
527 
528  } else if (rf != NULL && iu == NULL
529  && !table.hasRFPortCode(rf->name())) {
530  format errorMsg(
531  "Socket code table of socket %1% in %2% field of move "
532  "slot %3% does not contain RF port code for RF %4%.");
533  errorMsg % socketName;
534  if (srcField) {
535  errorMsg % "source";
536  } else {
537  errorMsg % "destination";
538  }
539  errorMsg % busName % rf->name();
540  errorMessages_.push_back(errorMsg.str());
541  } else if (iu != NULL && !table.hasIUPortCode(iu->name())) {
542  format errorMsg(
543  "Socket code table of socket %1% in %2% field of move slot "
544  "%3% does not contain IU port code for IU %4%.");
545  errorMsg % socketName;
546  if (srcField) {
547  errorMsg % "source";
548  } else {
549  errorMsg % "destination";
550  }
551  errorMsg % busName % iu->name();
552  errorMessages_.push_back(errorMsg.str());
553  }
554  }
555 }

References assert, errorMessages_, SocketCodeTable::hasFUPortCode(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), SocketCodeTable::hasIUPortCode(), SocketCodeTable::hasRFPortCode(), SocketEncoding::hasSocketCodes(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::HWOperation::name(), TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), SocketEncoding::parent(), SlotField::parent(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), SocketEncoding::socketCodes(), SocketEncoding::socketName(), and TTAMachine::Machine::socketNavigator().

Referenced by checkDestinationField(), and checkSourceField().

Here is the call graph for this function:

◆ checkSourceField()

void BEMValidator::checkSourceField ( const TTAMachine::Bus bus)
private

Checks the source field of the given bus for errors.

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

Definition at line 226 of file BEMValidator.cc.

226  {
227 
228  MoveSlot& moveSlot = bem_.moveSlot(bus.name());
229 
230  // collect the output sockets to a set
231  typedef std::set<Socket*> SocketSet;
232  SocketSet outputSockets;
233 
234  for (int i = 0; i < bus.segmentCount(); i++) {
235  Segment* segment = bus.segment(i);
236  for (int i = 0; i < segment->connectionCount(); i++) {
237  Socket* socket = segment->connection(i);
238  if (socket->portCount() > 0 &&
239  socket->direction() == Socket::OUTPUT) {
240  outputSockets.insert(socket);
241  }
242  }
243  }
244 
245  if (needsSourceField(moveSlot)) {
246  if (!moveSlot.hasSourceField()) {
247  format errorMsg(
248  "Move slot of bus %1% does not contain source field.");
249  errorMsg % bus.name();
250  errorMessages_.push_back(errorMsg.str());
251  } else {
252  // check the source field for socket encodings
253  SourceField& srcField = moveSlot.sourceField();
254  for (SocketSet::const_iterator iter = outputSockets.begin();
255  iter != outputSockets.end(); iter++) {
256  Socket* socket = *iter;
257  if (!srcField.hasSocketEncoding(socket->name())) {
258  format errorMsg(
259  "Source field of move slot of bus %1% does not"
260  "have an encoding for socket %2%.");
261  errorMsg % bus.name() % socket->name();
262  errorMessages_.push_back(errorMsg.str());
263  } else {
264  SocketEncoding& socketEnc = srcField.socketEncoding(
265  socket->name());
266  if (needsSocketCodeTable(socketEnc)) {
267  if (!socketEnc.hasSocketCodes()) {
268  format errorMsg(
269  "Encoding of socket %1% in source "
270  "field of move slot %2% does not refer to "
271  "any socket code table.");
272  errorMsg % socket->name() % bus.name();
273  errorMessages_.push_back(errorMsg.str());
274  } else {
275  checkSocketCodeTable(socketEnc);
276  }
277  }
278  }
279  }
280 
281  // check the source field for bridge encodings
283  for (int i = 0; i < bridgeNav.count(); i++) {
284  Bridge* bridge = bridgeNav.item(i);
285  if (bridge->destinationBus() == &bus &&
286  !moveSlot.sourceField().hasBridgeEncoding(
287  bridge->name())) {
288  format errorMsg(
289  "Source field of bus %1% does not have encoding "
290  "for bridge %2%.");
291  errorMsg % bus.name() % bridge->name();
292  errorMessages_.push_back(errorMsg.str());
293  }
294  }
295 
296  // check the source field for immediate encoding
297  if (bus.immediateWidth() > 0 &&
298  !srcField.hasImmediateEncoding()) {
299  format errorMsg(
300  "Source field of bus %1% does not have an immediate "
301  "encoding.");
302  errorMsg % bus.name();
303  errorMessages_.push_back(errorMsg.str());
304  }
305  }
306  }
307 }

References bem_, TTAMachine::Machine::bridgeNavigator(), checkSocketCodeTable(), TTAMachine::Segment::connection(), TTAMachine::Segment::connectionCount(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Bridge::destinationBus(), TTAMachine::Socket::direction(), errorMessages_, SourceField::hasBridgeEncoding(), SourceField::hasImmediateEncoding(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), MoveSlot::hasSourceField(), TTAMachine::Bus::immediateWidth(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, BinaryEncoding::moveSlot(), TTAMachine::Component::name(), needsSocketCodeTable(), needsSourceField(), TTAMachine::Socket::portCount(), TTAMachine::Bus::segment(), TTAMachine::Bus::segmentCount(), SlotField::socketEncoding(), and MoveSlot::sourceField().

Referenced by checkMoveSlot().

Here is the call graph for this function:

◆ errorCount()

int BEMValidator::errorCount ( ) const

Returns the number of errors found.

Returns
The number of errors.

Definition at line 145 of file BEMValidator.cc.

145  {
146  return errorMessages_.size();
147 }

References errorMessages_.

Referenced by errorMessage(), ProGe::ProGeUI::generateProcessor(), and validate().

◆ errorMessage()

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

Returns an error message by the given index.

Parameters
indexThe index.
Returns
The error message by the given index.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of errors.

Definition at line 159 of file BEMValidator.cc.

159  {
160  if (index < 0 || index >= errorCount()) {
161  throw OutOfRange(__FILE__, __LINE__, __func__);
162  } else {
163  return errorMessages_[index];
164  }
165 }

References __func__, errorCount(), and errorMessages_.

Referenced by ProGe::ProGeUI::generateProcessor().

Here is the call graph for this function:

◆ needsSocketCodeTable()

bool BEMValidator::needsSocketCodeTable ( const SocketEncoding socketEnc) const
private

Tells whether the given socket encoding needs a socket code table.

Parameters
socketEncThe socket encoding.
Returns
True if the socket encoding needs a socket code table, otherwise false.

Definition at line 767 of file BEMValidator.cc.

767  {
768 
769  string socketName = socketEnc.socketName();
771  assert(socketNav.hasItem(socketName));
772  Socket* socket = socketNav.item(socketName);
773 
774  if (socket->portCount() > 1) {
775  return true;
776  } else if (socket->portCount() == 0) {
777  return false;
778  }
779 
780  Port* port = socket->port(0);
781  Unit* unit = port->parentUnit();
782  BaseRegisterFile* rf = dynamic_cast<BaseRegisterFile*>(unit);
783  if (rf != NULL && rf->numberOfRegisters() > 1) {
784  return true;
785  }
786 
787  FunctionUnit* fu = dynamic_cast<FunctionUnit*>(unit);
788  if (fu != NULL) {
789  BaseFUPort* fuPort = dynamic_cast<BaseFUPort*>(port);
790  assert(fuPort != NULL);
791  if (fuPort->isOpcodeSetting() && fu->operationCount() > 1) {
792  return true;
793  }
794  }
795 
796  return false;
797 }

References assert, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), SocketEncoding::socketName(), and TTAMachine::Machine::socketNavigator().

Referenced by checkDestinationField(), and checkSourceField().

Here is the call graph for this function:

◆ needsSourceField()

bool BEMValidator::needsSourceField ( const MoveSlot slot) const
private

Tells whether the given move slot needs source field.

Parameters
slotThe move slot.
Returns
True if the move slot needs source field, otherwise false.

Definition at line 716 of file BEMValidator.cc.

716  {
717 
718  string busName = slot.name();
720  assert(busNav.hasItem(busName));
721  Bus* bus = busNav.item(busName);
722 
723  // check output sockets
724  for (int i = 0; i < bus->segmentCount(); i++) {
725  Segment* segment = bus->segment(i);
726  for (int i = 0; i < segment->connectionCount(); i++) {
727  Socket* socket = segment->connection(i);
728  if (socket->portCount() > 0 &&
729  socket->direction() == Socket::OUTPUT) {
730  return true;
731  }
732  }
733  }
734 
735  // check bridges
736  if (bus->hasNextBus()) {
737  Bus* nextBus = bus->nextBus();
738  if (bus->canRead(*nextBus)) {
739  return true;
740  }
741  }
742 
743  if (bus->hasPreviousBus()) {
744  Bus* prevBus = bus->previousBus();
745  if (bus->canRead(*prevBus)) {
746  return true;
747  }
748  }
749 
750  // check immediate
751  if (bus->immediateWidth() > 0) {
752  return true;
753  }
754 
755  return false;
756 }

References assert, TTAMachine::Machine::busNavigator(), TTAMachine::Bus::canRead(), TTAMachine::Segment::connection(), TTAMachine::Segment::connectionCount(), TTAMachine::Socket::direction(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Bus::hasNextBus(), TTAMachine::Bus::hasPreviousBus(), TTAMachine::Bus::immediateWidth(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MoveSlot::name(), TTAMachine::Bus::nextBus(), TTAMachine::Socket::portCount(), TTAMachine::Bus::previousBus(), TTAMachine::Bus::segment(), and TTAMachine::Bus::segmentCount().

Referenced by checkSourceField().

Here is the call graph for this function:

◆ validate()

bool BEMValidator::validate ( )

Validates the binary encoding map against the machine.

Updates the error and warning messages that can be queried with {error,warning}Count and {error,warning}Message methods.

Returns
True if the BEM is valid for the machine, otherwise false.

Definition at line 95 of file BEMValidator.cc.

95  {
96 
97  errorMessages_.clear();
98 
99  // check move slots for each bus
101  for (int i = 0; i < busNav.count(); i++) {
102  Bus* bus = busNav.item(i);
103  checkMoveSlot(*bus);
104  }
105 
106  // check immediate slots
107  Machine::ImmediateSlotNavigator immSlotNav =
109  for (int i = 0; i < immSlotNav.count(); i++) {
110  ImmediateSlot* immSlot = immSlotNav.item(i);
111  checkImmediateSlot(*immSlot);
112  }
113 
114  // check immediate control field
116 
117  // check long immediate destination register fields
119 
121  if (gcu == NULL) {
122  string errorMsg("Error: Couldn't find GCU from machine");
123  errorMessages_.push_back(errorMsg);
124  } else {
125  // no reason to check this as we are generating the
126  // instruction memory width according to the instruction
127  // width always (instruction indexed imem assumed)
128  // checkImemMauWidth(*gcu);
129  }
130 
131  if (errorCount() == 0) {
132  return true;
133  } else {
134  return false;
135  }
136 }

References TTAMachine::Machine::busNavigator(), checkImmediateControlField(), checkImmediateSlot(), checkLImmDstRegisterFields(), checkMoveSlot(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), errorCount(), errorMessages_, TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and machine_.

Referenced by ProGe::ProGeUI::generateProcessor().

Here is the call graph for this function:

◆ warningCount()

int BEMValidator::warningCount ( ) const

Returns the number of warnings found.

Returns
The number of warnings.

Definition at line 173 of file BEMValidator.cc.

173  {
174  return warningMessages_.size();
175 }

References warningMessages_.

Referenced by ProGe::ProGeUI::generateProcessor(), and warningMessage().

◆ warningMessage()

std::string BEMValidator::warningMessage ( int  index) const

Returns an warning message by the given index.

Parameters
indexThe index.
Returns
The warning message by the given index.
Exceptions
OutOfRangeIf the given index is negative or not smaller than the number of errors.

Definition at line 186 of file BEMValidator.cc.

186  {
187 
188  if (index < 0 || index >= warningCount()) {
189  throw OutOfRange(__FILE__, __LINE__, __func__);
190  } else {
191  return warningMessages_[index];
192  }
193 }

References __func__, warningCount(), and warningMessages_.

Referenced by ProGe::ProGeUI::generateProcessor().

Here is the call graph for this function:

Member Data Documentation

◆ bem_

const BinaryEncoding& BEMValidator::bem_
private

◆ errorMessages_

StringVector BEMValidator::errorMessages_
private

◆ machine_

const TTAMachine::Machine& BEMValidator::machine_
private

◆ warningMessages_

StringVector BEMValidator::warningMessages_
private

Contains the warning messages.

Definition at line 95 of file BEMValidator.hh.

Referenced by checkImemMauWidth(), warningCount(), and warningMessage().


The documentation for this class was generated from the following files:
TTAMachine::Bus::immediateWidth
int immediateWidth() const
Definition: Bus.cc:160
TTAMachine::Guard
Definition: Guard.hh:55
BinaryEncoding::immediateSlot
ImmediateSlotField & immediateSlot(int index) const
Definition: BinaryEncoding.cc:234
BEMValidator::checkDestinationField
void checkDestinationField(const TTAMachine::Bus &bus)
Definition: BEMValidator.cc:317
BEMValidator::checkImmediateControlField
void checkImmediateControlField()
Definition: BEMValidator.cc:596
MoveSlot::name
std::string name() const
Definition: MoveSlot.cc:136
TTAMachine::Socket::port
Port * port(int index) const
Definition: Socket.cc:266
TTAMachine::Socket::portCount
int portCount() const
BinaryEncoding::hasMoveSlot
bool hasMoveSlot(const std::string &name) const
Definition: BinaryEncoding.cc:138
TTAMachine::Bridge::destinationBus
Bus * destinationBus() const
GuardField::hasFUGuardEncoding
bool hasFUGuardEncoding(const std::string &fu, const std::string &port, bool inverted) const
Definition: GuardField.cc:410
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
BEMValidator::checkMoveSlot
void checkMoveSlot(const TTAMachine::Bus &bus)
Definition: BEMValidator.cc:204
TTAMachine::PortGuard::port
FUPort * port() const
DestinationField
Definition: DestinationField.hh:44
MoveSlot
Definition: MoveSlot.hh:60
TTAMachine::FunctionUnit::hasAddressSpace
virtual bool hasAddressSpace() const
Definition: FunctionUnit.cc:608
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::RegisterGuard::registerIndex
int registerIndex() const
TTAMachine::BaseFUPort::parentUnit
FunctionUnit * parentUnit() const
Definition: BaseFUPort.cc:96
TTAMachine::Bridge
Definition: Bridge.hh:51
TTAMachine::Segment
Definition: Segment.hh:54
BinaryEncoding::longImmDstRegisterFieldCount
int longImmDstRegisterFieldCount() const
Definition: BinaryEncoding.cc:400
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
SlotField::hasSocketEncoding
bool hasSocketEncoding(const std::string &socket) const
Definition: SlotField.cc:188
SourceField::hasImmediateEncoding
bool hasImmediateEncoding() const
Definition: SourceField.cc:279
OutOfRange
Definition: Exception.hh:320
SocketCodeTable::hasRFPortCode
bool hasRFPortCode(const std::string &regFile) const
Definition: SocketCodeTable.cc:502
TTAMachine::Bus
Definition: Bus.hh:53
TTAMachine::BaseFUPort
Definition: BaseFUPort.hh:44
BinaryEncoding::hasImmediateControlField
bool hasImmediateControlField() const
Definition: BinaryEncoding.cc:334
MoveSlot::hasGuardField
bool hasGuardField() const
Definition: MoveSlot.cc:202
GuardField
Definition: GuardField.hh:55
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAMachine::Machine::Navigator::count
int count() const
TTAMachine::Socket::direction
Direction direction() const
TTAMachine::Bus::segment
virtual Segment * segment(int index) const
Definition: Bus.cc:329
BEMValidator::warningCount
int warningCount() const
Definition: BEMValidator.cc:173
SlotField::socketEncoding
SocketEncoding & socketEncoding(int index) const
Definition: SlotField.cc:170
TTAMachine::Bus::hasPreviousBus
virtual bool hasPreviousBus() const
Definition: Bus.cc:473
BEMValidator::checkGuardField
void checkGuardField(const TTAMachine::Bus &bus)
Definition: BEMValidator.cc:385
ImmediateSlotField
Definition: ImmediateSlotField.hh:44
TTAMachine::BaseFUPort::isOpcodeSetting
virtual bool isOpcodeSetting() const =0
SocketCodeTable
Definition: SocketCodeTable.hh:68
ImmediateControlField::hasTemplateEncoding
bool hasTemplateEncoding(const std::string &name) const
Definition: ImmediateControlField.cc:167
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
BEMValidator::warningMessages_
StringVector warningMessages_
Contains the warning messages.
Definition: BEMValidator.hh:95
TTAMachine::InstructionTemplate
Definition: InstructionTemplate.hh:49
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::Segment::connectionCount
int connectionCount() const
TTAMachine::UnconditionalGuard
Definition: Guard.hh:180
MoveSlot::hasSourceField
bool hasSourceField() const
Definition: MoveSlot.cc:264
TTAMachine::FUPort
Definition: FUPort.hh:46
BEMValidator::needsSourceField
bool needsSourceField(const MoveSlot &slot) const
Definition: BEMValidator.cc:716
SourceField::hasBridgeEncoding
bool hasBridgeEncoding(const std::string &bridge) const
Definition: SourceField.cc:169
TTAMachine::BaseRegisterFile
Definition: BaseRegisterFile.hh:48
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::Bus::canRead
virtual bool canRead(const Bus &bus) const
Definition: Bus.cc:537
ImmediateControlField
Definition: ImmediateControlField.hh:57
TTAMachine::Unit
Definition: Unit.hh:51
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
BEMValidator::machine_
const TTAMachine::Machine & machine_
The machine.
Definition: BEMValidator.hh:90
TTAMachine::Machine::bridgeNavigator
virtual BridgeNavigator bridgeNavigator() const
Definition: Machine.cc:404
MoveSlot::guardField
GuardField & guardField() const
Definition: MoveSlot.cc:215
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
TTAMachine::RegisterGuard
Definition: Guard.hh:137
TTAMachine::Port
Definition: Port.hh:54
MoveSlot::hasDestinationField
bool hasDestinationField() const
Definition: MoveSlot.cc:327
BEMValidator::needsSocketCodeTable
bool needsSocketCodeTable(const SocketEncoding &socketEnc) const
Definition: BEMValidator.cc:767
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
BEMValidator::checkImmediateSlot
void checkImmediateSlot(const TTAMachine::ImmediateSlot &immSlot)
Definition: BEMValidator.cc:568
BinaryEncoding::width
virtual int width(const TCEString &templateName) const
Definition: BinaryEncoding.cc:768
SocketEncoding::socketName
std::string socketName() const
Definition: SocketEncoding.cc:145
GuardField::hasGPRGuardEncoding
bool hasGPRGuardEncoding(const std::string &regFile, int index, bool inverted) const
Definition: GuardField.cc:313
__func__
#define __func__
Definition: Application.hh:67
LImmDstRegisterField::immediateUnit
std::string immediateUnit(const std::string &instructionTemplate) const
Definition: LImmDstRegisterField.cc:197
TTAMachine::Socket
Definition: Socket.hh:53
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
SocketEncoding::hasSocketCodes
bool hasSocketCodes() const
Definition: SocketEncoding.cc:177
SocketCodeTable::hasFUPortCode
bool hasFUPortCode(const std::string &fu, const std::string &port) const
Definition: SocketCodeTable.cc:326
GuardField::hasUnconditionalGuardEncoding
bool hasUnconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:471
LImmDstRegisterField::width
virtual int width() const
Definition: LImmDstRegisterField.cc:213
SocketCodeTable::hasIUPortCode
bool hasIUPortCode(const std::string &immediateUnit) const
Definition: SocketCodeTable.cc:618
TTAMachine::Machine::socketNavigator
virtual SocketNavigator socketNavigator() const
Definition: Machine.cc:368
MoveSlot::sourceField
SourceField & sourceField() const
Definition: MoveSlot.cc:277
TTAMachine::InstructionTemplate::isOneOfDestinations
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:323
ImmediateSlotField::width
virtual int width() const
Definition: ImmediateSlotField.cc:167
TTAMachine::Bus::guardCount
int guardCount() const
Definition: Bus.cc:441
TTAMachine::Segment::connection
const Connection & connection(const Socket &socket) const
Definition: Segment.cc:250
TTAMachine::ImmediateSlot::width
int width() const
Definition: ImmediateSlot.cc:117
TTAMachine::Machine::immediateSlotNavigator
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition: Machine.cc:462
TTAMachine::Bus::guard
Guard * guard(int index) const
Definition: Bus.cc:456
BEMValidator::checkSocketCodeTable
void checkSocketCodeTable(const SocketEncoding &socketEnc)
Definition: BEMValidator.cc:468
TTAMachine::AddressSpace::width
virtual int width() const
Definition: AddressSpace.cc:155
SetTools::intersection
static void intersection(const std::set< ValueType > &firstContainer, const std::set< ValueType > &secondContainer, std::set< ValueType > &intersection)
LImmDstRegisterField::usedByInstructionTemplate
bool usedByInstructionTemplate(const std::string &instructionTemplate) const
Definition: LImmDstRegisterField.cc:181
TTAMachine::Bus::hasNextBus
virtual bool hasNextBus() const
Definition: Bus.cc:488
BEMValidator::errorMessages_
StringVector errorMessages_
Contains the error messages.
Definition: BEMValidator.hh:93
BinaryEncoding::hasImmediateSlot
bool hasImmediateSlot(const std::string &name) const
Definition: BinaryEncoding.cc:252
TTAMachine::Guard::isInverted
virtual bool isInverted() const
BEMValidator::errorCount
int errorCount() const
Definition: BEMValidator.cc:145
TTAMachine::Bus::previousBus
virtual Bus * previousBus() const
Definition: Bus.cc:518
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
SlotField
Definition: SlotField.hh:58
SocketEncoding::parent
SlotField * parent() const
Definition: SocketEncoding.cc:127
MathTools::bitLength
static unsigned int bitLength(long unsigned int number)
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
LImmDstRegisterField
Definition: LImmDstRegisterField.hh:47
BEMValidator::bem_
const BinaryEncoding & bem_
The binary encoding map.
Definition: BEMValidator.hh:88
BinaryEncoding::immediateControlField
ImmediateControlField & immediateControlField() const
Definition: BinaryEncoding.cc:348
BinaryEncoding::moveSlot
MoveSlot & moveSlot(int index) const
Definition: BinaryEncoding.cc:121
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
MoveSlot::destinationField
DestinationField & destinationField() const
Definition: MoveSlot.cc:341
TTAMachine::PortGuard
Definition: Guard.hh:99
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine::Bus::nextBus
virtual Bus * nextBus() const
Definition: Bus.cc:501
SocketEncoding::socketCodes
SocketCodeTable & socketCodes() const
Definition: SocketEncoding.cc:191
SocketEncoding
Definition: SocketEncoding.hh:51
SlotField::parent
MoveSlot * parent() const
Definition: SlotField.cc:98
TTAMachine::Machine::instructionTemplateNavigator
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition: Machine.cc:428
BinaryEncoding::longImmDstRegisterField
LImmDstRegisterField & longImmDstRegisterField(int index) const
Definition: BinaryEncoding.cc:415
TTAMachine::RegisterGuard::registerFile
const RegisterFile * registerFile() const
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Bus::segmentCount
virtual int segmentCount() const
Definition: Bus.cc:385
TTAMachine::ImmediateSlot
Definition: ImmediateSlot.hh:44
BEMValidator::checkLImmDstRegisterFields
void checkLImmDstRegisterFields()
Definition: BEMValidator.cc:628
BEMValidator::checkSourceField
void checkSourceField(const TTAMachine::Bus &bus)
Definition: BEMValidator.cc:226
TTAMachine::Port::parentUnit
Unit * parentUnit() const
SourceField
Definition: SourceField.hh:48
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50