OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MachineState Class Reference

#include <MachineState.hh>

Collaboration diagram for MachineState:
Collaboration graph

Public Member Functions

 MachineState ()
 
virtual ~MachineState ()
 
void clear ()
 
GCUStategcuState ()
 
BusStatebusState (const std::string &name)
 
FUStatefuState (const std::string &name)
 
int FUStateCount () const
 
FUStatefuState (int index)
 
void advanceClockOfAllFUStates ()
 
void endClockOfAllFUStates ()
 
void advanceClockOfAllGuardStates ()
 
void advanceClockOfAllLongImmediateUnitStates ()
 
void resetAllFUs ()
 
void clearBuses ()
 
PortStateportState (const std::string &portName, const std::string &fuName)
 
LongImmediateUnitStatelongImmediateUnitState (const std::string &name)
 
RegisterFileStateregisterFileState (const std::string &name)
 
GuardStateguardState (const TTAMachine::Guard &guard)
 
void addGCUState (GCUState *state)
 
void addBusState (BusState *state, const std::string &name)
 
void addFUState (FUState *state, const std::string &name)
 
void addPortState (PortState *state, const std::string &name, const std::string &fuName)
 
void addLongImmediateUnitState (LongImmediateUnitState *state, const std::string &name)
 
void addRegisterFileState (RegisterFileState *state, const std::string &name)
 
void addGuardState (GuardState *state, const TTAMachine::Guard &guard)
 
void addOperationExecutor (OperationExecutor *executor)
 
bool isFinished () const
 
void setFinished (bool finished=true)
 

Private Types

typedef std::map< std::string, BusState * > BusContainer
 Contains bus states indexed by names. More...
 
typedef std::map< std::string, FUState * > FUContainer
 Contains function unit states indexed by names. More...
 
typedef std::map< std::string, PortState * > PortContainer
 Contains port states indexed by names. More...
 
typedef std::map< std::string, LongImmediateUnitState * > LongImmediateContainer
 Contains long immediate unit states indexed by names. More...
 
typedef std::map< std::string, RegisterFileState * > RegisterFileContainer
 Contains register file states indexed by names. More...
 
typedef std::map< const TTAMachine::Guard *, GuardState * > GuardContainer
 Contains guard states indexed by their MOM object. More...
 
typedef std::vector< OperationExecutor * > ExecutorContainer
 Contains operation executors. More...
 
typedef std::vector< BusState * > BusCache
 
typedef std::vector< FUState * > FUCache
 
typedef std::vector< PortState * > PortCache
 
typedef std::vector< LongImmediateUnitState * > LongImmediateUnitCache
 
typedef std::vector< RegisterFileState * > RegisterFileCache
 
typedef std::vector< GuardState * > GuardCache
 

Private Member Functions

 MachineState (const MachineState &)
 Copying not allowed. More...
 
MachineStateoperator= (const MachineState &)
 Assignment not allowed. More...
 

Private Attributes

GCUStateGCUState_
 GCU state. More...
 
BusContainer busses_
 Contains all bus states. More...
 
FUContainer FUStates_
 Container of function unit states for fast traversal. More...
 
PortContainer ports_
 Contains all port states. More...
 
LongImmediateContainer longImmediates_
 Contains all long immediate unit states. More...
 
RegisterFileContainer registers_
 Contains all register file states. More...
 
ExecutorContainer executors_
 Contains all operation executors. More...
 
GuardContainer guards_
 Contains all guard states. More...
 
std::size_t fuStateCount_
 Count of FUStates added in MachineState (optimization). More...
 
BusCache busCache_
 
FUCache fuCache_
 
PortCache portCache_
 
LongImmediateUnitCache longImmediateCache_
 
RegisterFileCache rfCache_
 
GuardCache guardCache_
 
bool finished_
 

Detailed Description

Root class of machine state model.

Owns all state classes.

Definition at line 61 of file MachineState.hh.

Member Typedef Documentation

◆ BusCache

typedef std::vector<BusState*> MachineState::BusCache
private

