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

#include <Unit.hh>

Inheritance diagram for TTAMachine::Unit:
Inheritance graph
Collaboration diagram for TTAMachine::Unit:
Collaboration graph

Public Member Functions

virtual ~Unit ()
 
virtual bool hasPort (const std::string &name) const
 
virtual Portport (const std::string &name) const
 
virtual Portport (int index) 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)
 
virtual void unsetMachine ()
 
virtual ObjectStatesaveState () const
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::Component
virtual ~Component ()
 
virtual TCEString name () const
 
virtual void setName (const std::string &name)
 
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_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.
 

Protected Member Functions

 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 ()
 

Private Types

typedef std::vector< Port * > PortTable
 Container for ports.
 
typedef std::set< std::string > NameSet
 Set type for strings.
 

Private Member Functions

 Unit (const Unit &)
 Copying forbidden.
 
Unitoperator= (const Unit &)
 Assingment forbidden.
 
void addPort (Port &port)
 
void deleteAllPorts ()
 
void deleteOtherPorts (const NameSet &portsToLeave)
 
void loadStateWithoutReferences (const ObjectState *state)
 

Static Private Member Functions

static NameSet portNames (const ObjectState *state)
 

Private Attributes

PortTable ports_
 Contains all the ports of the unit.
 

Friends

class Port
 

Detailed Description

An Abstract base class for the different units in the machine.

Definition at line 51 of file Unit.hh.

Member Typedef Documentation

◆ NameSet

typedef std::set<std::string> TTAMachine::Unit::NameSet
private

Set type for strings.

Definition at line 82 of file Unit.hh.

◆ PortTable

typedef std::vector<Port*> TTAMachine::Unit::PortTable
private

Container for ports.

Definition at line 80 of file Unit.hh.

Constructor & Destructor Documentation

◆ ~Unit()

TTAMachine::Unit::~Unit ( )
virtual

Destructor.

Definition at line 84 of file Unit.cc.

84 {
86}
void deleteAllPorts()
Definition Unit.cc:373

References deleteAllPorts().

Here is the call graph for this function:

◆ Unit() [1/3]

TTAMachine::Unit::Unit ( const std::string &  name)
protected

Constructor.

Parameters
nameThe name of the unit.
Exceptions
InvalidNameIf the given name is not a valid component name.

Definition at line 59 of file Unit.cc.

59: Component(name) {}
Component(const std::string &name)
virtual TCEString name() const

◆ Unit() [2/3]

TTAMachine::Unit::Unit ( const ObjectState state)
protected

Constructor.

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

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

Definition at line 71 of file Unit.cc.

71 : Component(state) {
72 try {
74 } catch (const Exception&) {
75 // delete the ports that were loaded
77 throw;
78 }
79}
void loadStateWithoutReferences(const ObjectState *state)
Definition Unit.cc:334

References deleteAllPorts(), and loadStateWithoutReferences().

Here is the call graph for this function:

◆ Unit() [3/3]

TTAMachine::Unit::Unit ( const Unit )
private

Copying forbidden.

Member Function Documentation

◆ addPort()

void TTAMachine::Unit::addPort ( Port port)
private

Adds a port to the unit.

This method can be called from Port constructor only.

Parameters
portPort to be added.
Exceptions
ComponentAlreadyExistsIf another port with the same name exists.

Definition at line 213 of file Unit.cc.

213 {
214 // check that this method is called from Port constructor only
215 assert(port.parentUnit() == NULL);
216
217 // check that a port with same name does not exist
218 if (!hasPort(port.name())) {
219 ports_.push_back(&port);
220 return;
221 }
222
223 string procName = "Unit::addPort";
224 throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
225}
#define assert(condition)
Unit * parentUnit() const
virtual std::string name() const
Definition Port.cc:141
virtual bool hasPort(const std::string &name) const
Definition Unit.cc:96
PortTable ports_
Contains all the ports of the unit.
Definition Unit.hh:96
virtual Port * port(const std::string &name) const
Definition Unit.cc:116

References assert, hasPort(), TTAMachine::Port::name(), TTAMachine::Port::parentUnit(), port(), and ports_.

