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

#include <ImmediateUnit.hh>

Inheritance diagram for TTAMachine::ImmediateUnit:
Inheritance graph
Collaboration diagram for TTAMachine::ImmediateUnit:
Collaboration graph

Public Member Functions

 ImmediateUnit (const std::string &name, unsigned int size, unsigned int width, unsigned int maxReads, unsigned int guardLatency, Machine::Extension extension)
 
 ImmediateUnit (const ObjectState *state)
 
 ~ImmediateUnit ()
 
virtual void setMaxWrites (int maxWrites)
 
virtual void setName (const std::string &name)
 
bool signExtends () const
 
bool zeroExtends () const
 
virtual Machine::Extension extensionMode () const
 
virtual int latency () const
 
virtual void setExtensionMode (Machine::Extension mode)
 
virtual void unsetMachine ()
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::RegisterFile
 RegisterFile (const std::string &name, unsigned int size, unsigned int width, unsigned int maxReads, unsigned int maxwrites, unsigned int guardLatency, Type type, bool zeroRegister=false)
 
 RegisterFile (const ObjectState *state)
 
virtual ~RegisterFile ()
 
virtual RegisterFilecopy () const
 
virtual int maxReads () const
 
virtual int maxWrites () const
 
virtual RegisterFile::Type type () const
 
virtual bool isNormal () const
 
virtual bool isVolatile () const
 
virtual bool isReserved () const
 
virtual void setMaxReads (int maxReads)
 
virtual void setType (RegisterFile::Type type)
 
virtual void setNumberOfRegisters (int registers)
 
virtual int guardLatency () const
 
virtual void setGuardLatency (int latency)
 
virtual bool isArchitectureEqual (const RegisterFile &rf) const
 
virtual bool isUsedAsGuard () const
 
virtual bool zeroRegister () const
 
virtual void setZeroRegister (const bool &value)
 
PortfirstReadPort () const
 
PortfirstWritePort () const
 
- Public Member Functions inherited from TTAMachine::BaseRegisterFile
virtual ~BaseRegisterFile ()
 
virtual int numberOfRegisters () const
 
virtual int width () const
 
virtual int size () const
 
virtual void setWidth (int width)
 
virtual RFPortport (const std::string &name) const
 
virtual RFPortport (int index) const
 
- Public Member Functions inherited from TTAMachine::Unit
virtual ~Unit ()
 
virtual bool hasPort (const std::string &name) const
 
virtual int portCount () const
 
virtual int outputPortCount (bool countBidir=false) const
 
virtual int inputPortCount (bool countBidir=false) const
 
virtual int bidirPortCount () const
 
virtual void setMachine (Machine &mach)
 
- 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_UNIT
 ObjectState name for ImmediateUnit.
 
static const std::string OSKEY_EXTENSION = "extension"
 ObjectState attribute key for the extension mode.
 
static const std::string OSVALUE_SIGN = "sign"
 ObjectState attribute value for sign extension.
 
static const std::string OSVALUE_ZERO = "zero"
 ObjectState attribute value for zero extension.
 
static const std::string OSKEY_LATENCY = "latency"
 ObjectState attribute key for latency.
 
- Static Public Attributes inherited from TTAMachine::RegisterFile
static const std::string OSNAME_REGISTER_FILE = "reg_file"
 ObjectState name for RegisterFile.
 
static const std::string OSKEY_TYPE = "type"
 ObjectState attribute key for register file type.
 
static const std::string OSVALUE_NORMAL = "normal"
 ObjectState attribute value for normal register file type.
 
static const std::string OSVALUE_RESERVED = "reserved"
 ObjectState attribute value for reserved register file type.
 
static const std::string OSVALUE_VOLATILE = "volatile"
 ObjectState attribute value for volatile register file type.
 
static const std::string OSKEY_MAX_READS = "max_r"
 ObjectState attribute key for maximum simultaneous readers.
 
static const std::string OSKEY_MAX_WRITES = "max_w"
 ObjectState attribute key for maximum simultaneous writers.
 
static const std::string OSKEY_GUARD_LATENCY = "g_latency"
 ObjectState attribute key for the guard latency.
 
static const std::string OSKEY_ZERO_REGISTER = "zero_register"
 ObjectState attribute key for zero register flag.
 
- Static Public Attributes inherited from TTAMachine::BaseRegisterFile
static const std::string OSNAME_BASE_REGISTER_FILE = "baseregfile"
 ObjectState name for BaseRegisterFile.
 
static const std::string OSKEY_SIZE = "size"
 ObjectState attribute key for the number of registers.
 
static const std::string OSKEY_WIDTH = "width"
 ObjectState attribute key for bit width of the registers.
 
- Static Public Attributes inherited from TTAMachine::Unit
static const std::string OSNAME_UNIT = "unit"
 ObjectState name for Unit.
 
- 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.
 

Private Member Functions

virtual void setLatency (int latency)
 
void loadStateWithoutReferences (const ObjectState *state)
 

Private Attributes

Machine::Extension extension_
 
int latency_
 

Additional Inherited Members

- Public Types inherited from TTAMachine::RegisterFile
enum  Type { NORMAL , RESERVED , VOLATILE }
 Type of the register file indicates how the RF is used. More...
 
- Protected Member Functions inherited from TTAMachine::BaseRegisterFile
 BaseRegisterFile (const std::string &name, int size, int width)
 
 BaseRegisterFile (const ObjectState *state)
 
- Protected Member Functions inherited from TTAMachine::Unit
 Unit (const std::string &name)
 
 Unit (const ObjectState *state)
 
virtual void removePort (Port &port)
 
- 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

Represent a immediate unit in the machine.

Definition at line 50 of file ImmediateUnit.hh.

Constructor & Destructor Documentation

◆ ImmediateUnit() [1/2]

TTAMachine::ImmediateUnit::ImmediateUnit ( const std::string &  name,
unsigned int  size,
unsigned int  width,
unsigned int  maxReads,
unsigned int  guardLatency,
Machine::Extension  extension 
)

Constructor.

Parameters
nameName of the immediate unit.
sizeNumber of immediate registers in the immediate unit.
widthBit width of the long immediate registers in the immediate unit.
extensionExtension mode applied to the long immediate when it is narrower than the immediate register, see Machine::Extension.
latencyNumber of cycles needed between the encoding of a long immediate and its earliest transport on a data bus. The value "0" indicates that the long immediate can be read onto a bus in the same cycle in which the instruction that encodes it is executed.
Exceptions
OutOfRangeIf the given size or width is invalid.
InvalidNameIf the given name is not a valid name for a component.

Definition at line 74 of file ImmediateUnit.cc.

81 extension_(extension),
85}
const int LATENCY
const int MAX_WRITES
virtual int size() const
virtual int width() const
virtual void setWidth(int width)
virtual TCEString name() const
Machine::Extension extension_
virtual int maxReads() const
RegisterFile(const std::string &name, unsigned int size, unsigned int width, unsigned int maxReads, unsigned int maxwrites, unsigned int guardLatency, Type type, bool zeroRegister=false)
@ NORMAL
Used for general register allocation.
virtual int guardLatency() const
virtual void setNumberOfRegisters(int registers)

References TTAMachine::RegisterFile::setNumberOfRegisters(), TTAMachine::BaseRegisterFile::setWidth(), TTAMachine::BaseRegisterFile::size(), and TTAMachine::BaseRegisterFile::width().

Here is the call graph for this function:

◆ ImmediateUnit() [2/2]

TTAMachine::ImmediateUnit::ImmediateUnit ( const ObjectState state)

Constructor.

Loads the state of the immediate unit from the given ObjectState instance. Does not load references to other components.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if connections to other machine parts cannot be made.

Definition at line 98 of file ImmediateUnit.cc.

98 : RegisterFile(state) {
100}
void loadStateWithoutReferences(const ObjectState *state)

References loadStateWithoutReferences().

Here is the call graph for this function:

◆ ~ImmediateUnit()

TTAMachine::ImmediateUnit::~ImmediateUnit ( )

Destructor.

Definition at line 105 of file ImmediateUnit.cc.

105 {
106 unsetMachine();
107}

References unsetMachine().

Here is the call graph for this function:

Member Function Documentation

◆ extensionMode()

Machine::Extension TTAMachine::ImmediateUnit::extensionMode ( ) const
virtual

◆ latency()

int TTAMachine::ImmediateUnit::latency ( ) const
virtual

◆ loadState()

void TTAMachine::ImmediateUnit::loadState ( const ObjectState state)
virtual

Loads its state from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if the connections to other machine parts cannot be made.

Reimplemented from TTAMachine::RegisterFile.

Definition at line 261 of file ImmediateUnit.cc.

261 {
264}
virtual void loadState(const ObjectState *state)

References TTAMachine::RegisterFile::loadState(), and loadStateWithoutReferences().

Referenced by TTAMachine::Machine::loadState().

Here is the call graph for this function:

◆ loadStateWithoutReferences()

void TTAMachine::ImmediateUnit::loadStateWithoutReferences ( const ObjectState state)
private

Loads the state of the immediate unit without references to other components.

Parameters
stateThe ObjectState instance from which the state is loaded.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 275 of file ImmediateUnit.cc.

275 {
276 const string procName = "ImmediateUnit::loadStateWithoutReferences";
277
278 if (state->name() != OSNAME_IMMEDIATE_UNIT) {
279 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
280 }
281
282 try {
283 string extension = state->stringAttribute(OSKEY_EXTENSION);
284 if (extension == OSVALUE_SIGN) {
286 } else if (extension == OSVALUE_ZERO) {
288 } else {
289 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
290 }
291
293 assert(latency_ >= 0);
294
295 } catch (const Exception& e) {
297 __FILE__, __LINE__, procName, e.errorMessage());
298 }
299}
#define assert(condition)
std::string errorMessage() const
Definition Exception.cc:123
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
virtual void setLatency(int latency)
static const std::string OSKEY_LATENCY
ObjectState attribute key for latency.
virtual void setExtensionMode(Machine::Extension mode)
static const std::string OSNAME_IMMEDIATE_UNIT
ObjectState name for ImmediateUnit.
static const std::string OSVALUE_ZERO
ObjectState attribute value for zero extension.
static const std::string OSKEY_EXTENSION
ObjectState attribute key for the extension mode.
@ SIGN
Sign extension.
Definition Machine.hh:82
@ ZERO
Zero extension.
Definition Machine.hh:81

References assert, Exception::errorMessage(), ObjectState::intAttribute(), latency_, ObjectState::name(), OSKEY_EXTENSION, OSKEY_LATENCY, OSNAME_IMMEDIATE_UNIT, OSVALUE_SIGN, OSVALUE_ZERO, setExtensionMode(), setLatency(), TTAMachine::Machine::SIGN, ObjectState::stringAttribute(), and TTAMachine::Machine::ZERO.

Referenced by ImmediateUnit(), and loadState().

Here is the call graph for this function:

◆ saveState()

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

Saves the contents to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from TTAMachine::RegisterFile.

Definition at line 233 of file ImmediateUnit.cc.

233 {
234
237
238 // set extension mode
239 if (extension_ == Machine::SIGN) {
241 } else {
243 }
244
246
247 return iUnit;
248}
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
virtual ObjectState * saveState() const

References extension_, latency_, OSKEY_EXTENSION, OSKEY_LATENCY, OSNAME_IMMEDIATE_UNIT, OSVALUE_SIGN, OSVALUE_ZERO, TTAMachine::RegisterFile::saveState(), ObjectState::setAttribute(), ObjectState::setName(), and TTAMachine::Machine::SIGN.

Here is the call graph for this function:

◆ setExtensionMode()

void TTAMachine::ImmediateUnit::setExtensionMode ( Machine::Extension  mode)
virtual

Sets the extension mode for the immediate unit.

Parameters
modeThe new extension mode.

Definition at line 185 of file ImmediateUnit.cc.

185 {
187}
mode
Definition tceopgen.cc:45

References extension_.

Referenced by loadStateWithoutReferences(), and IUDialog::onOK().

◆ setLatency()

void TTAMachine::ImmediateUnit::setLatency ( int  latency)
privatevirtual

Sets the latency of the immediate unit.

Parameters
latencyThe new latency.
Exceptions
OutOfRangeIf the given latency is less than zero.

Definition at line 197 of file ImmediateUnit.cc.

197 {
198 if (latency != LATENCY) {
199 string procName = "ImmediateUnit::setLatency";
200 throw OutOfRange(__FILE__, __LINE__, procName);
201 }
203}
virtual int latency() const

References LATENCY, latency(), and latency_.

Referenced by loadStateWithoutReferences().

Here is the call graph for this function:

◆ setMaxWrites()

void TTAMachine::ImmediateUnit::setMaxWrites ( int  maxWrites)
virtual

Sets the maximum number of ports that can write a register all in the same cycle.

For immediate unit the value is fixed to 1.

Parameters
writesMaximum number of ports.
Exceptions
OutOfRangeIf the given number of maximum writes is out of range.

Reimplemented from TTAMachine::RegisterFile.

Definition at line 171 of file ImmediateUnit.cc.

171 {
172 if (maxWrites != MAX_WRITES) {
173 std::string procName = "ImmediateUnit::setMaxWrites";
174 throw OutOfRange(__FILE__, __LINE__, procName);
175 }
177}
virtual void setMaxWrites(int maxWrites)
virtual int maxWrites() const

References MAX_WRITES, TTAMachine::RegisterFile::maxWrites(), and TTAMachine::RegisterFile::setMaxWrites().

