OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ImmediateSlotField Class Reference

#include <ImmediateSlotField.hh>

Inheritance diagram for ImmediateSlotField:
Inheritance graph
Collaboration diagram for ImmediateSlotField:
Collaboration graph

Public Member Functions

 ImmediateSlotField (const std::string &name, int width, BinaryEncoding &parent)
 
 ImmediateSlotField (const ObjectState *state, BinaryEncoding &parent)
 
virtual ~ImmediateSlotField ()
 
BinaryEncodingparent () const
 
std::string name () const
 
void setName (const std::string &name)
 
virtual int childFieldCount () const
 
virtual int width () const
 
void setWidth (int width)
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from InstructionField
virtual ~InstructionField ()
 
InstructionFieldparent () const
 
virtual InstructionFieldchildField (int position) 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_IMMEDIATE_SLOT_FIELD
 ObjectState name for immediate slot field.
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the immediate slot.
 
static const std::string OSKEY_WIDTH = "width"
 ObjectState attribute key for the width of the field.
 
- Static Public Attributes inherited from InstructionField
static const std::string OSNAME_INSTRUCTION_FIELD = "instr_field"
 ObjectState name for instruction field.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 
static const std::string OSKEY_POSITION = "position"
 ObjectState attribute key for the relative position of the field.
 

Private Attributes

std::string name_
 Name of the immediate slot.
 
int width_
 The bit width of the field.
 

Additional Inherited Members

- Protected Member Functions inherited from InstructionField
 InstructionField (InstructionField *parent)
 
 InstructionField (const ObjectState *state, InstructionField *parent)
 
void setParent (InstructionField *parent)
 
- Static Protected Member Functions inherited from InstructionField
static void reorderSubfields (ObjectState *state)
 

Detailed Description

ImmediateSlotField represents a dedicated immediate slot in TTA instruction.

Definition at line 44 of file ImmediateSlotField.hh.

Constructor & Destructor Documentation

◆ ImmediateSlotField() [1/2]

ImmediateSlotField::ImmediateSlotField ( const std::string &  name,
int  width,
BinaryEncoding parent 
)

The constructor.

Parameters
nameName of the immediate slot programmed by this field.
widthBit width of the field. @parent The parent binary encoding map.
Exceptions
OutOfRangeIf the bit width is smaller than 1.
ObjectAlreadyExistsIf the parent binary encoding already has an immediate slot with the given name.

Definition at line 57 of file ImmediateSlotField.cc.

60 if (width < 1) {
61 const string procName = "ImmediateSlotField::ImmediateSlotField";
62 throw OutOfRange(__FILE__, __LINE__, procName);
63 }
64
65 setParent(NULL);
68}
void addImmediateSlot(ImmediateSlotField &slot)
virtual int width() const
std::string name() const
int width_
The bit width of the field.
std::string name_
Name of the immediate slot.
BinaryEncoding * parent() const
void setParent(InstructionField *parent)

References BinaryEncoding::addImmediateSlot(), parent(), InstructionField::setParent(), and width().

Here is the call graph for this function:

◆ ImmediateSlotField() [2/2]

ImmediateSlotField::ImmediateSlotField ( const ObjectState state,
BinaryEncoding parent 
)

The constructor.

Loads the state of the object from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 79 of file ImmediateSlotField.cc.

81 : InstructionField(state, &parent), name_(""), width_(0) {
82 loadState(state);
83 setParent(NULL);
86}
virtual void loadState(const ObjectState *state)

References BinaryEncoding::addImmediateSlot(), loadState(), parent(), and InstructionField::setParent().

Here is the call graph for this function:

◆ ~ImmediateSlotField()

ImmediateSlotField::~ImmediateSlotField ( )
virtual

The destructor.

Definition at line 91 of file ImmediateSlotField.cc.

91 {
92 BinaryEncoding* parent = this->parent();
93 assert(parent != NULL);
94 setParent(NULL);
96}
#define assert(condition)
void removeImmediateSlot(ImmediateSlotField &slot)

References assert, parent(), BinaryEncoding::removeImmediateSlot(), and InstructionField::setParent().

Here is the call graph for this function:

Member Function Documentation

◆ childFieldCount()

int ImmediateSlotField::childFieldCount ( ) const
virtual

Returns 0 always since immediate slot does not have any child fields.

Returns
0.

Implements InstructionField.

Definition at line 156 of file ImmediateSlotField.cc.

156 {
157 return 0;
158}

◆ loadState()

void ImmediateSlotField::loadState ( const ObjectState state)
virtual

Loads the state of the object from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Reimplemented from InstructionField.

Definition at line 210 of file ImmediateSlotField.cc.

210 {
211 const string procName = "ImmediateSlotField::loadState";
212
213 if (state->name() != OSNAME_IMMEDIATE_SLOT_FIELD) {
214 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
215 }
216
218
219 try {
222 } catch (const Exception&) {
223 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
224 }
225}
static const std::string OSNAME_IMMEDIATE_SLOT_FIELD
ObjectState name for immediate slot field.
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the immediate slot.
static const std::string OSKEY_WIDTH
ObjectState attribute key for the width of the field.
void setName(const std::string &name)
virtual void loadState(const ObjectState *state)
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const

