OpenASIP
2.0
|
#include <SocketEncoding.hh>
Public Member Functions | |
SocketEncoding (const std::string &name, unsigned int encoding, unsigned int extraBits, SlotField &parent) | |
SocketEncoding (const ObjectState *state, SlotField &parent) | |
virtual | ~SocketEncoding () |
SlotField * | parent () const |
std::string | socketName () const |
void | setSocketCodes (SocketCodeTable &codeTable) |
void | unsetSocketCodes () |
bool | hasSocketCodes () const |
SocketCodeTable & | socketCodes () const |
int | socketCodePosition () const |
void | setEncoding (unsigned int encoding, unsigned int extraBits) |
int | socketIDPosition () const |
int | socketIDWidth () const |
virtual int | width () const |
virtual int | bitPosition () const |
virtual ObjectState * | saveState () const |
Public Member Functions inherited from Encoding | |
virtual | ~Encoding () |
InstructionField * | parent () const |
unsigned int | encoding () const |
unsigned int | extraBits () const |
Static Public Attributes | |
static const std::string | OSNAME_SOCKET_ENCODING = "socket_encoding" |
ObjectState name for socket encoding. More... | |
static const std::string | OSKEY_SOCKET_NAME = "socket_name" |
ObjectState attribute key for the name of the socket. More... | |
static const std::string | OSKEY_SC_TABLE = "sc_table" |
ObjectState attribute key for the name of the socket code table. More... | |
Static Public Attributes inherited from Encoding | |
static const std::string | OSNAME_ENCODING = "encoding" |
ObjectState name for Encoding class. More... | |
static const std::string | OSKEY_ENCODING = "encoding" |
ObjectState attribute key for the encoding. More... | |
static const std::string | OSKEY_EXTRA_BITS = "extra_bits" |
ObjectState attribute key for the number of extra bits. More... | |
Private Member Functions | |
void | detachFromParent () |
Private Attributes | |
std::string | name_ |
Name of the socket. More... | |
SocketCodeTable * | socketCodes_ |
Socket code table. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Encoding | |
Encoding (unsigned int encoding, unsigned int extraBits, InstructionField *parent) | |
Encoding (const ObjectState *state, InstructionField *parent) | |
void | setParent (InstructionField *parent) |
void | setEncoding (unsigned int encoding, unsigned int extraBits) |
The SocketEncoding class models how socket sources or destinations are mapped to control codes.
Sockets have an independent encoding in each source or destination field they appear in. A socket encoding can be more complex than a fixed control code and encode many destinations or sources all reached from the same socket. In this case, the socket encoding contains SocketCodeTable instance.
Definition at line 51 of file SocketEncoding.hh.
SocketEncoding::SocketEncoding | ( | const std::string & | name, |
unsigned int | encoding, | ||
unsigned int | extraBits, | ||
SlotField & | parent | ||
) |
The constructor.
Creates a socket encoding and registers it into the given slot field. The socket is identified by name. The (fixed) part of the socket encoding and the parent slot field are given as parameters.
name | Name of the socket. |
encoding | Fixed part of the encoding. |
extraBits | The number of extra (zero) bits in the encoding. |
parent | The parent slot field. |
ObjectAlreadyExists | If the parent slot field already has an encoding for the same socket, or if the given encoding is ambiguous with another encoding in the parent slot field. |
Definition at line 66 of file SocketEncoding.cc.
References SlotField::addSocketEncoding(), parent(), and Encoding::setParent().
SocketEncoding::SocketEncoding | ( | const ObjectState * | state, |
SlotField & | parent | ||
) |
The constructor.
Loads the state of the object from the given ObjectState instance.
state | The ObjectState instance. |
parent | The parent slot field. |
ObjectStateLoadingException | If an error occurs while loading the state. |
ObjectAlreadyExists | If the parent slot field already has an encoding for the same socket, or if the given encoding is ambiguous with another encoding in the parent slot field. |
Definition at line 88 of file SocketEncoding.cc.
References SlotField::addSocketEncoding(), Exception::errorMessage(), ObjectState::hasAttribute(), NullSocketCodeTable::instance(), name_, OSKEY_SC_TABLE, OSKEY_SOCKET_NAME, parent(), SlotField::parent(), MoveSlot::parent(), Encoding::setParent(), setSocketCodes(), BinaryEncoding::socketCodeTable(), and ObjectState::stringAttribute().
|
virtual |
The destructor.
Definition at line 119 of file SocketEncoding.cc.
References detachFromParent().
|
virtual |
Returns always 0.
Implements Encoding.
Definition at line 291 of file SocketEncoding.cc.
|
private |
Removes itself from the parent slot field.
Definition at line 316 of file SocketEncoding.cc.
References parent(), SlotField::removeSocketEncoding(), and Encoding::setParent().
Referenced by setEncoding(), and ~SocketEncoding().
bool SocketEncoding::hasSocketCodes | ( | ) | const |
Tells whether the socket encoding contains a socket code table.
Definition at line 177 of file SocketEncoding.cc.
References socketCodes_.
Referenced by BEMValidator::checkDestinationField(), BEMValidator::checkSocketCodeTable(), BEMValidator::checkSourceField(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeRFTerminal(), printSlotFieldEncodings(), saveState(), socketCodes(), width(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), DefaultDecoderGenerator::writeControlRulesOfFUOutputPort(), DefaultDecoderGenerator::writeControlRulesOfRFReadPort(), and DefaultDecoderGenerator::writeControlRulesOfRFWritePort().
SlotField * SocketEncoding::parent | ( | ) | const |
Returns the parent slot field.
Definition at line 127 of file SocketEncoding.cc.
References assert, and Encoding::parent().
Referenced by SlotField::addSocketEncoding(), BEMValidator::checkSocketCodeTable(), detachFromParent(), DefaultDecoderGenerator::portCodeCondition(), SlotField::removeSocketEncoding(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), setEncoding(), socketCodePosition(), SocketEncoding(), socketIDPosition(), and DefaultDecoderGenerator::writeControlRulesOfFUInputPort().
|
virtual |
Saves the state of the socket encoding to an ObjectState instance.
Reimplemented from Encoding.
Definition at line 302 of file SocketEncoding.cc.
References hasSocketCodes(), OSKEY_SC_TABLE, OSKEY_SOCKET_NAME, OSNAME_SOCKET_ENCODING, Encoding::saveState(), ObjectState::setAttribute(), ObjectState::setName(), socketCodes(), and socketName().
Referenced by SlotField::saveState().
void SocketEncoding::setEncoding | ( | unsigned int | encoding, |
unsigned int | extraBits | ||
) |
Sets new encoding.
encoding | The encoding. |
extraBits | The extrabits of the encoding. |
ObjectAlreadyExists | If the parent slot field already has an encoding for the same socket, or if the given encoding is ambiguous with another encoding in the parent slot field. |
Definition at line 223 of file SocketEncoding.cc.
References SlotField::addSocketEncoding(), detachFromParent(), Encoding::encoding(), Encoding::extraBits(), parent(), Encoding::setEncoding(), and Encoding::setParent().
void SocketEncoding::setSocketCodes | ( | SocketCodeTable & | codeTable | ) |
Attaches a set of socket codes to the socket encoding.
codeTable | The socket code table to be attached. |
Definition at line 156 of file SocketEncoding.cc.
References socketCodes_.
Referenced by BEMGenerator::addEncodings(), and SocketEncoding().
int SocketEncoding::socketCodePosition | ( | ) | const |
Returns the position of the socket code within the slot field.
Definition at line 203 of file SocketEncoding.cc.
References InstructionField::extraBits(), parent(), BinaryEncoding::RIGHT, socketCodes(), SlotField::width(), and SocketCodeTable::width().
Referenced by BEMTester::conflictsWithDestinationEncodings(), and BEMTester::conflictsWithSourceEncodings().
SocketCodeTable & SocketEncoding::socketCodes | ( | ) | const |
Returns the socket code table.
Returns a NullSocketCodeTable instance if the socket does not have a socket code table set.
Definition at line 191 of file SocketEncoding.cc.
References hasSocketCodes(), NullSocketCodeTable::instance(), and socketCodes_.
Referenced by BEMValidator::checkSocketCodeTable(), BEMTester::conflictsWithDestinationEncodings(), BEMTester::conflictsWithSourceEncodings(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeRFTerminal(), printSlotFieldEncodings(), SocketCodeTable::removeReferences(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), saveState(), socketCodePosition(), width(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), DefaultDecoderGenerator::writeControlRulesOfFUOutputPort(), DefaultDecoderGenerator::writeControlRulesOfRFReadPort(), and DefaultDecoderGenerator::writeControlRulesOfRFWritePort().
int SocketEncoding::socketIDPosition | ( | ) | const |
Returns the position of the socket ID within the slot field.
The position is always 0 if socket ID is in the right end of the field. However, if socket code is in the right end of the field, the position of the socket ID depends on the bit width of the socket code.
Definition at line 249 of file SocketEncoding.cc.
References InstructionField::extraBits(), parent(), BinaryEncoding::RIGHT, socketIDWidth(), and SlotField::width().
Referenced by BEMTester::conflictsWithDestinationEncodings(), BEMTester::conflictsWithSourceEncodings(), DefaultDecoderGenerator::socketEncodingCondition(), and BEMTester::splitEncodingTo().
int SocketEncoding::socketIDWidth | ( | ) | const |
Returns the bit width of the fixed part of the socket encoding.
Definition at line 264 of file SocketEncoding.cc.
References MathTools::bitLength(), Encoding::encoding(), and Encoding::extraBits().
Referenced by BEMTester::canAddComponentEncoding(), BEMTester::conflictsWithDestinationEncodings(), BEMTester::conflictsWithSourceEncodings(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeRFTerminal(), DefaultDecoderGenerator::portCodeCondition(), printSlotFieldEncodings(), DefaultDecoderGenerator::socketEncodingCondition(), socketIDPosition(), BEMTester::splitEncodingTo(), width(), and DefaultDecoderGenerator::writeControlRulesOfFUInputPort().
std::string SocketEncoding::socketName | ( | ) | const |
Returns the name of the socket.
Definition at line 145 of file SocketEncoding.cc.
References name_.
Referenced by SlotField::addSocketEncoding(), BEMValidator::checkSocketCodeTable(), SlotField::hasSocketEncoding(), BEMValidator::needsSocketCodeTable(), printSlotFieldEncodings(), saveState(), and SlotField::socketEncoding().
void SocketEncoding::unsetSocketCodes | ( | ) |
Removes the socket codes from the socket encoding.
Definition at line 165 of file SocketEncoding.cc.
References socketCodes_.
Referenced by SocketCodeTable::removeReferences().
|
virtual |
Returns the number of bits required to encode all the destinations of this socket.
Reimplemented from Encoding.
Definition at line 276 of file SocketEncoding.cc.
References hasSocketCodes(), socketCodes(), socketIDWidth(), and SocketCodeTable::width().
Referenced by printSlotFieldEncodings(), and SlotField::width().
|
private |
Name of the socket.
Definition at line 90 of file SocketEncoding.hh.
Referenced by SocketEncoding(), and socketName().
|
static |
ObjectState attribute key for the name of the socket code table.
Definition at line 83 of file SocketEncoding.hh.
Referenced by saveState(), BEMSerializer::slotFieldToFile(), BEMSerializer::slotFieldToOM(), and SocketEncoding().
|
static |
ObjectState attribute key for the name of the socket.
Definition at line 81 of file SocketEncoding.hh.
Referenced by saveState(), BEMSerializer::slotFieldToFile(), BEMSerializer::slotFieldToOM(), and SocketEncoding().
|
static |
ObjectState name for socket encoding.
Definition at line 79 of file SocketEncoding.hh.
Referenced by SlotField::loadState(), saveState(), BEMSerializer::slotFieldToFile(), and BEMSerializer::slotFieldToOM().
|
private |
Socket code table.
Definition at line 92 of file SocketEncoding.hh.
Referenced by hasSocketCodes(), setSocketCodes(), socketCodes(), and unsetSocketCodes().