Definition at line 131 of file MachineState.hh.

◆ BusContainer

typedef std::map<std::string, BusState*> MachineState::BusContainer
private

Contains bus states indexed by names.

Definition at line 115 of file MachineState.hh.

◆ ExecutorContainer

typedef std::vector<OperationExecutor*> MachineState::ExecutorContainer
private

Contains operation executors.

Definition at line 128 of file MachineState.hh.

◆ FUCache

typedef std::vector<FUState*> MachineState::FUCache
private

Definition at line 132 of file MachineState.hh.

◆ FUContainer

typedef std::map<std::string, FUState*> MachineState::FUContainer
private

Contains function unit states indexed by names.

Definition at line 117 of file MachineState.hh.

◆ GuardCache

typedef std::vector<GuardState*> MachineState::GuardCache
private

Definition at line 136 of file MachineState.hh.

◆ GuardContainer

typedef std::map<const TTAMachine::Guard*, GuardState*> MachineState::GuardContainer
private

Contains guard states indexed by their MOM object.

Definition at line 126 of file MachineState.hh.

◆ LongImmediateContainer

typedef std::map<std::string, LongImmediateUnitState*> MachineState::LongImmediateContainer
private

Contains long immediate unit states indexed by names.

Definition at line 122 of file MachineState.hh.

◆ LongImmediateUnitCache

Definition at line 134 of file MachineState.hh.

◆ PortCache

typedef std::vector<PortState*> MachineState::PortCache
private

Definition at line 133 of file MachineState.hh.

◆ PortContainer

typedef std::map<std::string, PortState*> MachineState::PortContainer
private

Contains port states indexed by names.

Definition at line 119 of file MachineState.hh.

◆ RegisterFileCache

typedef std::vector<RegisterFileState*> MachineState::RegisterFileCache
private

Definition at line 135 of file MachineState.hh.

◆ RegisterFileContainer

typedef std::map<std::string, RegisterFileState*> MachineState::RegisterFileContainer
private

Contains register file states indexed by names.

Definition at line 124 of file MachineState.hh.

Constructor & Destructor Documentation

◆ MachineState() [1/2]

MachineState::MachineState ( )

Constructor.

Definition at line 61 of file MachineState.cc.

61  :
62  GCUState_(NULL), fuStateCount_(0), finished_(false) {
63 }

◆ ~MachineState()

MachineState::~MachineState ( )
virtual

Destructor.

Definition at line 68 of file MachineState.cc.

68  {
69  clear();
70 }

References clear().

Here is the call graph for this function:

◆ MachineState() [2/2]

MachineState::MachineState ( const MachineState )
private

Copying not allowed.

Member Function Documentation

◆ addBusState()

void MachineState::addBusState ( BusState state,
const std::string &  name 
)

Adds BusState to machine state.

Parameters
stateBusState to be added.
nameThe name of the BusState.

Definition at line 255 of file MachineState.cc.

255  {
256  busses_[name] = state;
257  busCache_.push_back(state);
258 }

References busCache_, and busses_.

Referenced by MachineStateBuilder::buildMachineState().

◆ addFUState()

void MachineState::addFUState ( FUState state,
const std::string &  name 
)

Adds FUState.

Parameters
stateFUState to be added.
nameThe name of the FU in ADF.

Definition at line 267 of file MachineState.cc.

267  {
268  FUStates_[name] = state;
269  fuCache_.push_back(state);
270 }

References fuCache_, and FUStates_.

Referenced by MachineStateBuilder::buildMachineState().

◆ addGCUState()

void MachineState::addGCUState ( GCUState state)

Adds GCUState to machine state.

Parameters
stateGCUState to be added.

Definition at line 244 of file MachineState.cc.

244  {
245  GCUState_ = state;
246 }

References GCUState_.

Referenced by MachineStateBuilder::buildMachineState().

◆ addGuardState()

void MachineState::addGuardState ( GuardState state,
const TTAMachine::Guard guard 
)

Adds GuardState.

Parameters
stateState to be added.
guardThe machine object model guard the state represents.