References ObjectState::intAttribute(), InstructionField::loadState(), ObjectState::name(), OSKEY_NAME, OSKEY_WIDTH, OSNAME_IMMEDIATE_SLOT_FIELD, setName(), setWidth(), and ObjectState::stringAttribute().

Referenced by ImmediateSlotField().

Here is the call graph for this function:

◆ name()

std::string ImmediateSlotField::name ( ) const

◆ parent()

BinaryEncoding * ImmediateSlotField::parent ( ) const

Returns the parent binary encoding map.

Returns
The parent binary encoding map.

Definition at line 105 of file ImmediateSlotField.cc.

105 {
107 if (parent == NULL) {
108 return NULL;
109 } else {
110 BinaryEncoding* bemParent = dynamic_cast<BinaryEncoding*>(parent);
111 assert(bemParent != NULL);
112 return bemParent;
113 }
114}
InstructionField * parent() const

References assert, parent(), and InstructionField::parent().

Referenced by BinaryEncoding::addImmediateSlot(), ImmediateSlotField(), ImmediateSlotField(), parent(), BinaryEncoding::removeImmediateSlot(), setName(), and ~ImmediateSlotField().

Here is the call graph for this function:

◆ saveState()

ObjectState * ImmediateSlotField::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented from InstructionField.

Definition at line 193 of file ImmediateSlotField.cc.

193 {
196 state->setAttribute(OSKEY_NAME, name());
197 state->setAttribute(OSKEY_WIDTH, width());
198 return state;
199}
virtual ObjectState * saveState() const
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)

References name(), OSKEY_NAME, OSKEY_WIDTH, OSNAME_IMMEDIATE_SLOT_FIELD, InstructionField::saveState(), ObjectState::setAttribute(), ObjectState::setName(), and width().

Referenced by BinaryEncoding::saveState().

Here is the call graph for this function:

◆ setName()

void ImmediateSlotField::setName ( const std::string &  name)

Sets the name of the immediate slot programmed by this field.

Parameters
nameThe name.
Exceptions
ObjectAlreadyExistsIf the parent binary encoding has an immediate slot field for the given immediate slot already.

Definition at line 137 of file ImmediateSlotField.cc.

137 {
138 if (name == this->name()) {
139 return;
140 }
141
142 if (parent()->hasImmediateSlot(name)) {
143 const string procName = "ImmediateSlotField::setName";
144 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
145 } else {
146 name_ = name;
147 }
148}

References name(), name_, and parent().

Referenced by loadState().

Here is the call graph for this function:

◆ setWidth()

void ImmediateSlotField::setWidth ( int  width)

Sets the bit width of the field.

Parameters
widthThe new bit width.
Exceptions
OutOfRangeIf the given width is smaller than 1.

Definition at line 179 of file ImmediateSlotField.cc.

179 {
180 if (width < 1) {
181 const string procName = "ImmediateSlotField::setWidth";
182 throw OutOfRange(__FILE__, __LINE__, procName);
183 }
184 width_ = width;
185}

References width(), and width_.

Referenced by loadState().

Here is the call graph for this function:

◆ width()

int ImmediateSlotField::width ( ) const
virtual

Member Data Documentation

◆ name_

std::string ImmediateSlotField::name_
private

Name of the immediate slot.

Definition at line 71 of file ImmediateSlotField.hh.

Referenced by name(), and setName().

◆ OSKEY_NAME

const std::string ImmediateSlotField::OSKEY_NAME = "name"
static

ObjectState attribute key for the name of the immediate slot.

Definition at line 65 of file ImmediateSlotField.hh.

Referenced by BEMSerializer::immediateSlotToFile(), BEMSerializer::immediateSlotToOM(), loadState(), and saveState().

◆ OSKEY_WIDTH

const std::string ImmediateSlotField::OSKEY_WIDTH = "width"
static

ObjectState attribute key for the width of the field.

Definition at line 67 of file ImmediateSlotField.hh.

Referenced by BEMSerializer::immediateSlotToFile(), BEMSerializer::immediateSlotToOM(), loadState(), and saveState().

◆ OSNAME_IMMEDIATE_SLOT_FIELD

const std::string ImmediateSlotField::OSNAME_IMMEDIATE_SLOT_FIELD
static
Initial value:
=
"imm_slot_field"

ObjectState name for immediate slot field.

Definition at line 63 of file ImmediateSlotField.hh.

Referenced by BEMSerializer::convertToFileFormat(), BEMSerializer::immediateSlotToOM(), BinaryEncoding::loadState(), loadState(), and saveState().

◆ width_

int ImmediateSlotField::width_
private

The bit width of the field.

Definition at line 73 of file ImmediateSlotField.hh.

Referenced by setWidth(), and width().


The documentation for this class was generated from the following files: