OpenASIP  2.0
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. More...
 
static const std::string OSKEY_EXTENSION = "extension"
 ObjectState attribute key for the extension mode. More...
 
static const std::string OSVALUE_SIGN = "sign"
 ObjectState attribute value for sign extension. More...
 
static const std::string OSVALUE_ZERO = "zero"
 ObjectState attribute value for zero extension. More...
 
static const std::string OSKEY_LATENCY = "latency"
 ObjectState attribute key for latency. More...
 
- Static Public Attributes inherited from TTAMachine::RegisterFile
static const std::string OSNAME_REGISTER_FILE = "reg_file"
 ObjectState name for RegisterFile. More...
 
static const std::string OSKEY_TYPE = "type"
 ObjectState attribute key for register file type. More...
 
static const std::string OSVALUE_NORMAL = "normal"
 ObjectState attribute value for normal register file type. More...
 
static const std::string OSVALUE_RESERVED = "reserved"
 ObjectState attribute value for reserved register file type. More...
 
static const std::string OSVALUE_VOLATILE = "volatile"
 ObjectState attribute value for volatile register file type. More...
 
static const std::string OSKEY_MAX_READS = "max_r"
 ObjectState attribute key for maximum simultaneous readers. More...
 
static const std::string OSKEY_MAX_WRITES = "max_w"
 ObjectState attribute key for maximum simultaneous writers. More...
 
static const std::string OSKEY_GUARD_LATENCY = "g_latency"
 ObjectState attribute key for the guard latency. More...
 
static const std::string OSKEY_ZERO_REGISTER = "zero_register"
 ObjectState attribute key for zero register flag. More...
 
- Static Public Attributes inherited from TTAMachine::BaseRegisterFile
static const std::string OSNAME_BASE_REGISTER_FILE = "baseregfile"
 ObjectState name for BaseRegisterFile. More...
 
static const std::string OSKEY_SIZE = "size"
 ObjectState attribute key for the number of registers. More...
 
static const std::string OSKEY_WIDTH = "width"
 ObjectState attribute key for bit width of the registers. More...
 
- Static Public Attributes inherited from TTAMachine::Unit
static const std::string OSNAME_UNIT = "unit"
 ObjectState name for Unit. 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...
 

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.

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 }

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 }

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 }

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 }

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  {
186  extension_ = mode;
187 }

References extension_.

Referenced by loadStateWithoutReferences().

◆ 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  }
202  latency_ = latency;
203 }

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 }

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 }

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

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 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Machine::removeImmediateUnit(), TTAMachine::InstructionTemplate::removeSlots(), and TTAMachine::Unit::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 loadStateWithoutReferences(), and saveState().

◆ OSKEY_LATENCY

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

ObjectState attribute key for latency.

Definition at line 83 of file ImmediateUnit.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ 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(), and saveState().

◆ 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(), and saveState().


The documentation for this class was generated from the following files:
TTAMachine::RegisterFile::setMaxWrites
virtual void setMaxWrites(int maxWrites)
Definition: RegisterFile.cc:247
TTAMachine::BaseRegisterFile::setWidth
virtual void setWidth(int width)
Definition: BaseRegisterFile.cc:112
TTAMachine::ImmediateUnit::OSVALUE_ZERO
static const std::string OSVALUE_ZERO
ObjectState attribute value for zero extension.
Definition: ImmediateUnit.hh:81
TTAMachine::Machine::ZERO
@ ZERO
Zero extension.
Definition: Machine.hh:81
TTAMachine::Component::setName
virtual void setName(const std::string &name)
Definition: MachinePart.cc:142
mode
mode
Definition: tceopgen.cc:45
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
OutOfRange
Definition: Exception.hh:320
TTAMachine::ImmediateUnit::extension_
Machine::Extension extension_
Definition: ImmediateUnit.hh:93
ObjectState
Definition: ObjectState.hh:59
LATENCY
const int LATENCY
Definition: ImmediateUnit.cc:40
ObjectState::setName
void setName(const std::string &name)
TTAMachine::RegisterFile::maxWrites
virtual int maxWrites() const
Definition: RegisterFile.cc:135
TTAMachine::ImmediateUnit::latency
virtual int latency() const
Definition: ImmediateUnit.cc:155
TTAMachine::ImmediateUnit::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: ImmediateUnit.cc:275
TTAMachine::Machine::BusNavigator
Navigator< Bus > BusNavigator
Navigator type for BusNavigator.
Definition: Machine.hh:213
TTAMachine::RegisterFile::loadState
virtual void loadState(const ObjectState *state)
Definition: RegisterFile.cc:433
TTAMachine::RegisterFile::saveState
virtual ObjectState * saveState() const
Definition: RegisterFile.cc:392
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::ImmediateUnit::unsetMachine
virtual void unsetMachine()
Definition: ImmediateUnit.cc:209
TTAMachine::RegisterFile::maxReads
virtual int maxReads() const
Definition: RegisterFile.cc:123
TTAMachine::ImmediateUnit::latency_
int latency_
Definition: ImmediateUnit.hh:99
TTAMachine::Machine::InstructionTemplateNavigator
Navigator< InstructionTemplate > InstructionTemplateNavigator
Navigator type for InstructionTemplateNavigator.
Definition: Machine.hh:225
TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT
static const std::string OSNAME_IMMEDIATE_UNIT
ObjectState name for ImmediateUnit.
Definition: ImmediateUnit.hh:75
TTAMachine::ImmediateUnit::OSKEY_EXTENSION
static const std::string OSKEY_EXTENSION
ObjectState attribute key for the extension mode.
Definition: ImmediateUnit.hh:77
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
TTAMachine::Machine::SIGN
@ SIGN
Sign extension.
Definition: Machine.hh:82
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::RegisterFile::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)
Definition: RegisterFile.cc:74
TTAMachine::Component::machine
virtual Machine * machine() const
TTAMachine::ImmediateUnit::OSVALUE_SIGN
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
Definition: ImmediateUnit.hh:79
TTAMachine::RegisterFile::NORMAL
@ NORMAL
Used for general register allocation.
Definition: RegisterFile.hh:51
ComponentAlreadyExists
Definition: Exception.hh:510
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
TTAMachine::ImmediateUnit::OSKEY_LATENCY
static const std::string OSKEY_LATENCY
ObjectState attribute key for latency.
Definition: ImmediateUnit.hh:83
TTAMachine::RegisterFile::guardLatency
virtual int guardLatency() const
Definition: RegisterFile.cc:333
MAX_WRITES
const int MAX_WRITES
Definition: ImmediateUnit.cc:43
TTAMachine::ImmediateUnit::setExtensionMode
virtual void setExtensionMode(Machine::Extension mode)
Definition: ImmediateUnit.cc:185
TTAMachine::ImmediateUnit::setLatency
virtual void setLatency(int latency)
Definition: ImmediateUnit.cc:197
TTAMachine::BaseRegisterFile::size
virtual int size() const
TTAMachine::BaseRegisterFile::width
virtual int width() const
TTAMachine::Unit::unsetMachine
virtual void unsetMachine()
Definition: Unit.cc:262
TTAMachine::RegisterFile::setNumberOfRegisters
virtual void setNumberOfRegisters(int registers)
Definition: RegisterFile.cc:320
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100