Referenced by TTAMachine::Port::Port(), and TTAMachine::Port::Port().

Here is the call graph for this function:

◆ bidirPortCount()

int TTAMachine::Unit::bidirPortCount ( ) const
virtual
Returns
The number of bidirectional ports in the unit.

Definition at line 174 of file Unit.cc.

174 {
175 unsigned count = 0;
176 for (auto &port : ports_) {
177 if (port->isInput() && port->isOutput())
178 count++;
179 }
180 return count;
181}
virtual bool isInput() const
Definition Port.cc:298
virtual bool isOutput() const
Definition Port.cc:308

References TTAMachine::Port::isInput(), TTAMachine::Port::isOutput(), port(), and ports_.

Referenced by ProGeTools::checkForSelectableRF(), and Automagic::checkForSelectableRF().

Here is the call graph for this function:

◆ deleteAllPorts()

void TTAMachine::Unit::deleteAllPorts ( )
private

Deletes all the ports from the unit.

Definition at line 373 of file Unit.cc.

373 {
374 while (ports_.size() > 0) {
375 // the size of the vector is decreased when the code of Port
376 // destructor is executed
377 delete ports_[0];
378 }
379}

References ports_.

Referenced by Unit(), and ~Unit().

◆ deleteOtherPorts()

void TTAMachine::Unit::deleteOtherPorts ( const NameSet portsToLeave)
private

Deletes all the ports which has a name that does not appear in the given name set.

Parameters
portsToLeaveA set of names of ports to leave.

Definition at line 389 of file Unit.cc.

389 {
390 for (int i = 0; i < portCount();) {
391 Port* port = this->port(i);
392 if (!AssocTools::containsKey(portsToLeave, port->name())) {
393 delete port;
394 } else {
395 i++;
396 }
397 }
398}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
virtual int portCount() const
Definition Unit.cc:135
friend class Port
Definition Unit.hh:99

References AssocTools::containsKey(), TTAMachine::Port::name(), port(), and portCount().

Referenced by loadStateWithoutReferences().

Here is the call graph for this function:

◆ hasPort()

bool TTAMachine::Unit::hasPort ( const std::string &  name) const
virtual

Returns true if the requested port is found, otherwise false.

Parameters
nameName of the port.
Returns
Tru if the port is found, otherwise false.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 96 of file Unit.cc.

96 {
97 PortTable::const_iterator iter = ports_.begin();
98 while (iter != ports_.end()) {
99 if ((*iter)->name() == name) {
100 return true;
101 }
102 iter++;
103 }
104 return false;
105}

References TTAMachine::Component::name(), and ports_.

Referenced by addPort(), TTAProgram::TPEFProgramFactory::findGuard(), TTAProgram::TPEFProgramFactory::findPort(), MachineResourceManager::functionUnitPortResource(), TTAMachine::FunctionUnit::hasOperationPort(), TTAMachine::ControlUnit::hasSpecialRegisterPort(), TTAProgram::TPEFResourceUpdater::initCache(), loadStateWithoutReferences(), GCUDialog::onAddFUPort(), FUDialog::onAddPort(), IUDialog::onAddPort(), RFDialog::onAddPort(), GCUDialog::onAddSRPort(), TTAMachine::FunctionUnit::port(), and TTAMachine::ControlUnit::specialRegisterPort().

Here is the call graph for this function:

◆ inputPortCount()

int TTAMachine::Unit::inputPortCount ( bool  countBidir = false) const
virtual
Parameters
countBidirTrue if we should count bidirectional ports
Returns
The number of input ports in the unit.

Definition at line 160 of file Unit.cc.

160 {
161 unsigned count = 0;
162 for (auto &port : ports_) {
163 if (port->isInput() && (!port->isOutput() || countBidir))
164 count++;
165 }
166 return count;
167}

References TTAMachine::Port::isInput(), TTAMachine::Port::isOutput(), port(), and ports_.

Referenced by ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), and ProGe::RV32MicroCodeGenerator::findRF().

Here is the call graph for this function:

