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

#include <RegisterFile.hh>

Inheritance diagram for TTAMachine::RegisterFile:
Inheritance graph
Collaboration diagram for TTAMachine::RegisterFile:
Collaboration graph

Public Types

enum  Type { NORMAL, RESERVED, VOLATILE }
 Type of the register file indicates how the RF is used. More...
 

Public Member Functions

 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 setName (const std::string &name)
 
virtual void setMaxReads (int maxReads)
 
virtual void setMaxWrites (int maxWrites)
 
virtual void setType (RegisterFile::Type type)
 
virtual void setNumberOfRegisters (int registers)
 
virtual int guardLatency () const
 
virtual void setGuardLatency (int latency)
 
virtual void unsetMachine ()
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
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_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

bool updateMaxReadsAndWrites () const
 
 RegisterFile (const RegisterFile &)
 Copying forbidden, use the copy() method. More...
 
RegisterFileoperator= (const RegisterFile &)
 Assingment forbidden. More...
 
void loadStateWithoutReferences (const ObjectState *state)
 
void deleteGuards (int registers) const
 

Private Attributes

int maxReads_
 Max number of ports that can read a register all in the same cycle. More...
 
int maxWrites_
 Max number of ports that can read a register all in the same cycle. More...
 
int guardLatency_
 The guard latency of the register file. More...
 
Type type_
 Type of the register file. More...
 
bool zeroRegister_
 

Additional Inherited Members

- 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

Represents a register-file in TTA processor.

Definition at line 47 of file RegisterFile.hh.

Member Enumeration Documentation

◆ Type

Type of the register file indicates how the RF is used.

Enumerator
NORMAL 

Used for general register allocation.

RESERVED 

Used for custom, user controlled register allocation.

VOLATILE 

Used for user-controlled I/O communication.

Definition at line 50 of file RegisterFile.hh.

50  {
51  NORMAL, ///< Used for general register allocation.
52  RESERVED, ///< Used for custom, user controlled register allocation.
53  VOLATILE ///< Used for user-controlled I/O communication.
54  };

Constructor & Destructor Documentation

◆ RegisterFile() [1/3]

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 
)

Constructor.

Parameters
nameName of the register file.
sizeNumber of registers in the register file.
widthBit width of the registers in the register file.
maxReadsMaximum simultaneous reads of a register.
maxWritesMaximum simultaneous writes of a register.
maxRwMaximum simultaneous reads of a register in the same cycle the register is written.
typeType of the register file, see RegisterFile::Type.
Exceptions
OutOfRangeIf some of the given parameters has an illegal value.
InvalidNameIf the given name is not a valid component name.

Definition at line 74 of file RegisterFile.cc.

References guardLatency(), maxReads(), maxWrites(), setGuardLatency(), setMaxReads(), and setMaxWrites().

Referenced by copy().

Here is the call graph for this function:

◆ RegisterFile() [2/3]

TTAMachine::RegisterFile::RegisterFile ( const ObjectState state)
explicit

Constructor.

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

Parameters
stateThe ObjectState from which the name is taken.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState tree is invalid.

Definition at line 99 of file RegisterFile.cc.

100  : BaseRegisterFile(state),
101  maxReads_(0),
102  maxWrites_(0),
103  guardLatency_(0),
104  type_(NORMAL),
105  zeroRegister_(false) {
107 }

References loadStateWithoutReferences().

Here is the call graph for this function:

◆ ~RegisterFile()

TTAMachine::RegisterFile::~RegisterFile ( )
virtual

Destructor.

Definition at line 112 of file RegisterFile.cc.

112  {
113  unsetMachine();
114 }

References unsetMachine().

Here is the call graph for this function:

◆ RegisterFile() [3/3]

TTAMachine::RegisterFile::RegisterFile ( const RegisterFile )
private

Copying forbidden, use the copy() method.

Member Function Documentation

◆ copy()

RegisterFile * TTAMachine::RegisterFile::copy ( ) const
virtual

Creates and returns a copy of the register file.

Returns
Copy of register file.

Definition at line 601 of file RegisterFile.cc.

601  {
602 
603  return new RegisterFile(saveState());
604 }

References RegisterFile(), and saveState().

Here is the call graph for this function:

◆ deleteGuards()

void TTAMachine::RegisterFile::deleteGuards ( int  registers) const
private

