OpenASIP
2.0
|
#include <BEMValidator.hh>
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 BinaryEncoding & | bem_ |
The binary encoding map. More... | |
const TTAMachine::Machine & | machine_ |
The machine. More... | |
StringVector | errorMessages_ |
Contains the error messages. More... | |
StringVector | warningMessages_ |
Contains the warning messages. More... | |
Validates binary encoding maps against machines. Checks that the BEM contains all the required information.
Definition at line 57 of file BEMValidator.hh.
|
private |
Vector type for string.
Definition at line 72 of file BEMValidator.hh.
BEMValidator::BEMValidator | ( | const BinaryEncoding & | bem, |
const TTAMachine::Machine & | machine | ||
) |
The constructor.
bem | The binary encoding map. |
machine | The machine. |
Definition at line 72 of file BEMValidator.cc.
BEMValidator::~BEMValidator | ( | ) |
|
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.
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().
|
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.
bus | The bus. |
Definition at line 385 of file BEMValidator.cc.
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().
|
private |
Checks that the instruction memory width (MAU) is greater or equal than the width of one instruction.
gcu | Global Control Unit of the machine |
Definition at line 691 of file BEMValidator.cc.
References TTAMachine::FunctionUnit::addressSpace(), bem_, errorMessages_, TTAMachine::FunctionUnit::hasAddressSpace(), warningMessages_, TTAMachine::AddressSpace::width(), and BinaryEncoding::width().
|
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.
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().
|
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.
immSlot | The immediate slot. |
Definition at line 568 of file BEMValidator.cc.
References bem_, errorMessages_, BinaryEncoding::hasImmediateSlot(), BinaryEncoding::immediateSlot(), TTAMachine::Component::name(), TTAMachine::ImmediateSlot::width(), and ImmediateSlotField::width().
Referenced by validate().
|
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.
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().
|
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.
bus | The bus. |
Definition at line 204 of file BEMValidator.cc.
References bem_, checkDestinationField(), checkGuardField(), checkSourceField(), errorMessages_, BinaryEncoding::hasMoveSlot(), and TTAMachine::Component::name().
Referenced by validate().
|
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.
socketEnc | The socket encoding. |
Definition at line 468 of file BEMValidator.cc.
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().
|
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.
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().
int BEMValidator::errorCount | ( | ) | const |
Returns the number of errors found.
Definition at line 145 of file BEMValidator.cc.
References errorMessages_.
Referenced by errorMessage(), ProGe::ProGeUI::generateProcessor(), and validate().
std::string BEMValidator::errorMessage | ( | int | index | ) | const |
Returns an error message by the given index.
index | The index. |
OutOfRange | If the given index is negative or not smaller than the number of errors. |
Definition at line 159 of file BEMValidator.cc.
References __func__, errorCount(), and errorMessages_.
Referenced by ProGe::ProGeUI::generateProcessor().
|
private |
Tells whether the given socket encoding needs a socket code table.
socketEnc | The socket encoding. |
Definition at line 767 of file BEMValidator.cc.
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().
|
private |
Tells whether the given move slot needs source field.
slot | The move slot. |
Definition at line 716 of file BEMValidator.cc.
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().
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.
Definition at line 95 of file BEMValidator.cc.
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().
int BEMValidator::warningCount | ( | ) | const |
Returns the number of warnings found.
Definition at line 173 of file BEMValidator.cc.
References warningMessages_.
Referenced by ProGe::ProGeUI::generateProcessor(), and warningMessage().
std::string BEMValidator::warningMessage | ( | int | index | ) | const |
Returns an warning message by the given index.
index | The index. |
OutOfRange | If the given index is negative or not smaller than the number of errors. |
Definition at line 186 of file BEMValidator.cc.
References __func__, warningCount(), and warningMessages_.
Referenced by ProGe::ProGeUI::generateProcessor().
|
private |
The binary encoding map.
Definition at line 88 of file BEMValidator.hh.
Referenced by checkDestinationField(), checkGuardField(), checkImemMauWidth(), checkImmediateControlField(), checkImmediateSlot(), checkLImmDstRegisterFields(), checkMoveSlot(), and checkSourceField().
|
private |
Contains the error messages.
Definition at line 93 of file BEMValidator.hh.
Referenced by checkDestinationField(), checkGuardField(), checkImemMauWidth(), checkImmediateControlField(), checkImmediateSlot(), checkLImmDstRegisterFields(), checkMoveSlot(), checkSocketCodeTable(), checkSourceField(), errorCount(), errorMessage(), and validate().
|
private |
The machine.
Definition at line 90 of file BEMValidator.hh.
Referenced by checkImmediateControlField(), checkLImmDstRegisterFields(), checkSocketCodeTable(), checkSourceField(), needsSocketCodeTable(), needsSourceField(), and validate().
|
private |
Contains the warning messages.
Definition at line 95 of file BEMValidator.hh.
Referenced by checkImemMauWidth(), warningCount(), and warningMessage().