◆ loadState()

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

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

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if references to sockets cannot be made.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::BaseRegisterFile, TTAMachine::ControlUnit, TTAMachine::FunctionUnit, TTAMachine::ImmediateUnit, TTAMachine::NullRegisterFile, TTAMachine::RegisterFile, UnboundedRegisterFile, and UniversalFunctionUnit.

Definition at line 309 of file Unit.cc.

309 {
311
312 // create port-socket connections
313 for (int i = 0; i < state->childCount(); i++) {
314 ObjectState* child = state->child(i);
315 if (child->name() == FUPort::OSNAME_FUPORT ||
316 child->name() == RFPort::OSNAME_RFPORT ||
318 string portName = child->stringAttribute(Port::OSKEY_NAME);
319 Port* port = this->port(portName);
320 port->loadState(child);
321 }
322 }
323}
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
std::string name() const
int childCount() const
static const std::string OSNAME_FUPORT
ObjectState name for FUPort.
Definition FUPort.hh:71
virtual void loadState(const ObjectState *state)
Definition Port.cc:459
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the port.
Definition Port.hh:82
static const std::string OSNAME_RFPORT
ObjectState name for register file port.
Definition RFPort.hh:58
static const std::string OSNAME_SPECIAL_REG_PORT
ObjectState name for special register port.

References ObjectState::child(), ObjectState::childCount(), TTAMachine::Port::loadState(), loadStateWithoutReferences(), ObjectState::name(), TTAMachine::Port::OSKEY_NAME, TTAMachine::FUPort::OSNAME_FUPORT, TTAMachine::RFPort::OSNAME_RFPORT, TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT, port(), and ObjectState::stringAttribute().

Referenced by TTAMachine::BaseRegisterFile::loadState(), and TTAMachine::FunctionUnit::loadState().

Here is the call graph for this function:

◆ loadStateWithoutReferences()

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

Loads its state from the given ObjectState instance without references to other components.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid.

Definition at line 334 of file Unit.cc.

334 {
335 const string procName = "Unit::loadStateWithoutReferences";
336
337 // load ports
338 try {
339 // cannot delete all the ports because there might be guards
340 // referencing to them
341 NameSet newPortNames = portNames(state);
342 deleteOtherPorts(newPortNames);
343
344 for (int i = 0; i < state->childCount(); i++) {
345 ObjectState* child = state->child(i);
346 string portName = child->stringAttribute(Port::OSKEY_NAME);
347
348 if (!hasPort(portName)) {
349 if (child->name() == RFPort::OSNAME_RFPORT) {
350 // port is attached automatically
351 new RFPort(child, *this);
352 } else if (child->name() == FUPort::OSNAME_FUPORT) {
353 // port is attached automatically
354 new FUPort(child, *this);
355 } else if (child->name() ==
357 // port is attached automatically
358 new SpecialRegisterPort(child, *this);
359 }
360 }
361 }
362
363 } catch (const Exception& exception) {
365 __FILE__, __LINE__, procName, exception.errorMessage());
366 }
367}
std::string errorMessage() const
Definition Exception.cc:123
std::set< std::string > NameSet
Set type for strings.
Definition Unit.hh:82
static NameSet portNames(const ObjectState *state)
Definition Unit.cc:409
void deleteOtherPorts(const NameSet &portsToLeave)
Definition Unit.cc:389

References ObjectState::child(), ObjectState::childCount(), deleteOtherPorts(), Exception::errorMessage(), hasPort(), ObjectState::name(), TTAMachine::Port::OSKEY_NAME, TTAMachine::FUPort::OSNAME_FUPORT, TTAMachine::RFPort::OSNAME_RFPORT, TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT, portNames(), and ObjectState::stringAttribute().

Referenced by loadState(), and Unit().

Here is the call graph for this function:

◆ operator=()

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

Assingment forbidden.

◆ outputPortCount()

int TTAMachine::Unit::outputPortCount ( bool  countBidir = false) const
virtual
Parameters
countBidirTrue if we should count bidirectional ports
Returns
The number of output ports in the unit.

Definition at line 145 of file Unit.cc.

