OpenASIP
2.0
|
#include <ImmediateControlField.hh>
Public Member Functions | |
ImmediateControlField (BinaryEncoding &parent) | |
ImmediateControlField (const ObjectState *state, BinaryEncoding &parent) | |
virtual | ~ImmediateControlField () |
BinaryEncoding * | parent () const |
int | templateCount () const |
std::string | instructionTemplate (int index) const |
bool | hasTemplateEncoding (const std::string &name) const |
unsigned int | templateEncoding (const std::string &name) const |
void | addTemplateEncoding (const std::string &name, unsigned int encoding) |
void | removeTemplateEncoding (const std::string &name) |
virtual int | width () const |
virtual int | childFieldCount () const |
virtual InstructionField & | childField (int) const |
virtual void | loadState (const ObjectState *state) |
virtual ObjectState * | saveState () const |
![]() | |
virtual | ~InstructionField () |
InstructionField * | parent () const |
int | bitPosition () const |
int | relativePosition () const |
virtual void | setRelativePosition (int position) |
void | setExtraBits (int bits) |
int | extraBits () const |
![]() | |
virtual | ~Serializable () |
Static Public Attributes | |
static const std::string | OSNAME_IMM_CONTROL_FIELD = "ic_field" |
ObjectState name for immediate control field. More... | |
static const std::string | OSNAME_TEMPLATE_MAP = "temp_map" |
ObjectState name for a template mapping. More... | |
static const std::string | OSKEY_TEMPLATE_NAME = "temp_name" |
ObjectState attribute key for the name of the instruction template. More... | |
static const std::string | OSKEY_ENCODING = "encoding" |
ObjectState attribute key for the encoding of the instruction template. More... | |
![]() | |
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... | |
Private Types | |
typedef std::map< std::string, unsigned int > | EncodingMap |
A map type for binary encodings. More... | |
Private Member Functions | |
void | clearTemplateEncodings () |
Private Attributes | |
EncodingMap | templates_ |
Binary encodings for instruction templates. More... | |
Additional Inherited Members | |
![]() | |
InstructionField (InstructionField *parent) | |
InstructionField (const ObjectState *state, InstructionField *parent) | |
void | setParent (InstructionField *parent) |
![]() | |
static void | reorderSubfields (ObjectState *state) |
ImmediateControlField is a specialised InstructionField and represents the field of the TTA instruction that contains the long immediate control tag.
This tag defines the template of the instruction. A TTA instruction template specifies which move slots are used to program data transports and which are used to encode immediate bits. An ImmediateControlField object can never exist alone. It is always registered to a BinaryEncoding object.
Definition at line 57 of file ImmediateControlField.hh.
|
private |
A map type for binary encodings.
Definition at line 95 of file ImmediateControlField.hh.
ImmediateControlField::ImmediateControlField | ( | BinaryEncoding & | parent | ) |
The constructor.
Registers the immediate control field to the parent BinaryEncoding automatically. The field is added as the leftmost field of the TTA instruction.
parent | The parent encoding map. |
ObjectAlreadyExists | If the given encoding map has an immediate control field already. |
Definition at line 61 of file ImmediateControlField.cc.
References parent(), BinaryEncoding::setImmediateControlField(), and InstructionField::setParent().
ImmediateControlField::ImmediateControlField | ( | const ObjectState * | state, |
BinaryEncoding & | parent | ||
) |
The constructor.
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
parent | The parent encoding map. |
ObjectStateLoadingException | If an error occurs while loading the state. |
ObjectAlreadyExists | If the given encoding map has an immediate control field already. |
Definition at line 80 of file ImmediateControlField.cc.
References loadState(), parent(), BinaryEncoding::setImmediateControlField(), and InstructionField::setParent().
|
virtual |
The destructor.
Definition at line 92 of file ImmediateControlField.cc.
References assert, parent(), InstructionField::setParent(), and BinaryEncoding::unsetImmediateControlField().
void ImmediateControlField::addTemplateEncoding | ( | const std::string & | name, |
unsigned int | encoding | ||
) |
Assings the given code to the instruction template identified by the given name.
If the given instruction template has an encoding already, replaces the encoding with the given one.
name | Name of the instruction template. |
encoding | The code to be assigned. |
ObjectAlreadyExists | If the given code is already assigned to another instruction template. |
Definition at line 206 of file ImmediateControlField.cc.
References assert, MapTools::containsValue(), and templates_.
Referenced by BEMGenerator::addEncodings(), and loadState().
|
virtual |
Always throws OutOfRange exception because immediate control field does not have any child fields.
OutOfRange | Always thrown. |
Reimplemented from InstructionField.
Definition at line 276 of file ImmediateControlField.cc.
|
virtual |
Always returns 0.
Implements InstructionField.
Definition at line 263 of file ImmediateControlField.cc.
|
private |
Clears all the template encodings from the immediate control field.
Definition at line 346 of file ImmediateControlField.cc.
References templates_.
Referenced by loadState().
bool ImmediateControlField::hasTemplateEncoding | ( | const std::string & | name | ) | const |
Tells whether the instruction template with the given name has has a binary encoding in this field.
name | Name of the instruction template. |
Definition at line 167 of file ImmediateControlField.cc.
References MapTools::containsKey(), and templates_.
Referenced by BEMValidator::checkImmediateControlField(), DefaultDecoderGenerator::instructionTemplateCondition(), and templateEncoding().
std::string ImmediateControlField::instructionTemplate | ( | int | index | ) | const |
Returns the name of the instruction template encoded in this field at the given position.
index | The position index. |
OutOfRange | If the given index is negative or not smaller than the number of encodings of instruction templates. |
Definition at line 138 of file ImmediateControlField.cc.
References assert, templateCount(), and templates_.
Referenced by BinaryEncoding::longestTemplateExtraBits(), printImmediateControlField(), saveState(), and BinaryEncoding::width().
|
virtual |
Loads the state of the immediate control field from the given ObjectState tree.
state | The ObjectState tree. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Reimplemented from InstructionField.
Definition at line 290 of file ImmediateControlField.cc.
References addTemplateEncoding(), ObjectState::child(), ObjectState::childCount(), clearTemplateEncodings(), Exception::errorMessage(), ObjectState::intAttribute(), InstructionField::loadState(), ObjectState::name(), OSKEY_ENCODING, OSKEY_TEMPLATE_NAME, OSNAME_IMM_CONTROL_FIELD, OSNAME_TEMPLATE_MAP, and ObjectState::stringAttribute().
Referenced by ImmediateControlField().
BinaryEncoding * ImmediateControlField::parent | ( | ) | const |
Returns the parent encoding map.
Definition at line 106 of file ImmediateControlField.cc.
References assert, and InstructionField::parent().
Referenced by ImmediateControlField(), BinaryEncoding::setImmediateControlField(), and ~ImmediateControlField().
void ImmediateControlField::removeTemplateEncoding | ( | const std::string & | name | ) |
Removes the code of the instruction template with the given name.
name | Name of the instruction template. |
Definition at line 232 of file ImmediateControlField.cc.
References templates_.
|
virtual |
Saves the state of the immediate control field to an ObjectState tree.
Reimplemented from InstructionField.
Definition at line 323 of file ImmediateControlField.cc.
References ObjectState::addChild(), instructionTemplate(), OSKEY_ENCODING, InstructionField::OSKEY_POSITION, OSKEY_TEMPLATE_NAME, OSNAME_IMM_CONTROL_FIELD, OSNAME_TEMPLATE_MAP, InstructionField::relativePosition(), InstructionField::saveState(), ObjectState::setAttribute(), ObjectState::setName(), templateCount(), and templateEncoding().
int ImmediateControlField::templateCount | ( | ) | const |
Returns the number of instruction templates with a binary encoding assigned.
Definition at line 124 of file ImmediateControlField.cc.
References templates_.
Referenced by instructionTemplate(), BinaryEncoding::longestTemplateExtraBits(), printImmediateControlField(), saveState(), and BinaryEncoding::width().
unsigned int ImmediateControlField::templateEncoding | ( | const std::string & | name | ) | const |
Returns the code that identifies the instruction template with the given name.
name | Name of the instruction template. |
InstanceNotFound | If the given instruction template does not have a binary encoding in this field. |
Definition at line 182 of file ImmediateControlField.cc.
References assert, hasTemplateEncoding(), and templates_.
Referenced by CodeCompressorPlugin::addBitsForICField(), DefaultDecoderGenerator::instructionTemplateCondition(), printImmediateControlField(), saveState(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().
|
virtual |
Returns the bit width of the immediate control field.
Implements InstructionField.
Definition at line 243 of file ImmediateControlField.cc.
References MathTools::bitLength(), InstructionField::extraBits(), and templates_.
Referenced by CodeCompressorPlugin::addBitsForICField(), CodeCompressorPlugin::bemInstructionBits(), CodeCompressorPlugin::firstMoveSlotIndex(), printImmediateControlField(), BinaryEncoding::width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeLongImmediateTagSignal().
|
static |
ObjectState attribute key for the encoding of the instruction template.
Definition at line 91 of file ImmediateControlField.hh.
Referenced by loadState(), BEMSerializer::longImmTagToFile(), BEMSerializer::longImmTagToOM(), and saveState().
|
static |
ObjectState attribute key for the name of the instruction template.
Definition at line 88 of file ImmediateControlField.hh.
Referenced by loadState(), BEMSerializer::longImmTagToFile(), BEMSerializer::longImmTagToOM(), and saveState().
|
static |
ObjectState name for immediate control field.
Definition at line 84 of file ImmediateControlField.hh.
Referenced by BEMSerializer::convertToFileFormat(), loadState(), BinaryEncoding::loadState(), BEMSerializer::longImmTagToOM(), and saveState().
|
static |
ObjectState name for a template mapping.
Definition at line 86 of file ImmediateControlField.hh.
Referenced by loadState(), BEMSerializer::longImmTagToFile(), BEMSerializer::longImmTagToOM(), and saveState().
|
private |
Binary encodings for instruction templates.
Definition at line 100 of file ImmediateControlField.hh.
Referenced by addTemplateEncoding(), clearTemplateEncodings(), hasTemplateEncoding(), instructionTemplate(), removeTemplateEncoding(), templateCount(), templateEncoding(), and width().