OpenASIP  2.0
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. More...
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the immediate slot. More...
 
static const std::string OSKEY_WIDTH = "width"
 ObjectState attribute key for the width of the field. 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...
 

Private Attributes

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

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);
66  parent.addImmediateSlot(*this);
67  setParent(&parent);
68 }

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);
84  parent.addImmediateSlot(*this);
85  setParent(&parent);
86 }

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 }

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 }

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 }

References assert, and InstructionField::parent().

Referenced by BinaryEncoding::addImmediateSlot(), ImmediateSlotField(), 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 }

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(), loadState(), BinaryEncoding::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:
BinaryEncoding
Definition: BinaryEncoding.hh:61
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
OutOfRange
Definition: Exception.hh:320
ImmediateSlotField::OSNAME_IMMEDIATE_SLOT_FIELD
static const std::string OSNAME_IMMEDIATE_SLOT_FIELD
ObjectState name for immediate slot field.
Definition: ImmediateSlotField.hh:63
ObjectState
Definition: ObjectState.hh:59
ObjectState::setName
void setName(const std::string &name)
InstructionField
Definition: InstructionField.hh:43
ImmediateSlotField::setWidth
void setWidth(int width)
Definition: ImmediateSlotField.cc:179
InstructionField::saveState
virtual ObjectState * saveState() const
Definition: InstructionField.cc:268
ImmediateSlotField::loadState
virtual void loadState(const ObjectState *state)
Definition: ImmediateSlotField.cc:210
assert
#define assert(condition)
Definition: Application.hh:86
ImmediateSlotField::parent
BinaryEncoding * parent() const
Definition: ImmediateSlotField.cc:105
InstructionField::setParent
void setParent(InstructionField *parent)
Definition: InstructionField.cc:282
InstructionField::parent
InstructionField * parent() const
Definition: InstructionField.cc:100
ImmediateSlotField::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the immediate slot.
Definition: ImmediateSlotField.hh:65
Exception
Definition: Exception.hh:54
ImmediateSlotField::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for the width of the field.
Definition: ImmediateSlotField.hh:67
ImmediateSlotField::width
virtual int width() const
Definition: ImmediateSlotField.cc:167
ObjectState::name
std::string name() const
ImmediateSlotField::setName
void setName(const std::string &name)
Definition: ImmediateSlotField.cc:137
BinaryEncoding::removeImmediateSlot
void removeImmediateSlot(ImmediateSlotField &slot)
Definition: BinaryEncoding.cc:320
ImmediateSlotField::name
std::string name() const
Definition: ImmediateSlotField.cc:123
ObjectAlreadyExists
Definition: Exception.hh:1002
ImmediateSlotField::name_
std::string name_
Name of the immediate slot.
Definition: ImmediateSlotField.hh:71
InstructionField::loadState
virtual void loadState(const ObjectState *state)
Definition: InstructionField.cc:242
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
BinaryEncoding::addImmediateSlot
void addImmediateSlot(ImmediateSlotField &slot)
Definition: BinaryEncoding.cc:300
InstructionField::InstructionField
InstructionField(InstructionField *parent)
Definition: InstructionField.cc:56
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
ImmediateSlotField::width_
int width_
The bit width of the field.
Definition: ImmediateSlotField.hh:73