145 {
146 unsigned count = 0;
147 for (auto &port : ports_) {
148 if (port->isOutput() && (!port->isInput() || countBidir))
149 count++;
150 }
151 return count;
152}

References TTAMachine::Port::isInput(), TTAMachine::Port::isOutput(), port(), and ports_.

Referenced by ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), ProGe::RV32MicroCodeGenerator::findRF(), and DefaultDecoderGenerator::verifyCompatibility().

Here is the call graph for this function:

◆ port() [1/2]

Port * TTAMachine::Unit::port ( const std::string &  name) const
virtual

◆ port() [2/2]

Port * TTAMachine::Unit::port ( int  index) const
virtual

Returns a port by the given index.

The index must be greater or equal to 0 and smaller than the number of ports in the unit.

Parameters
indexIndex.
Returns
The port by the given index.
Exceptions
OutOfRangeIf the given index is out of range.

Reimplemented in TTAMachine::BaseRegisterFile, and TTAMachine::FunctionUnit.

Definition at line 195 of file Unit.cc.

195 {
196 if (index < 0 || index >= portCount()) {
197 string procName = "Unit::port";
198 throw OutOfRange(__FILE__, __LINE__, procName);
199 }
200 return ports_[index];
201}

References portCount(), and ports_.

Here is the call graph for this function:

◆ portCount()

int TTAMachine::Unit::portCount ( ) const
virtual

Returns the number of ports in the unit.

Returns
The number of ports in the unit.

Reimplemented in TTAMachine::NullRegisterFile.

Definition at line 135 of file Unit.cc.

135 {
136 return ports_.size();
137}

References ports_.

