OpenASIP  2.0
Public Member Functions | Static Public Attributes | List of all members
TTAMachine::ImmediateSlot Class Reference

#include <ImmediateSlot.hh>

Inheritance diagram for TTAMachine::ImmediateSlot:
Inheritance graph
Collaboration diagram for TTAMachine::ImmediateSlot:
Collaboration graph

Public Member Functions

 ImmediateSlot (const std::string &name, Machine &parent)
 
 ImmediateSlot (const ObjectState *state, Machine &parent)
 
virtual ~ImmediateSlot ()
 
int width () const
 
virtual void setMachine (Machine &machine)
 
virtual void unsetMachine ()
 
virtual void setName (const std::string &name)
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::Component
virtual ~Component ()
 
virtual TCEString name () const
 
virtual Machinemachine () const
 
virtual void ensureRegistration (const Component &component) const
 
virtual bool isRegistered () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_IMMEDIATE_SLOT = "immediate_slot"
 ObjectState name for ImmediateSlot. More...
 
- Static Public Attributes inherited from TTAMachine::Component
static const std::string OSNAME_COMPONENT = "component"
 ObjectState name for component. More...
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the component. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::Component
 Component (const std::string &name)
 
 Component (const ObjectState *state)
 
void internalSetMachine (Machine &machine)
 
void internalUnsetMachine ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Immediate slot is a machine component and represents a dedicated long immediate field in the TTA instruction.

Definition at line 44 of file ImmediateSlot.hh.

Constructor & Destructor Documentation

◆ ImmediateSlot() [1/2]

TTAMachine::ImmediateSlot::ImmediateSlot ( const std::string &  name,
Machine parent 
)

The constructor.

Parameters
nameName of the immediate slot.
parentThe parent machine.
Exceptions
InvalidNameIf the given name is not a valid component name.
ComponentAlreadyExistsIf the machine already contains a bus or immediate slot with the same name.

Definition at line 57 of file ImmediateSlot.cc.

58  : Component(name) {
59  setMachine(parent);
60 }

References setMachine().

Here is the call graph for this function:

◆ ImmediateSlot() [2/2]

TTAMachine::ImmediateSlot::ImmediateSlot ( const ObjectState state,
Machine parent 
)

The constructor.

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

Parameters
stateThe ObjectState instance.
parentThe parent machine.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.
ComponentAlreadyExistsIf the machine already contains a bus or immediate slot with the same name.

Definition at line 75 of file ImmediateSlot.cc.

