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

#include <OperationContext.hh>

Collaboration diagram for OperationContext:
Collaboration graph

Public Types

typedef std::map< std::string, OperationState * > StateRegistry
 Type of state registry. More...
 

Public Member Functions

 OperationContext ()
 
 OperationContext (const TCEString &name)
 
 OperationContext (Memory *memory, InstructionAddress &programCounter, SimValue &returnAddress, int delayCycles)
 
 OperationContext (const OperationContext &)
 
OperationStatestate (const char *name) const
 
void setStateRegistry (StateRegistry &stateRegistry)
 
void unsetStateRegistry ()
 
StateRegistrystateRegistry ()
 
virtual ~OperationContext ()
 
Memorymemory ()
 
const Memorymemory () const
 
void setMemory (Memory *memory)
 
int contextId () const
 
InstructionAddressprogramCounter ()
 
const InstructionAddressprogramCounter () const
 
void setUpdateProgramCounter (bool value)
 
bool updateProgramCounter () const
 
void setSaveReturnAddress (bool value)
 
bool saveReturnAddress ()
 
SimValuereturnAddress ()
 
const SimValuereturnAddress () const
 
void advanceClock ()
 
bool isEmpty () const
 
bool hasMemoryModel () const
 
const TCEStringfunctionUnitName () const
 
int branchDelayCycles () const
 
void registerState (OperationState *state)
 
void unregisterState (const char *name)
 
CycleCount cycleCount () const
 
void setCycleCountVariable (CycleCount &cycleCount)
 

Private Member Functions

OperationContextoperator= (const OperationContext &)
 Assignment not allowed. More...
 

Private Attributes

OperationContextPimplpimpl_
 Implementation in separate source file to speed up compiling. More...
 

Detailed Description

OperationContext is used to store any implementation and context dependent data that may affect the result of an operation.

In typical client applications, operation implementations are related to a function unit.

Definition at line 56 of file OperationContext.hh.

Member Typedef Documentation

◆ StateRegistry

typedef std::map<std::string, OperationState*> OperationContext::StateRegistry

Type of state registry.

Definition at line 72 of file OperationContext.hh.

Constructor & Destructor Documentation

◆ OperationContext() [1/4]

OperationContext::OperationContext ( )

Constructor for contexts suitable for basic operations.

Definition at line 48 of file OperationContext.cc.

◆ OperationContext() [2/4]

OperationContext::OperationContext ( const TCEString name)

Constructor for basic operations in simulation – FU name passed.

Definition at line 54 of file OperationContext.cc.

54  : pimpl_(new OperationContextPimpl(name)) {
55 }

◆ OperationContext() [3/4]

OperationContext::OperationContext ( Memory memory,
InstructionAddress programCounter,
SimValue returnAddress,
int  delayCycles 
)

Constructor for contexts suitable for any kinds of operations.

Parameters
memoryThe memory model instance.
programCounterThe program counter register.
returnAddressThe return address register.

Definition at line 65 of file OperationContext.cc.

69  :
72  returnAddress, delayCycles)) {
73 }

◆ OperationContext() [4/4]

OperationContext::OperationContext ( const OperationContext context)

A copy constructor that performs a deep copy for the pimpl_

Parameters
contextOperationContext

Definition at line 80 of file OperationContext.cc.

80  :
81  pimpl_(new OperationContextPimpl(*context.pimpl_)) {
82 }

◆ ~OperationContext()

OperationContext::~OperationContext ( )
virtual

Destructor. Deletes the pimpl object

Definition at line 87 of file OperationContext.cc.

87  {
88  delete pimpl_;
89  pimpl_ = NULL;
90 }

References pimpl_.

Member Function Documentation

◆ advanceClock()

void OperationContext::advanceClock ( )

Advances the internal clock of each registered operation state object.

Definition at line 108 of file OperationContext.cc.

108  {
109  pimpl_->advanceClock(*this);
110 }

References OperationContextPimpl::advanceClock(), and pimpl_.

Referenced by GCUState::advanceClock(), FUState::advanceClock(), and SimulateDialog::onAdvanceClock().

Here is the call graph for this function:

◆ branchDelayCycles()

int OperationContext::branchDelayCycles ( ) const

Returns the amount of pipeline delay cycles.

Definition at line 308 of file OperationContext.cc.