Referenced by ProGe::NetlistGenerator::addBaseRFToNetlist(), RegisterCopyAdder::addConnectionRegisterCopies(), RegisterCopyAdder::addConnectionRegisterCopies(), RegisterCopyAdder::addConnectionRegisterCopiesImmediate(), ProGe::NetlistGenerator::addGCUToNetlist(), ProGe::NetlistGenerator::addGeneratableFUsToNetlist(), DefaultDecoderGenerator::addGlockPortToDecoder(), DefaultDecoderGenerator::addLockReqPortToDecoder(), MachineStateBuilder::addVirtualOpcodeSettingPortsToFU(), InputPSocketBroker::allAvailableResources(), OutputPSocketBroker::allAvailableResources(), TDGen::analyzeMachineRegisters(), TDGen::analyzeRegisters(), MachineConnectivityCheck::appendConnectedDestinationBuses(), MachineConnectivityCheck::appendConnectedSourceBuses(), CostDatabase::buildFunctionUnits(), MachineStateBuilder::buildMachineState(), MachineConnectivityCheck::busConnectedToRF(), MachineTester::canConnect(), FullyConnectedCheck::check(), FullyConnectedCheck::check(), RFPortCheck::check(), SimulatorFrontend::compareState(), DefaultDecoderGenerator::completeDecoderBlock(), ADFCombiner::connectPorts(), ProGe::RV32MicroCodeGenerator::connectRF(), ADFCombiner::copyGuards(), RegisterCopyAdder::countAndAddConnectionRegisterCopiesToRR(), FUFactory::createEditPart(), IUFactory::createEditPart(), RFFactory::createEditPart(), FUGen::createMandatoryPorts(), FUGen::createOutputPipeline(), FUGen::createPortPipeline(), ADFCombiner::createPortsAndSockets(), FUGen::createShadowRegisters(), llvm::LLVMTCEBuilder::createTerminalRegister(), TTAProgram::CodeGenerator::createTerminalRegister(), deleteOtherPorts(), ProximFUDetailsCmd::Do(), AddFUImplementationCmd::Do(), llvm::LLVMTCEBuilder::emitMove(), llvm::LLVMTCEBuilder::emitSPInitialization(), UniversalFunctionUnit::ensureInputPorts(), InfoPortsCommand::execute(), ProgrammabilityValidator::findConnections(), MachineConnectivityCheck::findPossibleSourcePorts(), MachineConnectivityCheck::findReadPorts(), BasicBlockScheduler::findTriggerFromUnit(), ProgramOperation::findTriggerFromUnit(), MachineConnectivityCheck::findWritePorts(), TTAMachine::RegisterFile::firstReadPort(), TTAMachine::RegisterFile::firstWritePort(), FullyConnectedCheck::fix(), MachineConnectivityCheck::fromRfConnected(), HDBToHtml::fuArchToHtml(), CompiledSimCodeGenerator::fuOutputPorts(), TTAMachine::FUPort::FUPort(), DefaultDecoderGenerator::glockPortWidth(), DefaultDecoderGenerator::glockRequestWidth(), MachineConnectivityCheck::immBits(), OutputPSocketBroker::isAnyResourceAvailable(), TTAMachine::RegisterFile::isArchitectureEqual(), ExecutionPipelineResource::isAvailable(), MachineConnectivityCheck::isConnected(), MachineConnectivityCheck::isConnected(), DefaultICGenerator::isGcuPort(), ComponentImplementationSelector::iuImplementations(), TTAMachine::FUPort::loadStateWithoutReferences(), MachineAnalysis::MachineAnalysis(), AddFUFromHDBDialog::onAdd(), AddWatchDialog::onFUChoice(), FUGuardDialog::onFUChoice(), BlockImplementationDialog::onHDBSelection(), FUArchitectureDialog::onOK(), FUPortDialog::onOK(), IUPortDialog::onOK(), RFPortDialog::onOK(), SRPortDialog::onOK(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), port(), UniversalFunctionUnit::portWithWidth(), MachineResourceManager::registerFileIndexReference(), HDB::RFArchitecture::RFArchitecture(), HDB::RFArchitecture::RFArchitecture(), HDB::RFArchitecture::RFArchitecture(), ComponentImplementationSelector::rfImplementations(), MachineResourceManager::rFPortOrFUIndexReference(), saveState(), TTAMachine::Port::setName(), TTAMachine::FUPort::setTriggering(), ExecutionPipelineBroker::setupResourceLinks(), InputFUBroker::setupResourceLinks(), IUBroker::setupResourceLinks(), OutputFUBroker::setupResourceLinks(), TTAMachine::ControlUnit::specialRegisterPort(), TTAMachine::ControlUnit::specialRegisterPortCount(), MachineConnectivityCheck::toRfConnected(), TTAMachine::FunctionUnit::triggerPort(), unsetMachine(), ProximPortWindow::update(), FUArchitectureDialog::update(), TTAMachine::RegisterFile::updateMaxReadsAndWrites(), FUDialog::updatePortList(), GCUDialog::updatePortList(), IUDialog::updatePortList(), RFDialog::updatePortList(), DefaultDecoderGenerator::writeControlRegisterMappings(), DefaultDecoderGenerator::writeFUCntrlSignals(), DefaultDecoderGenerator::writeRFCntrlSignals(), DefaultDecoderGenerator::writeRFSRAMDecodingProcess(), DefaultDecoderGenerator::writeRulesForDestinationControlSignals(), and DefaultDecoderGenerator::writeRulesForSourceControlSignals().

◆ portNames()

Unit::NameSet TTAMachine::Unit::portNames ( const ObjectState state)
staticprivate

Creates a set of port names that exists in the given ObjectState tree.

Parameters
stateAn ObjectState instance representing an unit.
Returns
Set of port names.
Exceptions
KeyNotFoundIf the given ObjectState instance is invalid.

Definition at line 409 of file Unit.cc.

409 {
410 NameSet names;
411 for (int i = 0; i < state->childCount(); i++) {
412 ObjectState* child = state->child(i);
413 names.insert(child->stringAttribute(Port::OSKEY_NAME));
414 }
415
416 return names;
417}

References ObjectState::child(), ObjectState::childCount(), TTAMachine::Port::OSKEY_NAME, and ObjectState::stringAttribute().

Referenced by loadStateWithoutReferences().

Here is the call graph for this function:

◆ removePort()

void TTAMachine::Unit::removePort ( Port port)
protectedvirtual

Removes the given port.

This method should only be called by Port destructor.

Parameters
portPort to be removed.