Deletes the guards that refer to registers would not exist if there were the given number of registers in this register file.

Parameters
registersThe number of registers.

Definition at line 492 of file RegisterFile.cc.

492  {
493 
494  Machine* mach = machine();
495  if (mach == NULL) {
496  return;
497  }
498 
499  // for each bus
500  Machine::BusNavigator navi = mach->busNavigator();
501  for (int busIndex = 0; busIndex < navi.count(); busIndex++) {
502  Bus* bus = navi.item(busIndex);
503  int guardIndex = 0;
504 
505  // delete register guards that refer to non-existing registers
506  while (guardIndex < bus->guardCount()) {
507  Guard* guard = bus->guard(guardIndex);
508  RegisterGuard* regGuard =
509  dynamic_cast<RegisterGuard*>(guard);
510  if (regGuard != NULL && regGuard->registerFile() == this &&
511  regGuard->registerIndex() >= registers) {
512 
513  // guard is removed from bus automatically
514  delete regGuard;
515  } else {
516  guardIndex++;
517  }
518  }
519  }
520 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Bus::guard(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::RegisterGuard::registerFile(), and TTAMachine::RegisterGuard::registerIndex().

Referenced by setNumberOfRegisters(), and unsetMachine().

Here is the call graph for this function:

◆ firstReadPort()

Port * TTAMachine::RegisterFile::firstReadPort ( ) const

Definition at line 607 of file RegisterFile.cc.

607  {
608  for (int i = 0; i < portCount(); i++) {
609  Port* p = port(i);
610  if (p->outputSocket() != NULL) {
611  return p;
612  }
613  }
614  return NULL;
615 }

References TTAMachine::Port::outputSocket(), TTAMachine::BaseRegisterFile::port(), and TTAMachine::Unit::portCount().

Referenced by RegisterRenamer::renameLiveRange(), BFRenameLiveRange::setTerminals(), BFRegCopyAfter::splitMove(), and BFRegCopyBefore::splitMove().

Here is the call graph for this function:

◆ firstWritePort()

Port * TTAMachine::RegisterFile::firstWritePort ( ) const

Definition at line 618 of file RegisterFile.cc.

618  {
619  for (int i = 0; i < portCount(); i++) {
620  Port* p = port(i);
621  if (p->inputSocket() != NULL) {
622  return p;
623  }
624  }
625  return NULL;
626 }

References TTAMachine::Port::inputSocket(), TTAMachine::BaseRegisterFile::port(), and TTAMachine::Unit::portCount().

Referenced by RegisterRenamer::renameLiveRange(), BFRenameLiveRange::setTerminals(), BFRegCopyAfter::splitMove(), and BFRegCopyBefore::splitMove().

Here is the call graph for this function:

◆ guardLatency()

int TTAMachine::RegisterFile::guardLatency ( ) const
virtual

◆ isArchitectureEqual()

bool TTAMachine::RegisterFile::isArchitectureEqual ( const RegisterFile rf) const
virtual

Checks is this register file architecture equal with the given register file.

Architecture equality means that register files have same values, names and port names may differ.

Parameters
rfRegister file to compare with.
Returns
True if the register files are architecture equal.

Definition at line 532 of file RegisterFile.cc.

532  {
533 
534  if (size() != rf.size()) {
535  return false;
536  }
537  if (width() != rf.width()) {
538  return false;
539  }
540  if (maxReads_ != rf.maxReads()) {
541  return false;
542  }
543  if (maxWrites_ != rf.maxWrites()) {
544  return false;
545  }
546  if (type_ != rf.type()) {
547  return false;
548  }
549  if (guardLatency_ != rf.guardLatency()) {
550  return false;
551  }
552  if (portCount() != rf.portCount()) {
553  return false;
554  }
555  // ports have same width that the register file, so port widths are not
556  // needed to check
557 
558  return true;
559 }

References guardLatency(), guardLatency_, maxReads(), maxReads_, maxWrites(), maxWrites_, TTAMachine::Unit::portCount(), TTAMachine::BaseRegisterFile::size(), type(), type_, and TTAMachine::BaseRegisterFile::width().

Referenced by MachineResourceModifier::analyzeRegisters().

Here is the call graph for this function:

◆ isNormal()

bool TTAMachine::RegisterFile::isNormal ( ) const
virtual

Returns true if the type of the register file is normal, otherwise false.

Returns
True if the type of the register file is normal, otherwise false.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 158 of file RegisterFile.cc.

158  {
159  return (type_ == NORMAL);
160 }

References NORMAL, and type_.

Referenced by ProDeRFEditPolicy::getCommand().

◆ isReserved()

bool TTAMachine::RegisterFile::isReserved ( ) const
virtual

Returns true if the type of the register file is reserved, otherwise false.

Returns
True if the type of the register file is reserved, otherwise false.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 184 of file RegisterFile.cc.

184  {
185  return (type_ == RESERVED);
186 }

References RESERVED, and type_.

Referenced by TDGen::analyzeRegisters(), and ProDeRFEditPolicy::getCommand().

◆ isUsedAsGuard()

bool TTAMachine::RegisterFile::isUsedAsGuard ( ) const
virtual

Returns true if the register file is used as a guard.

Returns
True if the register file is used as a guard.

Definition at line 567 of file RegisterFile.cc.

567  {
568 
569  Machine* mach = machine();
570  if (mach == NULL) {
571  return false;
572  }
573 
574  // for each bus
575  Machine::BusNavigator navi = mach->busNavigator();
576  for (int busIndex = 0; busIndex < navi.count(); busIndex++) {
577  Bus* bus = navi.item(busIndex);
578  int guardIndex = 0;
579 
580  // check if there are register guards that refer to this register file
581  while (guardIndex < bus->guardCount()) {
582  Guard* guard = bus->guard(guardIndex);
583  RegisterGuard* regGuard =
584  dynamic_cast<RegisterGuard*>(guard);
585  if (regGuard != NULL && regGuard->registerFile() == this) {
586  return true;
587  } else {
588  guardIndex++;
589  }
590  }
591  }
592  return false;
593 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Bus::guard(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), and TTAMachine::RegisterGuard::registerFile().

Referenced by Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableIU(), Automagic::checkForSelectableRF(), ProGeTools::checkForSelectableRF(), AutoSelectImplementationsDialog::findRFImplementations(), BlockImplementationDialog::onHDBSelection(), and ComponentImplementationSelector::selectRFs().

Here is the call graph for this function:

◆ isVolatile()

bool TTAMachine::RegisterFile::isVolatile ( ) const
virtual

Returns true if the type of the register file is volatile, otherwise false.

Returns
True if the type of the register file is volatile, otherwise false.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 171 of file RegisterFile.cc.

171  {
172  return (type_ == VOLATILE);
173 }

References type_, and VOLATILE.

Referenced by ProDeRFEditPolicy::getCommand().

◆ loadState()

void TTAMachine::RegisterFile::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.

Reimplemented from TTAMachine::BaseRegisterFile.

Reimplemented in TTAMachine::NullRegisterFile, TTAMachine::ImmediateUnit, and UnboundedRegisterFile.

Definition at line 433 of file RegisterFile.cc.

433  {
434  const string procName = "RegisterFile::loadState";
437  MOMTextGenerator textGenerator;
438 }

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

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

Here is the call graph for this function:

◆ loadStateWithoutReferences()

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

Loads the state of the register file without references to other components.

Parameters
stateThe ObjectState instance from which the state is loaded.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid.

Definition at line 449 of file RegisterFile.cc.

449  {
450  const string procName = "RegisterFile::loadStateWithoutReferences";
451 
452  if (! (state->name() == OSNAME_REGISTER_FILE ||
454  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
455  }
456 
457  try {
458  string type = state->stringAttribute(OSKEY_TYPE);
459  if (type == OSVALUE_NORMAL) {
460  setType(NORMAL);
461  } else if (type == OSVALUE_RESERVED) {
462  setType(RESERVED);
463  } else if (type == OSVALUE_VOLATILE) {
464  setType(VOLATILE);
465  } else {
466  const string errorMsg = "Unknown register file type in "
467  "ObjectState instance.";
469  __FILE__, __LINE__, procName, errorMsg);
470  }
471 
475  if (state->hasAttribute(OSKEY_ZERO_REGISTER)) {
477  }
478 
479  } catch (const Exception& e) {
481  __FILE__, __LINE__, procName, e.errorMessage());
482  }
483 }

References ObjectState::boolAttribute(), Exception::errorMessage(), ObjectState::hasAttribute(), ObjectState::intAttribute(), ObjectState::name(), NORMAL, OSKEY_GUARD_LATENCY, OSKEY_MAX_READS, OSKEY_MAX_WRITES, OSKEY_TYPE, OSKEY_ZERO_REGISTER, TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT, OSNAME_REGISTER_FILE, OSVALUE_NORMAL, OSVALUE_RESERVED, OSVALUE_VOLATILE, RESERVED, setGuardLatency(), setMaxReads(), setMaxWrites(), setType(), setZeroRegister(), ObjectState::stringAttribute(), type(), and VOLATILE.

Referenced by loadState(), and RegisterFile().

Here is the call graph for this function:

◆ maxReads()

int TTAMachine::RegisterFile::maxReads ( ) const
virtual

◆ maxWrites()

int TTAMachine::RegisterFile::maxWrites ( ) const
virtual

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

Returns
The number of ports that can write a register all in same cycle.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 135 of file RegisterFile.cc.

135  {
137  return maxWrites_;
138 }

References maxWrites_, and updateMaxReadsAndWrites().

Referenced by ResourceConstraintAnalyzer::analyzeMoveNode(), ADFCombiner::createPortsAndSockets(), FullyConnectedCheck::fix(), isArchitectureEqual(), BlockImplementationDialog::onHDBSelection(), RegisterFile(), HDB::RFArchitecture::RFArchitecture(), ComponentImplementationSelector::rfImplementations(), TTAMachine::ImmediateUnit::setMaxWrites(), and setMaxWrites().

Here is the call graph for this function:

◆ operator=()

RegisterFile& TTAMachine::RegisterFile::operator= ( const RegisterFile )
private

Assingment forbidden.

◆ saveState()

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

Saves the contents to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from TTAMachine::BaseRegisterFile.

Reimplemented in TTAMachine::NullRegisterFile, and TTAMachine::ImmediateUnit.

Definition at line 392 of file RegisterFile.cc.

392  {
393 
395  regFile->setName(OSNAME_REGISTER_FILE);
396 
397  // set type
398  switch(type_) {
399  case NORMAL: regFile->setAttribute(OSKEY_TYPE, OSVALUE_NORMAL); break;
401  break;
403  break;
404  default: assert(false);
405  }
406 
407  // set max reads
409 
410  // set max writes
412 
413  // set guard latency
415 
416  // set zero register
417  if (zeroRegister_) {
419  }
420 
421  return regFile;
422 }

References assert, guardLatency_, maxReads_, maxWrites_, NORMAL, OSKEY_GUARD_LATENCY, OSKEY_MAX_READS, OSKEY_MAX_WRITES, OSKEY_TYPE, OSKEY_ZERO_REGISTER, OSNAME_REGISTER_FILE, OSVALUE_NORMAL, OSVALUE_RESERVED, OSVALUE_VOLATILE, RESERVED, TTAMachine::BaseRegisterFile::saveState(), ObjectState::setAttribute(), ObjectState::setName(), type_, VOLATILE, and zeroRegister_.

Referenced by copy(), and TTAMachine::ImmediateUnit::saveState().

Here is the call graph for this function:

◆ setGuardLatency()

void TTAMachine::RegisterFile::setGuardLatency ( int  latency)
virtual

Sets the guard latency.

Parameters
latencyThe new guard latency.
Exceptions
OutOfRangeIf the given value is negative or if local + global guard latency would be zero.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 346 of file RegisterFile.cc.

346  {
347  if (latency < 0) {
348  throw OutOfRange(__FILE__, __LINE__, __func__);
349  }
350 
351  // check that local guard latency + global guard latency > 0
352  if (latency == 0 && isRegistered()) {
353  ControlUnit* gcu = machine()->controlUnit();
354  if (gcu != NULL) {
355  int oldLatency = guardLatency();
356  guardLatency_ = latency;
357  try {
358  // this throws OutOfRange if the local guard latency cannot
359  // be zero
360  gcu->setGlobalGuardLatency(gcu->globalGuardLatency());
361  } catch (const OutOfRange& exception) {
362  guardLatency_ = oldLatency;
363  throw exception;
364  }
365  }
366  }
367 
368  guardLatency_ = latency;
369 }

References __func__, TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::globalGuardLatency(), guardLatency(), guardLatency_, TTAMachine::Component::isRegistered(), TTAMachine::Component::machine(), and TTAMachine::ControlUnit::setGlobalGuardLatency().

Referenced by loadStateWithoutReferences(), and RegisterFile().

Here is the call graph for this function:

◆ setMaxReads()

void TTAMachine::RegisterFile::setMaxReads ( int  reads)
virtual

Sets the maximum number of ports that can read a register all in the same cycle. Note that this function is only needed if all of the ports are unconnected, otherwise this value is computed automatically.

The given value must be at least zero.

Parameters
readsMaximum number of ports.
Exceptions
OutOfRangeIf the given number of maximum reads is out of range.

Reimplemented in TTAMachine::NullRegisterFile, and UnboundedRegisterFile.

Definition at line 227 of file RegisterFile.cc.

227  {
228  if (reads < 0) {
229  std::string procName = "RegisterFile::setMaxReads";
230  throw OutOfRange(__FILE__, __LINE__, procName);
231  }
232  maxReads_ = reads;
233 }

References maxReads_.

Referenced by loadStateWithoutReferences(), and RegisterFile().

◆ setMaxWrites()

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

Sets the maximum number of ports that can write a register all in the same cycle. Note that this function is only needed if all of the ports are unconnected, otherwise this value is computed automatically.

The given value must be at least zero.

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

Reimplemented in TTAMachine::NullRegisterFile, TTAMachine::ImmediateUnit, and UnboundedRegisterFile.

Definition at line 247 of file RegisterFile.cc.

247  {
248  if (maxWrites < 0) {
249  std::string procName = "RegisterFile::setMaxWrites";
250  throw OutOfRange(__FILE__, __LINE__, procName);
251  }
253 }

References maxWrites(), and maxWrites_.

Referenced by loadStateWithoutReferences(), RegisterFile(), and TTAMachine::ImmediateUnit::setMaxWrites().

Here is the call graph for this function:

◆ setName()

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

Sets the name of the register file.

Parameters
nameName of the register file.
Exceptions
ComponentAlreadyExistsIf a register file with the given name is already in the same machine.
InvalidNameIf the given name is not a valid component name.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::NullRegisterFile, TTAMachine::ImmediateUnit, and UnboundedRegisterFile.

Definition at line 198 of file RegisterFile.cc.

198  {
199  if (name == this->name()) {
200  return;
201  }
202 
203  if (machine() != NULL) {
204  if (machine()->registerFileNavigator().hasItem(name)) {
205  string procName = "RegisterFile::setName";
206  throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
207  } else {
209  }
210  } else {
212  }
213 }

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

Referenced by ADFCombiner::addRegisterFiles(), MachineResourceModifier::increaseAllRFsThatDiffersByAmount(), and MachineResourceModifier::percentualRegisterIncrease().

Here is the call graph for this function:

◆ setNumberOfRegisters()

void TTAMachine::RegisterFile::setNumberOfRegisters ( int  registers)
virtual

Sets the number of registers in the register file.

If the number of registers decreases, deletes the register guards that were referencing to the registers that are removed.

Parameters
registersThe new amount of registers.
Exceptions
OutOfRangeIf the given number of registers is less or equal to zero.

Reimplemented from TTAMachine::BaseRegisterFile.

Reimplemented in TTAMachine::NullRegisterFile, and UnboundedRegisterFile.

Definition at line 320 of file RegisterFile.cc.

320  {
321  if (registers < numberOfRegisters()) {
322  deleteGuards(registers);
323  }
325 }

References deleteGuards(), TTAMachine::BaseRegisterFile::numberOfRegisters(), and TTAMachine::BaseRegisterFile::setNumberOfRegisters().

Referenced by RegisterQuantityCheck::fixIntRegs(), and TTAMachine::ImmediateUnit::ImmediateUnit().

Here is the call graph for this function:

◆ setType()

void TTAMachine::RegisterFile::setType ( RegisterFile::Type  type)
virtual

Sets the type of the register file.

Parameters
typeType of the register file.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 304 of file RegisterFile.cc.

304  {
305  type_ = type;
306 }

References type(), and type_.

Referenced by loadStateWithoutReferences().

Here is the call graph for this function:

◆ setZeroRegister()

void TTAMachine::RegisterFile::setZeroRegister ( const bool &  value)
virtual

Definition at line 634 of file RegisterFile.cc.

634  {
635  zeroRegister_ = value;
636 }

References zeroRegister_.

Referenced by loadStateWithoutReferences().

◆ type()

RegisterFile::Type TTAMachine::RegisterFile::type ( ) const
virtual

Returns the type of the register file.

Returns
Type of the register file.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 147 of file RegisterFile.cc.

147  {
148  return type_;
149 }

References type_.

Referenced by isArchitectureEqual(), loadStateWithoutReferences(), and setType().

◆ unsetMachine()

void TTAMachine::RegisterFile::unsetMachine ( )
virtual

Removes the register file from machine.

Reimplemented from TTAMachine::Unit.

Reimplemented in TTAMachine::ImmediateUnit, and TTAMachine::NullRegisterFile.

Definition at line 375 of file RegisterFile.cc.

375  {
376  Machine* mach = machine();
377  if (mach == NULL) {
378  return;
379  }
380  deleteGuards(0);
382  mach->removeRegisterFile(*this);
383 }

References deleteGuards(), TTAMachine::Component::machine(), TTAMachine::Machine::removeRegisterFile(), and TTAMachine::Unit::unsetMachine().

Referenced by ~RegisterFile().

Here is the call graph for this function:

◆ updateMaxReadsAndWrites()

bool TTAMachine::RegisterFile::updateMaxReadsAndWrites ( ) const
private

Updates RFs max reads/writes according in/output ports.

Port that is not assigned to a socket is considered to be a dead port, thus not counted towards the maximum number of reads or writes.

Returns
True if max reads/writes changed
Exceptions
OutOfRangeIf setMaxReads/setMaxWrites throws outOfRange exception.

Definition at line 266 of file RegisterFile.cc.

266  {
267  int reads = 0;
268  int writes = 0;
269  bool changed = false;
270 
271  for (int p = 0; p < portCount(); ++p) {
272  if (!port(p)->isOutput() && !port(p)->isInput()) {
273 
274  // do not count unconnected ports
275  //++reads;
276  //++writes;
277 
278  } else {
279  if (port(p)->isOutput()) {
280  changed = true;
281  ++reads;
282  }
283  if (port(p)->isInput()) {
284  changed = true;
285  ++writes;
286  }
287  }
288  }
289 
290  if (changed)
291  {
292  maxReads_ = reads;
293  maxWrites_ = writes;
294  }
295  return changed;
296 }

References TTAMachine::Port::isInput(), TTAMachine::Port::isOutput(), maxReads_, maxWrites_, TTAMachine::BaseRegisterFile::port(), and TTAMachine::Unit::portCount().

Referenced by maxReads(), and maxWrites().

Here is the call graph for this function:

◆ zeroRegister()

bool TTAMachine::RegisterFile::zeroRegister ( ) const
virtual

Member Data Documentation

◆ guardLatency_

int TTAMachine::RegisterFile::guardLatency_
private

The guard latency of the register file.

Definition at line 133 of file RegisterFile.hh.

Referenced by guardLatency(), isArchitectureEqual(), saveState(), and setGuardLatency().

◆ maxReads_

int TTAMachine::RegisterFile::maxReads_
mutableprivate

Max number of ports that can read a register all in the same cycle.

Definition at line 129 of file RegisterFile.hh.

Referenced by isArchitectureEqual(), maxReads(), saveState(), setMaxReads(), and updateMaxReadsAndWrites().

◆ maxWrites_

int TTAMachine::RegisterFile::maxWrites_
mutableprivate

Max number of ports that can read a register all in the same cycle.

Definition at line 131 of file RegisterFile.hh.

Referenced by isArchitectureEqual(), maxWrites(), saveState(), setMaxWrites(), and updateMaxReadsAndWrites().

◆ OSKEY_GUARD_LATENCY

const string TTAMachine::RegisterFile::OSKEY_GUARD_LATENCY = "g_latency"
static

ObjectState attribute key for the guard latency.

Definition at line 108 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSKEY_MAX_READS

const string TTAMachine::RegisterFile::OSKEY_MAX_READS = "max_r"
static

ObjectState attribute key for maximum simultaneous readers.

Definition at line 104 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSKEY_MAX_WRITES

const string TTAMachine::RegisterFile::OSKEY_MAX_WRITES = "max_w"
static

ObjectState attribute key for maximum simultaneous writers.

Definition at line 106 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSKEY_TYPE

const string TTAMachine::RegisterFile::OSKEY_TYPE = "type"
static

ObjectState attribute key for register file type.

Definition at line 96 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSKEY_ZERO_REGISTER

const string TTAMachine::RegisterFile::OSKEY_ZERO_REGISTER = "zero_register"
static

ObjectState attribute key for zero register flag.

Definition at line 110 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSNAME_REGISTER_FILE

const string TTAMachine::RegisterFile::OSNAME_REGISTER_FILE = "reg_file"
static

◆ OSVALUE_NORMAL

const string TTAMachine::RegisterFile::OSVALUE_NORMAL = "normal"
static

ObjectState attribute value for normal register file type.

Definition at line 98 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSVALUE_RESERVED

const string TTAMachine::RegisterFile::OSVALUE_RESERVED = "reserved"
static

ObjectState attribute value for reserved register file type.

Definition at line 100 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ OSVALUE_VOLATILE

const string TTAMachine::RegisterFile::OSVALUE_VOLATILE = "volatile"
static

ObjectState attribute value for volatile register file type.

Definition at line 102 of file RegisterFile.hh.

Referenced by loadStateWithoutReferences(), and saveState().

◆ type_

Type TTAMachine::RegisterFile::type_
private

Type of the register file.

Definition at line 136 of file RegisterFile.hh.

Referenced by isArchitectureEqual(), isNormal(), isReserved(), isVolatile(), saveState(), setType(), and type().

◆ zeroRegister_

bool TTAMachine::RegisterFile::zeroRegister_
private

Definition at line 138 of file RegisterFile.hh.

Referenced by saveState(), setZeroRegister(), and zeroRegister().


The documentation for this class was generated from the following files:
TTAMachine::RegisterFile::setMaxWrites
virtual void setMaxWrites(int maxWrites)
Definition: RegisterFile.cc:247
ObjectState::hasAttribute
bool hasAttribute(const std::string &name) const
Definition: ObjectState.cc:205
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
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
TTAMachine::Component::isRegistered
virtual bool isRegistered() const
Definition: MachinePart.cc:177
TTAMachine::RegisterFile::RESERVED
@ RESERVED
Used for custom, user controlled register allocation.
Definition: RegisterFile.hh:52
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::RegisterFile::OSKEY_GUARD_LATENCY
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the guard latency.
Definition: RegisterFile.hh:108
OutOfRange
Definition: Exception.hh:320
TTAMachine::RegisterFile::type_
Type type_
Type of the register file.
Definition: RegisterFile.hh:136
TTAMachine::RegisterFile::OSKEY_TYPE
static const std::string OSKEY_TYPE
ObjectState attribute key for register file type.
Definition: RegisterFile.hh:96
TTAMachine::BaseRegisterFile::loadState
virtual void loadState(const ObjectState *state)
Definition: BaseRegisterFile.cc:176
TTAMachine::RegisterFile::unsetMachine
virtual void unsetMachine()
Definition: RegisterFile.cc:375
ObjectState
Definition: ObjectState.hh:59
TTAMachine::RegisterFile::setType
virtual void setType(RegisterFile::Type type)
Definition: RegisterFile.cc:304
TTAMachine::BaseRegisterFile::BaseRegisterFile
BaseRegisterFile(const std::string &name, int size, int width)
Definition: BaseRegisterFile.cc:60
TTAMachine::RegisterFile::OSVALUE_RESERVED
static const std::string OSVALUE_RESERVED
ObjectState attribute value for reserved register file type.
Definition: RegisterFile.hh:100
ObjectState::setName
void setName(const std::string &name)
TTAMachine::RegisterFile::maxWrites
virtual int maxWrites() const
Definition: RegisterFile.cc:135
TTAMachine::RegisterFile::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: RegisterFile.cc:449
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
TTAMachine::Machine::BusNavigator
Navigator< Bus > BusNavigator
Navigator type for BusNavigator.
Definition: Machine.hh:213
TTAMachine::RegisterFile::updateMaxReadsAndWrites
bool updateMaxReadsAndWrites() const
Definition: RegisterFile.cc:266
TTAMachine::RegisterFile::saveState
virtual ObjectState * saveState() const
Definition: RegisterFile.cc:392
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::RegisterFile::setGuardLatency
virtual void setGuardLatency(int latency)
Definition: RegisterFile.cc:346
TTAMachine::RegisterFile::VOLATILE
@ VOLATILE
Used for user-controlled I/O communication.
Definition: RegisterFile.hh:53
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::RegisterFile::maxReads
virtual int maxReads() const
Definition: RegisterFile.cc:123
TTAMachine::RegisterFile::OSKEY_MAX_READS
static const std::string OSKEY_MAX_READS
ObjectState attribute key for maximum simultaneous readers.
Definition: RegisterFile.hh:104
TTAMachine::RegisterFile::setMaxReads
virtual void setMaxReads(int maxReads)
Definition: RegisterFile.cc:227
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::RegisterFile::OSKEY_ZERO_REGISTER
static const std::string OSKEY_ZERO_REGISTER
ObjectState attribute key for zero register flag.
Definition: RegisterFile.hh:110
TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT
static const std::string OSNAME_IMMEDIATE_UNIT
ObjectState name for ImmediateUnit.
Definition: ImmediateUnit.hh:75
TTAMachine::RegisterFile::OSNAME_REGISTER_FILE
static const std::string OSNAME_REGISTER_FILE
ObjectState name for RegisterFile.
Definition: RegisterFile.hh:94
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
TTAMachine::Port::isOutput
virtual bool isOutput() const
Definition: Port.cc:308
TTAMachine::RegisterFile::zeroRegister_
bool zeroRegister_
Definition: RegisterFile.hh:138
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::Unit::Port
friend class Port
Definition: Unit.hh:99
TTAMachine::BaseRegisterFile::setNumberOfRegisters
virtual void setNumberOfRegisters(int registers)
Definition: BaseRegisterFile.cc:96
TTAMachine::BaseRegisterFile::port
virtual RFPort * port(const std::string &name) const
Definition: BaseRegisterFile.cc:129
TTAMachine::BaseRegisterFile::saveState
virtual ObjectState * saveState() const
Definition: BaseRegisterFile.cc:159
TTAMachine::RegisterFile::deleteGuards
void deleteGuards(int registers) const
Definition: RegisterFile.cc:492
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
MOMTextGenerator
Definition: MOMTextGenerator.hh:40
TTAMachine::RegisterFile::setZeroRegister
virtual void setZeroRegister(const bool &value)
Definition: RegisterFile.cc:634
ObjectState::boolAttribute
bool boolAttribute(const std::string &name) const
Definition: ObjectState.cc:338
TTAMachine::RegisterFile::NORMAL
@ NORMAL
Used for general register allocation.
Definition: RegisterFile.hh:51
ComponentAlreadyExists
Definition: Exception.hh:510
TTAMachine::Port::isInput
virtual bool isInput() const
Definition: Port.cc:298
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
TTAMachine::RegisterFile::OSVALUE_NORMAL
static const std::string OSVALUE_NORMAL
ObjectState attribute value for normal register file type.
Definition: RegisterFile.hh:98
TTAMachine::RegisterFile::guardLatency
virtual int guardLatency() const
Definition: RegisterFile.cc:333
TTAMachine::RegisterFile::maxReads_
int maxReads_
Max number of ports that can read a register all in the same cycle.
Definition: RegisterFile.hh:129
TTAMachine::BaseRegisterFile::size
virtual int size() const
TTAMachine::RegisterFile::OSVALUE_VOLATILE
static const std::string OSVALUE_VOLATILE
ObjectState attribute value for volatile register file type.
Definition: RegisterFile.hh:102
TTAMachine::BaseRegisterFile::width
virtual int width() const
TTAMachine::RegisterFile::type
virtual RegisterFile::Type type() const
Definition: RegisterFile.cc:147
TTAMachine::Unit::unsetMachine
virtual void unsetMachine()
Definition: Unit.cc:262
TTAMachine::RegisterFile::OSKEY_MAX_WRITES
static const std::string OSKEY_MAX_WRITES
ObjectState attribute key for maximum simultaneous writers.
Definition: RegisterFile.hh:106
TTAMachine::RegisterFile::maxWrites_
int maxWrites_
Max number of ports that can read a register all in the same cycle.
Definition: RegisterFile.hh:131
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
TTAMachine::RegisterFile::zeroRegister
virtual bool zeroRegister() const
Definition: RegisterFile.cc:629
TTAMachine::RegisterFile::guardLatency_
int guardLatency_
The guard latency of the register file.
Definition: RegisterFile.hh:133