Here is the call graph for this function:

◆ setName()

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

Sets the name of the immediate unit.

Parameters
nameName of the immediate unit.
Exceptions
ComponentAlreadyExistsIf an immediate unit with the given name is already in the same machine.
InvalidNameIf the given name is not a valid name for a component.

Reimplemented from TTAMachine::RegisterFile.

Definition at line 120 of file ImmediateUnit.cc.

120 {
121 if (name == this->name()) {
122 return;
123 }
124
125 if (machine() != NULL) {
126 if (machine()->immediateUnitNavigator().hasItem(name)) {
127 string procName = "ImmediateUnit::setName";
128 throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
129 } else {
131 }
132 } else {
134 }
135}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
virtual void setName(const std::string &name)

References machine, TTAMachine::Component::name(), and TTAMachine::Component::setName().

Referenced by IUDialog::onOK().

Here is the call graph for this function:

◆ signExtends()

bool TTAMachine::ImmediateUnit::signExtends ( ) const
inline

◆ unsetMachine()

void TTAMachine::ImmediateUnit::unsetMachine ( )
virtual

Removes the immediate unit from machine.

Reimplemented from TTAMachine::RegisterFile.

Definition at line 209 of file ImmediateUnit.cc.

209 {
210 Machine* mach = machine();
211 if (mach == NULL) {
212 return;
213 }
214
216 mach->instructionTemplateNavigator();
217 Machine::BusNavigator busNav = mach->busNavigator();
218 for (int itIndex = 0; itIndex < itNav.count(); itIndex++) {
219 InstructionTemplate* it = itNav.item(itIndex);
220 it->removeSlots(*this);
221 }
223 mach->removeImmediateUnit(*this);
224}
virtual void unsetMachine()=0
Navigator< Bus > BusNavigator
Navigator type for BusNavigator.
Definition Machine.hh:213
Navigator< InstructionTemplate > InstructionTemplateNavigator
Navigator type for InstructionTemplateNavigator.
Definition Machine.hh:225

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, TTAMachine::Machine::removeImmediateUnit(), TTAMachine::InstructionTemplate::removeSlots(), and TTAMachine::Component::unsetMachine().

Referenced by ~ImmediateUnit().

Here is the call graph for this function:

◆ zeroExtends()

bool TTAMachine::ImmediateUnit::zeroExtends ( ) const
inline

Definition at line 63 of file ImmediateUnit.hh.

63{ return extension_ == Machine::ZERO; }

References extension_, and TTAMachine::Machine::ZERO.

Referenced by TTAProgram::TPEFProgramFactory::findInstrTemplate().

Member Data Documentation

◆ extension_

Machine::Extension TTAMachine::ImmediateUnit::extension_
private

Extension mode applied to the long immediate when it is narrower than the immediate register.

Definition at line 93 of file ImmediateUnit.hh.

Referenced by extensionMode(), saveState(), setExtensionMode(), signExtends(), and zeroExtends().

◆ latency_

int TTAMachine::ImmediateUnit::latency_
private

Minimum number of cycles needed between the encoding of a long immediate and its earliest transport on a data bus.

Definition at line 99 of file ImmediateUnit.hh.

Referenced by latency(), loadStateWithoutReferences(), saveState(), and setLatency().

◆ OSKEY_EXTENSION

const string TTAMachine::ImmediateUnit::OSKEY_EXTENSION = "extension"
static

ObjectState attribute key for the extension mode.

Definition at line 77 of file ImmediateUnit.hh.

Referenced by ADFSerializer::immediateUnitToMDF(), loadStateWithoutReferences(), saveState(), and ADFSerializer::setIUExtensionMode().

◆ OSKEY_LATENCY

const string TTAMachine::ImmediateUnit::OSKEY_LATENCY = "latency"
static

◆ OSNAME_IMMEDIATE_UNIT

const string TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT
static

◆ OSVALUE_SIGN

const string TTAMachine::ImmediateUnit::OSVALUE_SIGN = "sign"
static

ObjectState attribute value for sign extension.

Definition at line 79 of file ImmediateUnit.hh.

Referenced by loadStateWithoutReferences(), saveState(), and ADFSerializer::setIUExtensionMode().

◆ OSVALUE_ZERO

const string TTAMachine::ImmediateUnit::OSVALUE_ZERO = "zero"
static

ObjectState attribute value for zero extension.

Definition at line 81 of file ImmediateUnit.hh.

Referenced by loadStateWithoutReferences(), saveState(), and ADFSerializer::setIUExtensionMode().


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