308  {
309  return pimpl_->branchDelayCycles();
310 }

References OperationContextPimpl::branchDelayCycles(), and pimpl_.

Referenced by OperationDAGBehavior::areValid().

Here is the call graph for this function:

◆ contextId()

int OperationContext::contextId ( ) const

Returns the unique id of the OperationContext instance.

Returns
The unique id for the OperationContext instance.

Definition at line 266 of file OperationContext.cc.

266  {
267  return pimpl_->contextId();
268 }

References OperationContextPimpl::contextId(), and pimpl_.

Here is the call graph for this function:

◆ cycleCount()

CycleCount OperationContext::cycleCount ( ) const

Returns the elapsed time since the beginning of simulation.

Can be used to implement real time timer operations, etc. Uses the simulator's cycle count, if available, otherwise uses internal cycle counter that is incremented with the advanceClock();

Definition at line 288 of file OperationContext.cc.

288  {
289  return pimpl_->cycleCount();
290 }

References OperationContextPimpl::cycleCount(), and pimpl_.

Referenced by setCycleCountVariable().

Here is the call graph for this function:

◆ functionUnitName()

const TCEString & OperationContext::functionUnitName ( ) const

Returns the FU name of the OperationContext instance.

Returns
The FU name for the OperationContext instance.

Definition at line 276 of file OperationContext.cc.

276  {
277  return pimpl_->functionUnitName();
278 }

References OperationContextPimpl::functionUnitName(), and pimpl_.

Here is the call graph for this function:

◆ hasMemoryModel()

bool OperationContext::hasMemoryModel ( ) const

◆ isEmpty()

bool OperationContext::isEmpty ( ) const

Returns true if there are no operation state objects stored in the context.

Returns
True if there are no operation state objects stored in the context.

Definition at line 224 of file OperationContext.cc.

224  {
225  return pimpl_->isEmpty();
226 }

References OperationContextPimpl::isEmpty(), and pimpl_.

Referenced by FUState::advanceClock().

Here is the call graph for this function:

◆ memory() [1/2]

const Memory & OperationContext::memory ( )

Returns a reference to a Memory Module wrapper instance.

This instance can be accessed by the function unit and behavior simulation methods to simulate memory access.

Returns
The Memory instance.

Definition at line 251 of file OperationContext.cc.

251  {
252  return pimpl_->memory();
253 }

References OperationContextPimpl::memory(), and pimpl_.

Referenced by setMemory().

Here is the call graph for this function:

◆ memory() [2/2]

const Memory& OperationContext::memory ( ) const

◆ operator=()

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

Assignment not allowed.

◆ programCounter() [1/2]

const InstructionAddress & OperationContext::programCounter ( )

Returns a reference to the current value of the program counter register.

The value of the program counter can be changed through this reference. This is used to implement control transfer operations like jumps and calls to subroutines.

Returns
The program counter value as a reference.

Definition at line 152 of file OperationContext.cc.

152  {
153  return pimpl_->programCounter();
154 }

References pimpl_, and OperationContextPimpl::programCounter().

Referenced by OperationDAGBehavior::areValid(), CmdTrigger::execute(), SimulationInfoDialog::handleEvent(), TesterContext::programCounter(), TransportPipeline::startOperation(), and SimulationInfoDialog::updateList().

Here is the call graph for this function:

◆ programCounter() [2/2]

const InstructionAddress& OperationContext::programCounter ( ) const

◆ registerState()

void OperationContext::registerState ( OperationState stateToRegister)

Registers the operation state for given name.

Called in the createState() of the custom OperationBehavior classes. If state with given identifier is already found in the context, program is aborted. This method is only for internal use. Used by the macro definitions of OSAL.hh.

Parameters
nameThe identifier for the registered state instance.
stateToRegisterThe state instance.

Definition at line 124 of file OperationContext.cc.

124  {
125  pimpl_->registerState(stateToRegister);
126 }

References pimpl_, and OperationContextPimpl::registerState().

Here is the call graph for this function:

◆ returnAddress() [1/2]

const SimValue & OperationContext::returnAddress ( )

Returns a reference to the current value of the return address register.

The value of the return address can be changed through this reference. This is used in implementing calls to subroutines.

Returns
The return address value as a reference.

Definition at line 207 of file OperationContext.cc.

207  {
208  return pimpl_->returnAddress();
209 }