Definition at line 325 of file MachineState.cc.

327  {
328 
329  guards_[&guard] = state;
330  guardCache_.push_back(state);
331 }

References guardCache_, and guards_.

Referenced by MachineStateBuilder::buildMachineState().

◆ addLongImmediateUnitState()

void MachineState::addLongImmediateUnitState ( LongImmediateUnitState state,
const std::string &  name 
)

Adds LongImmediateUnitState.

Parameters
stateLongImmediateUnitState to be added.
nameThe name of the state.

Definition at line 295 of file MachineState.cc.

297  {
298 
299  longImmediates_[name] = state;
300  longImmediateCache_.push_back(state);
301 }

References longImmediateCache_, and longImmediates_.

Referenced by MachineStateBuilder::buildMachineState().

◆ addOperationExecutor()

void MachineState::addOperationExecutor ( OperationExecutor executor)

Adds operation executor.

Parameters
executorOperation executor.

Definition at line 339 of file MachineState.cc.

339  {
340  executors_.push_back(executor);
341 }

References executors_.

Referenced by MachineStateBuilder::addVirtualOpcodeSettingPortsToFU().

◆ addPortState()

void MachineState::addPortState ( PortState state,
const std::string &  name,
const std::string &  fuName 
)

Adds PortState.

Parameters
statePortState to be added.
nameName of the port in ADF.
fuNameName of the FU of the port in ADF.

Definition at line 280 of file MachineState.cc.

283  {
284  ports_[fuName + "." + StringTools::stringToLower(name)] = state;
285  portCache_.push_back(state);
286 }

References portCache_, ports_, and StringTools::stringToLower().

Referenced by MachineStateBuilder::addPortToFU(), and MachineStateBuilder::addVirtualOpcodeSettingPortsToFU().

Here is the call graph for this function:

◆ addRegisterFileState()

void MachineState::addRegisterFileState ( RegisterFileState state,
const std::string &  name 
)

Adds RegisterFileState.

Parameters
stateState to be added.
nameName of the state.

Definition at line 310 of file MachineState.cc.

312  {
313 
314  registers_[name] = state;
315  rfCache_.push_back(state);
316 }

References registers_, and rfCache_.

Referenced by MachineStateBuilder::buildMachineState().

◆ advanceClockOfAllFUStates()

void MachineState::advanceClockOfAllFUStates ( )

◆ advanceClockOfAllGuardStates()

void MachineState::advanceClockOfAllGuardStates ( )

◆ advanceClockOfAllLongImmediateUnitStates()

void MachineState::advanceClockOfAllLongImmediateUnitStates ( )

◆ busState()

BusState & MachineState::busState ( const std::string &  name)

Returns bus state with a given name.

If bus state with a given name is not found, return NullBusState.

Parameters
nameName of the bus state.
Returns
Bus state with a given name.

Definition at line 116 of file MachineState.cc.

116  {
117  BusContainer::iterator iter = busses_.find(name);
118  if (iter == busses_.end()) {
119  return NullBusState::instance();
120  }
121  return *((*iter).second);
122 }

References busses_, and NullBusState::instance().

Referenced by ProximBusDetailsCmd::Do(), InfoSegmentsCommand::execute(), BusTracker::handleEvent(), and SimProgramBuilder::processMove().

Here is the call graph for this function:

◆ clear()

void MachineState::clear ( )

Reserved memory is freed, containers are emptied.

Definition at line 76 of file MachineState.cc.

76  {
77  delete GCUState_;
78  GCUState_ = NULL;
79 
80  // Clear all caches
81  busCache_.clear();
82  fuCache_.clear();
83  portCache_.clear();
84  longImmediateCache_.clear();
85  rfCache_.clear();
86  guardCache_.clear();
87 
95 }

References busCache_, busses_, SequenceTools::deleteAllItems(), MapTools::deleteAllValues(), executors_, fuCache_, FUStates_, GCUState_, guardCache_, guards_, longImmediateCache_, longImmediates_, portCache_, ports_, registers_, and rfCache_.

