OpenASIP
2.0
|
#include <SlotField.hh>
Public Member Functions | |
virtual | ~SlotField () |
MoveSlot * | parent () const |
void | addSocketEncoding (SocketEncoding &encoding) |
void | removeSocketEncoding (SocketEncoding &encoding) |
int | socketEncodingCount () const |
SocketEncoding & | socketEncoding (int index) const |
bool | hasSocketEncoding (const std::string &socket) const |
SocketEncoding & | socketEncoding (const std::string &socket) const |
void | setNoOperationEncoding (NOPEncoding &encoding) |
void | unsetNoOperationEncoding () |
bool | hasNoOperationEncoding () const |
NOPEncoding & | noOperationEncoding () const |
BinaryEncoding::Position | componentIDPosition () const |
virtual int | width () const |
virtual int | childFieldCount () const |
virtual InstructionField & | childField (int position) const |
virtual void | loadState (const ObjectState *state) |
virtual ObjectState * | saveState () const |
Public Member Functions inherited from InstructionField | |
virtual | ~InstructionField () |
InstructionField * | parent () const |
int | bitPosition () const |
int | relativePosition () const |
virtual void | setRelativePosition (int position) |
void | setExtraBits (int bits) |
int | extraBits () const |
Public Member Functions inherited from Serializable | |
virtual | ~Serializable () |
Static Public Attributes | |
static const std::string | OSNAME_SLOT_FIELD = "slot_field" |
ObjectState name for slot field. More... | |
static const std::string | OSKEY_COMPONENT_ID_POSITION = "comp_id_pos" |
ObjectState attribute key for component ID position. More... | |
Static Public Attributes inherited from InstructionField | |
static const std::string | OSNAME_INSTRUCTION_FIELD = "instr_field" |
ObjectState name for instruction field. More... | |
static const std::string | OSKEY_EXTRA_BITS = "extra_bits" |
ObjectState attribute key for the number of extra bits. More... | |
static const std::string | OSKEY_POSITION = "position" |
ObjectState attribute key for the relative position of the field. More... | |
Protected Member Functions | |
SlotField (BinaryEncoding::Position componentIDPos, MoveSlot &parent) | |
SlotField (const ObjectState *state, MoveSlot &parent) | |
Protected Member Functions inherited from InstructionField | |
InstructionField (InstructionField *parent) | |
InstructionField (const ObjectState *state, InstructionField *parent) | |
void | setParent (InstructionField *parent) |
Private Types | |
typedef std::vector< SocketEncoding * > | SocketEncodingTable |
A container type for socket encodings. More... | |
Private Member Functions | |
void | clearSocketEncodings () |
void | clearNoOperationEncoding () |
Private Attributes | |
NOPEncoding * | nopEncoding_ |
The NOP encoding. More... | |
SocketEncodingTable | encodings_ |
The container for socket encodings. More... | |
BinaryEncoding::Position | componentIDPos_ |
Position of the socket and bridge IDs within the field. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from InstructionField | |
static void | reorderSubfields (ObjectState *state) |
SlotField is an abstract base class that models the properties common to SourceField and DestinationField classes.
SlotField contains and manages the encodings for sockets. Encodings for different sources and destinations consists of two parts: socket ID and optional socket code. Socket ID determines the socket. Socket code determines the port (and opcode) the socket is connected to. Socket ID may be on either left or right side of the socket code in the source or destination field. If socket ID is on the left side of socket code, socket ID is aligned to the left end of the whole source/destination field. In the other case, socket ID is aligned to the right end of the source/destination field.
Definition at line 58 of file SlotField.hh.
|
private |
A container type for socket encodings.
Definition at line 99 of file SlotField.hh.
|
virtual |
The destructor.
Definition at line 88 of file SlotField.cc.
References clearNoOperationEncoding(), and clearSocketEncodings().
|
protected |
The constructor.
componentIDPos | Position of the socket (or bridge) ID within the source or destination field. |
parent | The parent move slot. |
Definition at line 60 of file SlotField.cc.
|
protected |
The constructor.
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
parent | The parent move slot. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Definition at line 78 of file SlotField.cc.
References loadState().
void SlotField::addSocketEncoding | ( | SocketEncoding & | encoding | ) |
Adds the given socket encoding.
This method is to be called from the constructor of SocketEncoding.
encoding | The socket encoding to be added. |
ObjectAlreadyExists | If the field already has an encoding for the same socket or if the encoding is already assigned to another socket. |
Definition at line 121 of file SlotField.cc.
References assert, BEMTester::canAddComponentEncoding(), Encoding::encoding(), encodings_, Encoding::extraBits(), hasSocketEncoding(), SocketEncoding::parent(), and SocketEncoding::socketName().
Referenced by SocketEncoding::setEncoding(), and SocketEncoding::SocketEncoding().
|
virtual |
Always throws OutOfRange because slot fields do not have any child fields.
OutOfRange | Always throws. |
Reimplemented from InstructionField.
Definition at line 345 of file SlotField.cc.
|
virtual |
Always returns 0 because slot fields do not have any child fields.
Implements InstructionField.
Definition at line 333 of file SlotField.cc.
|
private |
Deletes the NOP encoding if one exists.
Definition at line 422 of file SlotField.cc.
References hasNoOperationEncoding(), and nopEncoding_.
Referenced by loadState(), and ~SlotField().
|
private |
Clears all the socket encodings from the slot field.
Definition at line 413 of file SlotField.cc.
References SequenceTools::deleteAllItems(), and encodings_.
Referenced by loadState(), and ~SlotField().
BinaryEncoding::Position SlotField::componentIDPosition | ( | ) | const |
Returns the position of the component ID within the slot field.
Definition at line 296 of file SlotField.cc.
References componentIDPos_.
Referenced by BEMTester::calculateAlignment(), DestinationField::DestinationField(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeNOP(), CodeCompressorPlugin::encodeSlotField(), DefaultDecoderGenerator::portCodeCondition(), printSlotFieldEncodings(), printSourceFieldEncodings(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), saveState(), SourceField::SourceField(), and DefaultDecoderGenerator::writeControlRulesOfFUInputPort().
bool SlotField::hasNoOperationEncoding | ( | ) | const |
Tells whether the slot field has a NOP encoding.
Definition at line 267 of file SlotField.cc.
References nopEncoding_.
Referenced by BEMTester::canAddComponentEncoding(), clearNoOperationEncoding(), CodeCompressorPlugin::encodeNOP(), noOperationEncoding(), printSlotFieldEncodings(), saveState(), setNoOperationEncoding(), unsetNoOperationEncoding(), and width().
bool SlotField::hasSocketEncoding | ( | const std::string & | socket | ) | const |
Tells whether the slot field has an encoding for the socket with the given name.
socket | Name of the socket. |
Definition at line 188 of file SlotField.cc.
References encodings_, and SocketEncoding::socketName().
Referenced by addSocketEncoding(), BEMValidator::checkDestinationField(), BEMValidator::checkSourceField(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeIUTerminal(), and CodeCompressorPlugin::encodeRFTerminal().
|
virtual |
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Reimplemented from InstructionField.
Reimplemented in SourceField.
Definition at line 358 of file SlotField.cc.
References ObjectState::child(), ObjectState::childCount(), clearNoOperationEncoding(), clearSocketEncodings(), componentIDPos_, Exception::errorMessage(), ObjectState::intAttribute(), InstructionField::loadState(), ObjectState::name(), OSKEY_COMPONENT_ID_POSITION, NOPEncoding::OSNAME_NOP_ENCODING, and SocketEncoding::OSNAME_SOCKET_ENCODING.
Referenced by SourceField::loadState(), and SlotField().
NOPEncoding & SlotField::noOperationEncoding | ( | ) | const |
Returns the NOP encoding.
Returns NullNOPEncoding instance if the slot field does not have a NOP encoding.
Definition at line 281 of file SlotField.cc.
References hasNoOperationEncoding(), NullNOPEncoding::instance(), and nopEncoding_.
Referenced by BEMTester::canAddComponentEncoding(), CodeCompressorPlugin::encodeNOP(), printSlotFieldEncodings(), saveState(), unsetNoOperationEncoding(), and width().
MoveSlot * SlotField::parent | ( | ) | const |
Returns the parent move slot.
Definition at line 98 of file SlotField.cc.
References assert, and InstructionField::parent().
Referenced by CodeCompressorPlugin::addBitsForDestinationField(), CodeCompressorPlugin::addBitsForSourceField(), BEMGenerator::addEncodings(), BEMValidator::checkSocketCodeTable(), DestinationField::DestinationField(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeRFTerminal(), DefaultDecoderGenerator::portCodeCondition(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), MoveSlot::setDestinationField(), SourceField::setImmediateEncoding(), MoveSlot::setSourceField(), SocketEncoding::SocketEncoding(), DefaultDecoderGenerator::socketEncodingCondition(), SourceField::SourceField(), SourceField::unsetImmediateEncoding(), unsetNoOperationEncoding(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), DestinationField::~DestinationField(), and SourceField::~SourceField().
void SlotField::removeSocketEncoding | ( | SocketEncoding & | encoding | ) |
Removes the given socket encoding.
This method is to be called from SocketEncoding destructor.
encoding | The socket encoding to be removed. |
Definition at line 143 of file SlotField.cc.
References assert, encodings_, SocketEncoding::parent(), and ContainerTools::removeValueIfExists().
Referenced by SocketEncoding::detachFromParent().
|
virtual |
Saves the state of the object to an ObjectState tree.
Reimplemented from InstructionField.
Reimplemented in SourceField, and DestinationField.
Definition at line 388 of file SlotField.cc.
References ObjectState::addChild(), componentIDPosition(), hasNoOperationEncoding(), noOperationEncoding(), OSKEY_COMPONENT_ID_POSITION, OSNAME_SLOT_FIELD, InstructionField::saveState(), SocketEncoding::saveState(), ObjectState::setAttribute(), ObjectState::setName(), socketEncoding(), and socketEncodingCount().
Referenced by DestinationField::saveState(), and SourceField::saveState().
void SlotField::setNoOperationEncoding | ( | NOPEncoding & | encoding | ) |
Sets the given encoding for no operation.
This method is to be called from the constructor of NOPEncoding.
encoding | The encoding to be set. |
ObjectAlreadyExists | If the slot field has a NOP encoding already or if the given encoding is ambiguous with some other encoding. |
Definition at line 234 of file SlotField.cc.
References assert, BEMTester::canAddComponentEncoding(), Encoding::encoding(), Encoding::extraBits(), hasNoOperationEncoding(), nopEncoding_, and NOPEncoding::parent().
Referenced by NOPEncoding::NOPEncoding().
SocketEncoding & SlotField::socketEncoding | ( | const std::string & | socket | ) | const |
Returns the socket encoding of the socket with the given name.
Returns a NullSocketEncoding instance if this field does not encode the socket.
socket | Name of the socket. |
Definition at line 210 of file SlotField.cc.
References encodings_, NullSocketEncoding::instance(), and SocketEncoding::socketName().
SocketEncoding & SlotField::socketEncoding | ( | int | index | ) | const |
Returns the socket encoding stored at the given position.
index | The position. |
OutOfRange | If the given index is negative or not smaller than the number of sockets encoded in the field. |
Definition at line 170 of file SlotField.cc.
References encodings_, and socketEncodingCount().
Referenced by BEMTester::canAddComponentEncoding(), BEMValidator::checkDestinationField(), BEMValidator::checkSourceField(), BEMTester::conflictsWithDestinationEncodings(), BEMTester::conflictsWithSourceEncodings(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeRFTerminal(), printSlotFieldEncodings(), SocketCodeTable::removeReferences(), saveState(), DefaultDecoderGenerator::socketEncodingCondition(), width(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), DefaultDecoderGenerator::writeControlRulesOfFUOutputPort(), DefaultDecoderGenerator::writeControlRulesOfRFReadPort(), and DefaultDecoderGenerator::writeControlRulesOfRFWritePort().
int SlotField::socketEncodingCount | ( | ) | const |
Returns the number of sockets that are encoded in this field.
Definition at line 156 of file SlotField.cc.
References encodings_.
Referenced by BEMTester::canAddComponentEncoding(), BEMTester::conflictsWithDestinationEncodings(), BEMTester::conflictsWithSourceEncodings(), printSlotFieldEncodings(), SocketCodeTable::removeReferences(), saveState(), socketEncoding(), and width().
void SlotField::unsetNoOperationEncoding | ( | ) |
Unsets the NOP encoding.
This method is to be called from the destructor of NOPEncoding.
Definition at line 253 of file SlotField.cc.
References assert, hasNoOperationEncoding(), noOperationEncoding(), nopEncoding_, and parent().
Referenced by NOPEncoding::~NOPEncoding().
|
virtual |
Returns the bit width required by the socket encodings.
Implements InstructionField.
Reimplemented in SourceField.
Definition at line 307 of file SlotField.cc.
References InstructionField::extraBits(), hasNoOperationEncoding(), noOperationEncoding(), socketEncoding(), socketEncodingCount(), Encoding::width(), and SocketEncoding::width().
Referenced by NOPEncoding::bitPosition(), BEMTester::canAddComponentPriorityEncoding(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), CodeCompressorPlugin::encodeSlotField(), ProGe::RV32MicroCodeGenerator::findBusWidths(), printMoveSlotLayout(), printSlotFieldEncodings(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), SocketEncoding::socketCodePosition(), SocketEncoding::socketIDPosition(), SourceField::width(), MoveSlot::width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeMoveFieldSignals().
|
private |
Position of the socket and bridge IDs within the field.
Definition at line 109 of file SlotField.hh.
Referenced by componentIDPosition(), and loadState().
|
private |
The container for socket encodings.
Definition at line 107 of file SlotField.hh.
Referenced by addSocketEncoding(), clearSocketEncodings(), hasSocketEncoding(), removeSocketEncoding(), socketEncoding(), and socketEncodingCount().
|
private |
The NOP encoding.
Definition at line 105 of file SlotField.hh.
Referenced by clearNoOperationEncoding(), hasNoOperationEncoding(), noOperationEncoding(), setNoOperationEncoding(), and unsetNoOperationEncoding().
|
static |
ObjectState attribute key for component ID position.
Definition at line 91 of file SlotField.hh.
Referenced by loadState(), saveState(), BEMSerializer::slotFieldToFile(), and BEMSerializer::slotFieldToOM().
|
static |
ObjectState name for slot field.
Definition at line 89 of file SlotField.hh.
Referenced by saveState(), and BEMSerializer::slotFieldToOM().