References pimpl_, and OperationContextPimpl::returnAddress().

Referenced by OperationDAGBehavior::areValid(), CmdTrigger::execute(), SimulationInfoDialog::handleEvent(), TesterContext::returnAddress(), TransportPipeline::startOperation(), and SimulationInfoDialog::updateList().

Here is the call graph for this function:

◆ returnAddress() [2/2]

const SimValue& OperationContext::returnAddress ( ) const

◆ saveReturnAddress()

bool OperationContext::saveReturnAddress ( )

Returns true if RA should saved before executing next control flow operation.

Returns
The return address value as a reference.

Definition at line 194 of file OperationContext.cc.

194  {
195  return pimpl_->saveReturnAddress();
196 }

References pimpl_, and OperationContextPimpl::saveReturnAddress().

Referenced by CmdTrigger::execute(), and TransportPipeline::startOperation().

Here is the call graph for this function:

◆ setCycleCountVariable()

void OperationContext::setCycleCountVariable ( CycleCount cycleCount)

Sets the variable that contains the current simulation cycle count at the best possible accuracy.

Used by real time operations to track simulation time during simulations.

Definition at line 300 of file OperationContext.cc.

300  {
302 }

References cycleCount(), pimpl_, and OperationContextPimpl::setCycleCountVariable().

Referenced by SimulationController::SimulationController().

Here is the call graph for this function:

◆ setMemory()

void OperationContext::setMemory ( Memory memory)

Sets the reference to a Memory Module instance.

This instance can be accessed by the function unit and behavior simulation methods to simulate memory access.

Parameters
memoryThe Memory instance.

Definition at line 238 of file OperationContext.cc.

238  {
240 }

References memory(), pimpl_, and OperationContextPimpl::setMemory().

Referenced by main(), and MemoryAccessingFUState::MemoryAccessingFUState().

Here is the call graph for this function:

◆ setSaveReturnAddress()

void OperationContext::setSaveReturnAddress ( bool  value)

Makes the return address to be saved in the RA register.

This is used by CALL instruction to save the RA before jumping.

Parameters
valueValue to set to.
Returns
The return address value as a reference.

Definition at line 183 of file OperationContext.cc.

183  {
185 }

References pimpl_, and OperationContextPimpl::setSaveReturnAddress().

Referenced by TransportPipeline::startOperation().

Here is the call graph for this function:

◆ setStateRegistry()

void OperationContext::setStateRegistry ( StateRegistry stateRegistry)

Definition at line 313 of file OperationContext.cc.

313  {
315 }

References pimpl_, OperationContextPimpl::setStateRegistry(), and stateRegistry().

Referenced by TransportPipeline::TransportPipeline().

Here is the call graph for this function:

◆ setUpdateProgramCounter()

void OperationContext::setUpdateProgramCounter ( bool  value)

Definition at line 162 of file OperationContext.cc.

162  {
164 }

References pimpl_, and OperationContextPimpl::setUpdateProgramCounter().

Referenced by TransportPipeline::startOperation().

Here is the call graph for this function:

◆ state()

OperationState & OperationContext::state ( const char *  name) const

Looks up the (concrete) operation state identified by the string name.

Parameters
nameThe state identifier.
Returns
The found operation state instance.
Exceptions
KeyNotFoundIf state by name couldn't be found.

Definition at line 100 of file OperationContext.cc.

100  {
101  return pimpl_->state(name);
102 }

References pimpl_, and OperationContextPimpl::state().

Here is the call graph for this function:

◆ stateRegistry()

OperationContext::StateRegistry & OperationContext::stateRegistry ( )

Definition at line 323 of file OperationContext.cc.

323  {
324  return pimpl_->stateRegistry();
325 }

References pimpl_, and OperationContextPimpl::stateRegistry().

Referenced by setStateRegistry(), and TransportPipeline::TransportPipeline().

Here is the call graph for this function:

◆ unregisterState()

void OperationContext::unregisterState ( const char *  name)

Unregisters the operation state of given name.

This method is only for internal use. Used by the macro definitions of OSAL.hh.

Called in deleteState() of the custom OperationBehavior classes. Aborts if there's no state with given identifier in the context.

Definition at line 138 of file OperationContext.cc.

138  {
139  pimpl_->unregisterState(name);
140 }

References pimpl_, and OperationContextPimpl::unregisterState().