Referenced by ~MachineState().

Here is the call graph for this function:

◆ clearBuses()

void MachineState::clearBuses ( )

◆ endClockOfAllFUStates()

void MachineState::endClockOfAllFUStates ( )

◆ fuState() [1/2]

FUState & MachineState::fuState ( const std::string &  name)

Returns the FUState with a given name.

If FUState is not found, returns NullFUState.

Parameters
nameName of the FUState.
Returns
FUState with a given name.

Definition at line 133 of file MachineState.cc.

133  {
134  FUContainer::iterator iter = FUStates_.find(name);
135  if (iter == FUStates_.end()) {
136  return NullFUState::instance();
137  }
138  return *((*iter).second);
139 }

References FUStates_, and NullFUState::instance().

Referenced by FUTestbenchGenerator::createStimulus(), SimpleSimulatorFrontend::setOperationSimulator(), and SimulationController::SimulationController().

Here is the call graph for this function:

◆ fuState() [2/2]

FUState & MachineState::fuState ( int  index)

Returns the FUState with a given index.

Parameters
indexThe index of the FUState.
Returns
The FUState with a given index.
Exceptions
OutOfRangeIf index is out of range.

Definition at line 149 of file MachineState.cc.

149  {
150  const int count = FUStateCount();
151  if (index < 0 || (index > count - 1)) {
152  string msg = "FUState index out of range";
153  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
154  }
155 
156  int i = 0;
157  FUContainer::iterator iter = FUStates_.begin();
158  while (i < index) {
159  iter++;
160  ++i;
161  }
162  return *((*iter).second);
163 }

References __func__, FUStateCount(), and FUStates_.

Here is the call graph for this function:

◆ FUStateCount()

int MachineState::FUStateCount ( ) const

◆ gcuState()

GCUState & MachineState::gcuState ( )

Returns the GCUState of the machine state.

Returns
GCUState.

Definition at line 103 of file MachineState.cc.

103  {
104  return *GCUState_;
105 }

References GCUState_.

Referenced by OTASimulationController::advanceMachineCycle(), OTASimulationController::simulateCycle(), and SimulationController::simulateCycle().

◆ guardState()

GuardState & MachineState::guardState ( const TTAMachine::Guard guard)

Returns the GuardState associated with the given MOM Guard.

If not found, returns NullGuardState::instace().

Parameters
nameThe MOM Guard instance.
Returns
GuardState associated with the instance.

Definition at line 230 of file MachineState.cc.

230  {
231  GuardContainer::iterator iter = guards_.find(&guard);
232  if (iter == guards_.end()) {
233  return NullGuardState::instance();
234  }
235  return *((*iter).second);
236 }

References guards_, and NullGuardState::instance().

Referenced by SimProgramBuilder::findGuardModel().

Here is the call graph for this function:

◆ isFinished()

bool MachineState::isFinished ( ) const
inline

Definition at line 105 of file MachineState.hh.

105 { return finished_; }

References finished_.

Referenced by SimulationController::simulateCycle().

◆ longImmediateUnitState()

LongImmediateUnitState & MachineState::longImmediateUnitState ( const std::string &  name)

Returns LongImmediateUnitState with a given name.

If LongImmediateUnitState is not found, returns NullLongImmediateUnistState.

Parameters
nameThe name of the LongImmediateUnitState.
Returns
LongImmediateUnitState with a given name.

Definition at line 196 of file MachineState.cc.

196  {
197  LongImmediateContainer::iterator iter = longImmediates_.find(name);
198  if (iter == longImmediates_.end()) {
200  }
201  return *((*iter).second);
202 }

References NullLongImmediateUnitState::instance(), and longImmediates_.

Referenced by ProximIUDetailsCmd::Do(), ProximRegisterWindow::loadImmediateUnit(), SimProgramBuilder::processInstruction(), and SimProgramBuilder::processSourceTerminal().

Here is the call graph for this function:

◆ operator=()

MachineState& MachineState::operator= ( const MachineState )
private

