OpenASIP
2.0
|
#include <InstructionField.hh>
Public Member Functions | |
virtual | ~InstructionField () |
InstructionField * | parent () const |
virtual int | childFieldCount () const =0 |
virtual InstructionField & | childField (int position) const |
virtual int | width () const =0 |
int | bitPosition () const |
int | relativePosition () const |
virtual void | setRelativePosition (int position) |
void | setExtraBits (int bits) |
int | extraBits () const |
virtual void | loadState (const ObjectState *state) |
virtual ObjectState * | saveState () const |
Public Member Functions inherited from Serializable | |
virtual | ~Serializable () |
Static Public Attributes | |
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 | |
InstructionField (InstructionField *parent) | |
InstructionField (const ObjectState *state, InstructionField *parent) | |
void | setParent (InstructionField *parent) |
Static Protected Member Functions | |
static void | reorderSubfields (ObjectState *state) |
Private Attributes | |
int | relativePos_ |
Indicates the relative position of the field. More... | |
int | extraBits_ |
The number of extra bits. More... | |
InstructionField * | parent_ |
The parent instruction field. More... | |
InstructionField is an abstract base class that represents the properties common to all types of bit fields of the TTA instruction word.
Definition at line 43 of file InstructionField.hh.
|
virtual |
|
protected |
The constructor.
relativePosition | Relative position of the instruction field within its parent field. |
parent | The parent instruction field. |
Definition at line 56 of file InstructionField.cc.
References childFieldCount(), parent(), and relativePos_.
|
protected |
The constructor.
Loads the state of the object from the given ObjectState tree.
state | The ObjectState tree. |
parent | The parent instruction field. |
ObjectStateLoadingException | If an error occurs while loading the state. |
Definition at line 75 of file InstructionField.cc.
References childFieldCount(), loadState(), parent(), and relativePos_.
int InstructionField::bitPosition | ( | ) | const |
Returns the bit-accurate position of the field within its parent field.
Definition at line 132 of file InstructionField.cc.
References childField(), parent(), relativePosition(), and width().
Referenced by BEMTester::canAddComponentPriorityEncoding(), BEMTester::fieldsOverlap(), ProGe::RV32MicroCodeGenerator::findBusWidths(), printImmediateControlField(), printLImmDstRegisterField(), printMoveSlot(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeInstructionTemplateProcedures().
|
virtual |
Returns the child field which has the given relative position within the instruction field.
This base class implementation just checks whether the given position is out of range and throw the exception if necessary.
position | The position. |
OutOfRange | If the position is negative or not smaller than the number of child fields. |
Reimplemented in GuardField, ImmediateControlField, BinaryEncoding, MoveSlot, SlotField, and NullInstructionField.
Definition at line 117 of file InstructionField.cc.
References childFieldCount(), and NullInstructionField::instance().
Referenced by bitPosition(), MoveSlot::childField(), and setRelativePosition().
|
pure virtual |
Returns the number of (immediate) child fields within the instruction field.
Implemented in BinaryEncoding, GuardField, MoveSlot, SlotField, ImmediateControlField, LImmDstRegisterField, ImmediateSlotField, and NullInstructionField.
Referenced by childField(), InstructionField(), and setRelativePosition().
int InstructionField::extraBits | ( | ) | const |
Returns the number of extra bits in the field.
Definition at line 229 of file InstructionField.cc.
References extraBits_.
Referenced by BEMGenerator::addSubfields(), NOPEncoding::bitPosition(), BridgeEncoding::bitPosition(), ImmediateEncoding::encodingPosition(), ImmediateEncoding::immediatePosition(), printGuardFieldEncodings(), printImmediateControlField(), printSlotFieldEncodings(), printSourceFieldEncodings(), saveState(), SocketEncoding::socketCodePosition(), SocketEncoding::socketIDPosition(), SourceField::width(), ImmediateControlField::width(), SlotField::width(), GuardField::width(), and BinaryEncoding::width().
|
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. |
Implements Serializable.
Reimplemented in BinaryEncoding, GuardField, MoveSlot, SlotField, LImmDstRegisterField, ImmediateControlField, SourceField, and ImmediateSlotField.
Definition at line 242 of file InstructionField.cc.
References __func__, Exception::errorMessage(), ObjectState::intAttribute(), OSKEY_EXTRA_BITS, OSKEY_POSITION, relativePosition(), setExtraBits(), and ObjectState::stringAttribute().
Referenced by InstructionField(), ImmediateSlotField::loadState(), ImmediateControlField::loadState(), LImmDstRegisterField::loadState(), SlotField::loadState(), MoveSlot::loadState(), and GuardField::loadState().
InstructionField * InstructionField::parent | ( | ) | const |
Returns the parent instruction field.
Returns NULL if the field has no parent field (BinaryEncoding).
Definition at line 100 of file InstructionField.cc.
References parent_.
Referenced by bitPosition(), InstructionField(), ImmediateSlotField::parent(), LImmDstRegisterField::parent(), GuardField::parent(), SlotField::parent(), ImmediateControlField::parent(), MoveSlot::parent(), setParent(), setRelativePosition(), and BinaryEncoding::unsetImmediateControlField().
int InstructionField::relativePosition | ( | ) | const |
Returns the relative position of the field compared to sibling fields.
If the field is the rightmost field, returns 0. The leftmost field returns the number of sibling fields - 1.
Definition at line 160 of file InstructionField.cc.
References relativePos_.
Referenced by bitPosition(), MoveSlot::childField(), BinaryEncoding::childField(), loadState(), saveState(), ImmediateControlField::saveState(), and setRelativePosition().
|
staticprotected |
Sorts the child ObjectState instances of the given ObjectState instance such that they are returned by child(index) method in the correct order.
The correct order means that at first the rightmost subfield is returned and then the next to left and so on.
state | The ObjectState instance. |
Definition at line 297 of file InstructionField.cc.
References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), ObjectState::hasAttribute(), ObjectState::intAttribute(), OSKEY_POSITION, and ObjectState::removeChild().
Referenced by MoveSlot::loadState(), and BinaryEncoding::loadState().
|
virtual |
Saves the state of the object to an ObjectState tree.
Implements Serializable.
Reimplemented in BinaryEncoding, GuardField, MoveSlot, SlotField, ImmediateControlField, SourceField, LImmDstRegisterField, ImmediateSlotField, and DestinationField.
Definition at line 268 of file InstructionField.cc.
References extraBits(), OSKEY_EXTRA_BITS, OSKEY_POSITION, OSNAME_INSTRUCTION_FIELD, relativePosition(), and ObjectState::setAttribute().
Referenced by ImmediateSlotField::saveState(), LImmDstRegisterField::saveState(), ImmediateControlField::saveState(), SlotField::saveState(), MoveSlot::saveState(), and GuardField::saveState().
void InstructionField::setExtraBits | ( | int | bits | ) |
Sets the number of extra (zero) bits to the field.
The field can be forced longer than necessary by defining some number of extra bits. In practice, there will be the given amount of zeros always in the MSB end of the field.
bits | The number of extra bits. |
OutOfRange | If the given number is negative. |
Definition at line 214 of file InstructionField.cc.
References extraBits_.
Referenced by BEMGenerator::addSubfields(), and loadState().
|
protected |
Sets the parent instruction field.
parent | The parent field. |
Definition at line 282 of file InstructionField.cc.
References parent(), and parent_.
Referenced by DestinationField::DestinationField(), GuardField::GuardField(), ImmediateControlField::ImmediateControlField(), ImmediateSlotField::ImmediateSlotField(), LImmDstRegisterField::LImmDstRegisterField(), MoveSlot::MoveSlot(), SourceField::SourceField(), DestinationField::~DestinationField(), GuardField::~GuardField(), ImmediateControlField::~ImmediateControlField(), ImmediateSlotField::~ImmediateSlotField(), LImmDstRegisterField::~LImmDstRegisterField(), MoveSlot::~MoveSlot(), and SourceField::~SourceField().
|
virtual |
Sets a new relative position for the field.
position | The new relative position. |
OutOfRange | If the given position is negative. |
Definition at line 172 of file InstructionField.cc.
References assert, childField(), childFieldCount(), NullInstructionField::instance(), parent(), relativePos_, and relativePosition().
Referenced by GuardField::GuardField().
|
pure virtual |
Returns the bit width of the field.
Implemented in BinaryEncoding, GuardField, MoveSlot, SlotField, ImmediateControlField, SourceField, LImmDstRegisterField, ImmediateSlotField, and NullInstructionField.
Referenced by bitPosition(), BEMTester::fieldsOverlap(), and printInstructionLayout().
|
private |
The number of extra bits.
Definition at line 90 of file InstructionField.hh.
Referenced by extraBits(), and setExtraBits().
|
static |
ObjectState attribute key for the number of extra bits.
Definition at line 75 of file InstructionField.hh.
Referenced by BEMSerializer::guardFieldToFile(), BEMSerializer::guardFieldToOM(), BEMSerializer::immediateSlotToOM(), loadState(), BEMSerializer::longImmDstRegFieldToOM(), BEMSerializer::longImmTagToFile(), BEMSerializer::longImmTagToOM(), BEMSerializer::moveSlotToFile(), BEMSerializer::moveSlotToOM(), saveState(), BEMSerializer::slotFieldToFile(), and BEMSerializer::slotFieldToOM().
|
static |
ObjectState attribute key for the relative position of the field.
Definition at line 77 of file InstructionField.hh.
Referenced by BEMSerializer::guardFieldToFile(), BEMSerializer::guardFieldToOM(), BEMSerializer::immediateSlotToFile(), BEMSerializer::immediateSlotToOM(), loadState(), BEMSerializer::longImmDstRegFieldToOM(), BEMSerializer::longImmDstRegisterFieldToFile(), BEMSerializer::longImmTagToFile(), BEMSerializer::longImmTagToOM(), BEMSerializer::moveSlotToFile(), BEMSerializer::moveSlotToOM(), reorderSubfields(), saveState(), ImmediateControlField::saveState(), BEMSerializer::slotFieldToFile(), and BEMSerializer::slotFieldToOM().
|
static |
ObjectState name for instruction field.
Definition at line 73 of file InstructionField.hh.
Referenced by saveState().
|
private |
The parent instruction field.
Definition at line 92 of file InstructionField.hh.
Referenced by parent(), and setParent().
|
private |
Indicates the relative position of the field.
Definition at line 88 of file InstructionField.hh.
Referenced by InstructionField(), relativePosition(), and setRelativePosition().