76  : Component(state) {
77  const string procName = "ImmediateSlot::ImmediateSlot";
78 
79  if (parent.busNavigator().hasItem(name())) {
80  MOMTextGenerator textGenerator;
81  format text = textGenerator.text(
83  text % name();
85  __FILE__, __LINE__, procName, text.str());
86  }
87  if (parent.immediateSlotNavigator().hasItem(name())) {
88  MOMTextGenerator textGenerator;
89  format text = textGenerator.text(
91  text % name();
93  __FILE__, __LINE__, procName, text.str());
94  }
95 
96  setMachine(parent);
97  loadState(state);
98 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateSlotNavigator(), loadState(), TTAMachine::Component::name(), setMachine(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_BUS_AND_IMM_SLOT_WITH_SAME_NAME, and MOMTextGenerator::TXT_IMM_SLOT_EXISTS_BY_SAME_NAME.

Here is the call graph for this function:

◆ ~ImmediateSlot()

TTAMachine::ImmediateSlot::~ImmediateSlot ( )
virtual

The destructor.

Definition at line 103 of file ImmediateSlot.cc.

103  {
104  unsetMachine();
105 }

References unsetMachine().

Here is the call graph for this function:

Member Function Documentation

◆ loadState()

void TTAMachine::ImmediateSlot::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 when loading the state.

Reimplemented from TTAMachine::Component.

Definition at line 214 of file ImmediateSlot.cc.

214  {
215  if (state->name() != OSNAME_IMMEDIATE_SLOT) {
216  const string procName = "ImmediateSlot::loadState";
217  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
218  }
219 
220  Component::loadState(state);
221 }

References TTAMachine::Component::loadState(), ObjectState::name(), and OSNAME_IMMEDIATE_SLOT.

Referenced by ImmediateSlot().

Here is the call graph for this function:

◆ saveState()

ObjectState * TTAMachine::ImmediateSlot::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented from TTAMachine::Component.

Definition at line 199 of file ImmediateSlot.cc.

199  {
202  return state;
203 }

References OSNAME_IMMEDIATE_SLOT, TTAMachine::Component::saveState(), and ObjectState::setName().

Here is the call graph for this function:

◆ setMachine()

void TTAMachine::ImmediateSlot::setMachine ( Machine machine)
virtual

Registers the immediate slot to a machine.

Parameters
machMachine to which the immediate slot is going to be registered.
Exceptions
ComponentAlreadyExistsIf the given machine already has another immediate slot or bus by the same name.

Implements TTAMachine::Component.

Definition at line 142 of file ImmediateSlot.cc.

142  {
143  machine.addImmediateSlot(*this);
145 }

References TTAMachine::Machine::addImmediateSlot(), TTAMachine::Component::internalSetMachine(), and TTAMachine::Component::machine().

Referenced by ImmediateSlot().

Here is the call graph for this function:

◆ setName()

void TTAMachine::ImmediateSlot::setName ( const std::string &  name)
virtual

Sets the name of the immediate slot.

Parameters
nameThe new name.
Exceptions
ComponentAlreadyExistsIf the machine already contains an immediate slot or bus with the same name.
InvalidNameIf the given name is not a valid component name.

Reimplemented from TTAMachine::Component.

Definition at line 178 of file ImmediateSlot.cc.

178  {
179  if (name == this->name()) {
180  return;
181  }
182 
183  Machine* mach = machine();
184  if (mach->immediateSlotNavigator().hasItem(name) ||
185  mach->busNavigator().hasItem(name)) {
186  const string procName = "ImmediateSlot::setName";
187  throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
188  } else {
190  }
191 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::Component::setName().

Here is the call graph for this function:

◆ unsetMachine()

void TTAMachine::ImmediateSlot::unsetMachine ( )
virtual

Removes registration of the immediate slot from its current machine.

Implements TTAMachine::Component.

Definition at line 151 of file ImmediateSlot.cc.

151  {
152  assert(machine() != NULL);
153  Machine* mach = machine();
154 
155  // delete the template slots that use this slot
157  mach->instructionTemplateNavigator();
158  for (int i = 0; i < itNav.count(); i++) {
159  InstructionTemplate* iTemp = itNav.item(i);
160  iTemp->removeSlot(name());
161  }
162 
164  mach->deleteImmediateSlot(*this);
165 }

References assert, TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::deleteImmediateSlot(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Component::internalUnsetMachine(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::InstructionTemplate::removeSlot().

Referenced by ~ImmediateSlot().

Here is the call graph for this function:

◆ width()

int TTAMachine::ImmediateSlot::width ( ) const

Returns the bit width of the immediate slot.

The bit width is determined by the instruction templates which use the immediate slot.

Returns
The bit width of the immediate slot.

Definition at line 117 of file ImmediateSlot.cc.

117  {
118 
119  int width = 0;
120 
123  for (int i = 0; i < itNav.count(); i++) {
124  InstructionTemplate* iTemp = itNav.item(i);
125  if (iTemp->supportedWidth(name()) > width) {
126  width = iTemp->supportedWidth(name());
127  }
128  }
129 
130  return width;
131 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), and TTAMachine::InstructionTemplate::supportedWidth().

Referenced by BEMGenerator::addTopLevelFields(), and BEMValidator::checkImmediateSlot().

Here is the call graph for this function:

Member Data Documentation

◆ OSNAME_IMMEDIATE_SLOT

const std::string TTAMachine::ImmediateSlot::OSNAME_IMMEDIATE_SLOT = "immediate_slot"
static

ObjectState name for ImmediateSlot.

Definition at line 60 of file ImmediateSlot.hh.

Referenced by loadState(), TTAMachine::Machine::loadState(), and saveState().


The documentation for this class was generated from the following files:
TTAMachine::Component::internalUnsetMachine
void internalUnsetMachine()
TTAMachine::Component::setName
virtual void setName(const std::string &name)
Definition: MachinePart.cc:142
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::ImmediateSlot::setMachine
virtual void setMachine(Machine &machine)
Definition: ImmediateSlot.cc:142
TTAMachine::Component::saveState
virtual ObjectState * saveState() const
Definition: MachinePart.cc:189
ObjectState
Definition: ObjectState.hh:59
MOMTextGenerator::TXT_IMM_SLOT_EXISTS_BY_SAME_NAME
@ TXT_IMM_SLOT_EXISTS_BY_SAME_NAME
Definition: MOMTextGenerator.hh:86
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ObjectState::setName
void setName(const std::string &name)
TTAMachine::Component::internalSetMachine
void internalSetMachine(Machine &machine)
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::Component::Component
Component(const std::string &name)
Definition: MachinePart.cc:82
TTAMachine::ImmediateSlot::OSNAME_IMMEDIATE_SLOT
static const std::string OSNAME_IMMEDIATE_SLOT
ObjectState name for ImmediateSlot.
Definition: ImmediateSlot.hh:60
TTAMachine::Machine::InstructionTemplateNavigator
Navigator< InstructionTemplate > InstructionTemplateNavigator
Navigator type for InstructionTemplateNavigator.
Definition: Machine.hh:225
TTAMachine::Component::loadState
virtual void loadState(const ObjectState *state)
Definition: MachinePart.cc:205
TTAMachine::ImmediateSlot::unsetMachine
virtual void unsetMachine()
Definition: ImmediateSlot.cc:151
ObjectState::name
std::string name() const
TTAMachine::ImmediateSlot::width
int width() const
Definition: ImmediateSlot.cc:117
TTAMachine::ImmediateSlot::loadState
virtual void loadState(const ObjectState *state)
Definition: ImmediateSlot.cc:214
TTAMachine::Component::machine
virtual Machine * machine() const
MOMTextGenerator
Definition: MOMTextGenerator.hh:40
TTAMachine::Machine::addImmediateSlot
virtual void addImmediateSlot(ImmediateSlot &slot)
Definition: Machine.cc:299
ComponentAlreadyExists
Definition: Exception.hh:510
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
MOMTextGenerator::TXT_BUS_AND_IMM_SLOT_WITH_SAME_NAME
@ TXT_BUS_AND_IMM_SLOT_WITH_SAME_NAME
Definition: MOMTextGenerator.hh:85
TTAMachine::Machine::instructionTemplateNavigator
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition: Machine.cc:428