Assignment not allowed.

◆ portState()

PortState & MachineState::portState ( const std::string &  portName,
const std::string &  fuName 
)

Returns PortState with a given name.

If PortState is not found, return NullPortState.

Parameters
portNameThe name of the PortState.
fuNameThe name of the parent FU of the port.
Returns
PortState with a given name.

Definition at line 175 of file MachineState.cc.

177  {
178 
179  PortContainer::iterator i =
180  ports_.find(fuName + "." + StringTools::stringToLower(portName));
181  if (i == ports_.end())
182  return NullPortState::instance();
183  else
184  return *(*i).second;
185 }

References NullPortState::instance(), ports_, and StringTools::stringToLower().

Referenced by MachineStateBuilder::addVirtualOpcodeSettingPortsToFU(), MachineStateBuilder::bindPortsToOperands(), MachineStateBuilder::buildMachineState(), ProximFUPortDetailsCmd::Do(), ProximFUDetailsCmd::Do(), SimulatorFrontend::findPort(), FUTestbenchGenerator::parseFuPorts(), SimProgramBuilder::processBidirTerminal(), FUTestbenchGenerator::readValuesFromOutPorts(), ProximPortWindow::update(), and FUTestbenchGenerator::writeInputPortStimulus().

Here is the call graph for this function:

◆ registerFileState()

RegisterFileState & MachineState::registerFileState ( const std::string &  name)

Returns RegisterFileState with a given name.

If RegisterFileState is not found, return NullRegisterFileState.

Parameters
nameThe name of the state.
Returns
RegisterFileState with a given name.

Definition at line 213 of file MachineState.cc.

213  {
214  RegisterFileContainer::iterator iter = registers_.find(name);
215  if (iter == registers_.end()) {
217  }
218  return *((*iter).second);
219 }

References NullRegisterFileState::instance(), and registers_.

Referenced by MachineStateBuilder::buildMachineState(), RFTestbenchGenerator::createStimulus(), ProximRFDetailsCmd::Do(), SimulatorFrontend::findBooleanRegister(), SimulatorFrontend::findRegister(), ProximRegisterWindow::loadRegisterFile(), and SimProgramBuilder::processBidirTerminal().

Here is the call graph for this function:

◆ resetAllFUs()

void MachineState::resetAllFUs ( )

◆ setFinished()

void MachineState::setFinished ( bool  finished = true)
inline

Definition at line 106 of file MachineState.hh.

106 { finished_ = finished; }

References finished_.

Referenced by OTASimulationController::simulateCycle(), and SimulationController::simulateCycle().

Member Data Documentation

◆ busCache_

BusCache MachineState::busCache_
private

Definition at line 158 of file MachineState.hh.

Referenced by addBusState(), and clear().

◆ busses_

BusContainer MachineState::busses_
private

Contains all bus states.

Definition at line 141 of file MachineState.hh.

Referenced by addBusState(), busState(), and clear().

◆ executors_

ExecutorContainer MachineState::executors_
private

Contains all operation executors.

Definition at line 151 of file MachineState.hh.

Referenced by addOperationExecutor(), and clear().

◆ finished_

bool MachineState::finished_
private

Definition at line 167 of file MachineState.hh.

Referenced by isFinished(), and setFinished().

◆ fuCache_

FUCache MachineState::fuCache_
private

Definition at line 159 of file MachineState.hh.

Referenced by addFUState(), and clear().

◆ fuStateCount_

std::size_t MachineState::fuStateCount_
private

Count of FUStates added in MachineState (optimization).

Definition at line 155 of file MachineState.hh.

◆ FUStates_

FUContainer MachineState::FUStates_
private

Container of function unit states for fast traversal.

Definition at line 143 of file MachineState.hh.

Referenced by addFUState(), clear(), and fuState().

◆ GCUState_

GCUState* MachineState::GCUState_
private

GCU state.

Definition at line 139 of file MachineState.hh.

Referenced by addGCUState(), clear(), and gcuState().

◆ guardCache_

GuardCache MachineState::guardCache_
private

