OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
- Static Public Attributes inherited from TTAMachine::Component
static const std::string OSNAME_COMPONENT = "component"
 ObjectState name for component.
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for the name of the component.
 

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}
Component(const std::string &name)
virtual TCEString name() const
virtual void setMachine(Machine &machine)

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}
virtual void loadState(const ObjectState *state)
virtual boost::format text(int textId)

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
221}
std::string name() const
virtual void loadState(const ObjectState *state)
static const std::string OSNAME_IMMEDIATE_SLOT
ObjectState name for ImmediateSlot.

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}
void setName(const std::string &name)
virtual ObjectState * saveState() const

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 {
145}
virtual Machine * machine() const
void internalSetMachine(Machine &machine)
virtual void addImmediateSlot(ImmediateSlot &slot)
Definition Machine.cc:299

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

Referenced by ImmediateSlot(), and 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}
virtual void setName(const std::string &name)

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}
#define assert(condition)
Navigator< InstructionTemplate > InstructionTemplateNavigator
Navigator type for InstructionTemplateNavigator.
Definition Machine.hh:225

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}
ComponentType * item(int index) const
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition Machine.cc:428

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

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

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

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