Here is the call graph for this function:

◆ unsetStateRegistry()

void OperationContext::unsetStateRegistry ( )

Definition at line 318 of file OperationContext.cc.

318  {
320 }

References pimpl_, and OperationContextPimpl::unsetStateRegistry().

Referenced by TransportPipeline::~TransportPipeline().

Here is the call graph for this function:

◆ updateProgramCounter()

bool OperationContext::updateProgramCounter ( ) const

Definition at line 169 of file OperationContext.cc.

169  {
170  return pimpl_->updateProgramCounter();
171 }

References pimpl_, and OperationContextPimpl::updateProgramCounter().

Referenced by TransportPipeline::startOperation().

Here is the call graph for this function:

Member Data Documentation

◆ pimpl_

OperationContextPimpl* OperationContext::pimpl_
private

The documentation for this class was generated from the following files:
OperationContextPimpl::unregisterState
void unregisterState(const char *name)
Definition: OperationContextPimpl.cc:197
OperationContextPimpl::registerState
void registerState(OperationState *state)
Definition: OperationContextPimpl.cc:178
OperationContext::pimpl_
OperationContextPimpl * pimpl_
Implementation in separate source file to speed up compiling.
Definition: OperationContext.hh:113
OperationContext::cycleCount
CycleCount cycleCount() const
Definition: OperationContext.cc:288
OperationContextPimpl::stateRegistry
StateRegistry & stateRegistry()
Definition: OperationContextPimpl.hh:59
OperationContext::memory
Memory & memory()
Definition: OperationContext.cc:251
OperationContextPimpl::setUpdateProgramCounter
void setUpdateProgramCounter(bool value)
Definition: OperationContextPimpl.cc:269
DEFAULT_FU_NAME
#define DEFAULT_FU_NAME
Definition: OperationContext.hh:47
OperationContextPimpl::advanceClock
void advanceClock(OperationContext &)
Definition: OperationContextPimpl.cc:155
OperationContextPimpl::state
OperationState & state(const char *name) const
Definition: OperationContextPimpl.cc:139
OperationContextPimpl::setMemory
void setMemory(Memory *memory)
Definition: OperationContextPimpl.cc:227
OperationContextPimpl::branchDelayCycles
int branchDelayCycles()
Definition: OperationContextPimpl.cc:360
OperationContext::stateRegistry
StateRegistry & stateRegistry()
Definition: OperationContext.cc:323
OperationContextPimpl::returnAddress
SimValue & returnAddress()
Definition: OperationContextPimpl.cc:290
OperationContextPimpl::setStateRegistry
void setStateRegistry(StateRegistry &stateRegistry)
Definition: OperationContextPimpl.hh:56
OperationContextPimpl::memory
Memory & memory()
Definition: OperationContextPimpl.cc:214
OperationContextPimpl::programCounter
InstructionAddress & programCounter()
Definition: OperationContextPimpl.cc:261
OperationContextPimpl::contextId
int contextId() const
Definition: OperationContextPimpl.cc:237
OperationContextPimpl::setCycleCountVariable
void setCycleCountVariable(CycleCount &cycleCount)
Definition: OperationContextPimpl.hh:74
OperationContextPimpl::cycleCount
CycleCount cycleCount() const
Definition: OperationContextPimpl.cc:348
OperationContext::programCounter
InstructionAddress & programCounter()
Definition: OperationContext.cc:152
OperationContextPimpl::updateProgramCounter
bool updateProgramCounter() const
Definition: OperationContextPimpl.cc:277
OperationContextPimpl::saveReturnAddress
bool saveReturnAddress()
Definition: OperationContextPimpl.cc:314
OperationContextPimpl::setSaveReturnAddress
void setSaveReturnAddress(bool value)
Definition: OperationContextPimpl.cc:303
OperationContextPimpl::unsetStateRegistry
void unsetStateRegistry()
Definition: OperationContextPimpl.hh:58
OperationContextPimpl
Definition: OperationContextPimpl.hh:47
OperationContextPimpl::functionUnitName
const TCEString & functionUnitName()
Definition: OperationContextPimpl.cc:247
OperationContext::returnAddress
SimValue & returnAddress()
Definition: OperationContext.cc:207
OperationContextPimpl::isEmpty
bool isEmpty() const
Definition: OperationContextPimpl.cc:326