Definition at line 163 of file MachineState.hh.

Referenced by addGuardState(), and clear().

◆ guards_

GuardContainer MachineState::guards_
private

Contains all guard states.

Definition at line 153 of file MachineState.hh.

Referenced by addGuardState(), clear(), and guardState().

◆ longImmediateCache_

LongImmediateUnitCache MachineState::longImmediateCache_
private

Definition at line 161 of file MachineState.hh.

Referenced by addLongImmediateUnitState(), and clear().

◆ longImmediates_

LongImmediateContainer MachineState::longImmediates_
private

Contains all long immediate unit states.

Definition at line 147 of file MachineState.hh.

Referenced by addLongImmediateUnitState(), clear(), and longImmediateUnitState().

◆ portCache_

PortCache MachineState::portCache_
private

Definition at line 160 of file MachineState.hh.

Referenced by addPortState(), and clear().

◆ ports_

PortContainer MachineState::ports_
private

Contains all port states.

Definition at line 145 of file MachineState.hh.

Referenced by addPortState(), clear(), and portState().

◆ registers_

RegisterFileContainer MachineState::registers_
private

Contains all register file states.

Definition at line 149 of file MachineState.hh.

Referenced by addRegisterFileState(), clear(), and registerFileState().

◆ rfCache_

RegisterFileCache MachineState::rfCache_
private

Definition at line 162 of file MachineState.hh.

Referenced by addRegisterFileState(), and clear().


The documentation for this class was generated from the following files:
NullLongImmediateUnitState::instance
static NullLongImmediateUnitState & instance()
Definition: LongImmediateUnitState.cc:191
OutOfRange
Definition: Exception.hh:320
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
NullPortState::instance
static NullPortState & instance()
Definition: PortState.cc:96
MachineState::rfCache_
RegisterFileCache rfCache_
Definition: MachineState.hh:162
MachineState::portCache_
PortCache portCache_
Definition: MachineState.hh:160
MachineState::FUStateCount
int FUStateCount() const
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
MachineState::clear
void clear()
Definition: MachineState.cc:76
NullGuardState::instance
static NullGuardState & instance()
Definition: GuardState.cc:118
NullFUState::instance
static NullFUState & instance()
Definition: FUState.cc:392
MachineState::FUStates_
FUContainer FUStates_
Container of function unit states for fast traversal.
Definition: MachineState.hh:143
__func__
#define __func__
Definition: Application.hh:67
MachineState::longImmediateCache_
LongImmediateUnitCache longImmediateCache_
Definition: MachineState.hh:161
NullRegisterFileState::instance
static NullRegisterFileState & instance()
Definition: RegisterFileState.cc:111
NullBusState::instance
static NullBusState & instance()
Definition: BusState.cc:112
MachineState::GCUState_
GCUState * GCUState_
GCU state.
Definition: MachineState.hh:139
MachineState::longImmediates_
LongImmediateContainer longImmediates_
Contains all long immediate unit states.
Definition: MachineState.hh:147
MachineState::executors_
ExecutorContainer executors_
Contains all operation executors.
Definition: MachineState.hh:151
MachineState::finished_
bool finished_
Definition: MachineState.hh:167
MachineState::ports_
PortContainer ports_
Contains all port states.
Definition: MachineState.hh:145
MachineState::fuStateCount_
std::size_t fuStateCount_
Count of FUStates added in MachineState (optimization).
Definition: MachineState.hh:155
MachineState::registers_
RegisterFileContainer registers_
Contains all register file states.
Definition: MachineState.hh:149
MachineState::busCache_
BusCache busCache_
Definition: MachineState.hh:158
MachineState::fuCache_
FUCache fuCache_
Definition: MachineState.hh:159
MachineState::busses_
BusContainer busses_
Contains all bus states.
Definition: MachineState.hh:141
MachineState::guards_
GuardContainer guards_
Contains all guard states.
Definition: MachineState.hh:153
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
MachineState::guardCache_
GuardCache guardCache_
Definition: MachineState.hh:163