Reimplemented in TTAMachine::ControlUnit.

Definition at line 235 of file Unit.cc.

235 {
236
237 // sanity check to verify that this is called from Port's destructor
238 // only
239 assert(port.parentUnit() == NULL);
241 assert(removed);
242}
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)

References assert, TTAMachine::Port::parentUnit(), port(), ports_, and ContainerTools::removeValueIfExists().

Referenced by TTAMachine::ControlUnit::removePort(), and TTAMachine::Port::~Port().

Here is the call graph for this function:

◆ saveState()

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

Saves the state of the object to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from TTAMachine::Component.

Reimplemented in TTAMachine::BaseRegisterFile, TTAMachine::ControlUnit, TTAMachine::FunctionUnit, TTAMachine::ImmediateUnit, TTAMachine::NullRegisterFile, and TTAMachine::RegisterFile.

Definition at line 285 of file Unit.cc.

285 {
286
288 state->setName(OSNAME_UNIT);
289
290 // add ports
291 for (int i = 0; i < portCount(); i++) {
292 Port* port = this->port(i);
293 state->addChild(port->saveState());
294 }
295
296 return state;
297}
void setName(const std::string &name)
void addChild(ObjectState *child)
virtual ObjectState * saveState() const
virtual ObjectState * saveState() const
Definition Port.cc:404
static const std::string OSNAME_UNIT
ObjectState name for Unit.
Definition Unit.hh:70

References ObjectState::addChild(), OSNAME_UNIT, port(), portCount(), TTAMachine::Component::saveState(), TTAMachine::Port::saveState(), and ObjectState::setName().

Referenced by TTAMachine::BaseRegisterFile::saveState(), and TTAMachine::FunctionUnit::saveState().

Here is the call graph for this function:

◆ setMachine()

void TTAMachine::Unit::setMachine ( Machine mach)
virtual

Registers the unit to a machine.

Parameters
machMachine to which the unit is to be registered.
Exceptions
ComponentAlreadyExistsIf there is another unit by the same name and type in the machine.

Implements TTAMachine::Component.

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

Definition at line 253 of file Unit.cc.

253 {
254 internalSetMachine(mach);
255 mach.addUnit(*this);
256}
void internalSetMachine(Machine &machine)

References TTAMachine::Machine::addUnit(), and TTAMachine::Component::internalSetMachine().

Referenced by AddFUCmd::Do(), AddIUCmd::Do(), and AddRFCmd::Do().

Here is the call graph for this function:

◆ unsetMachine()

void TTAMachine::Unit::unsetMachine ( )
virtual

Removes registration of the unit from its current machine.

Implements TTAMachine::Component.

Reimplemented in TTAMachine::ControlUnit, TTAMachine::FunctionUnit, TTAMachine::ImmediateUnit, TTAMachine::NullRegisterFile, and TTAMachine::RegisterFile.

Definition at line 262 of file Unit.cc.

262 {
263
264 if (machine() == NULL) {
265 return;
266 }
267
269
270 // detach all ports from sockets
271 int ports = portCount();
272 for (int i = 0; i < ports; i++) {
273 Port* unitPort = port(i);
274 unitPort->detachAllSockets();
275 }
276}
virtual Machine * machine() const

References TTAMachine::Port::detachAllSockets(), TTAMachine::Component::internalUnsetMachine(), TTAMachine::Component::machine(), port(), and portCount().

Referenced by TTAMachine::FunctionUnit::unsetMachineDerived().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ Port

friend class Port
friend

Definition at line 99 of file Unit.hh.

Member Data Documentation

◆ OSNAME_UNIT

const string TTAMachine::Unit::OSNAME_UNIT = "unit"
static

ObjectState name for Unit.

Definition at line 70 of file Unit.hh.

Referenced by saveState().

◆ ports_

PortTable TTAMachine::Unit::ports_
private

Contains all the ports of the unit.

Definition at line 96 of file Unit.hh.

Referenced by addPort(), bidirPortCount(), deleteAllPorts(), hasPort(), inputPortCount(), outputPortCount(), port(), port(), portCount(), and removePort().


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