OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 

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.
 

Private Attributes

OperationContextPimplpimpl_
 Implementation in separate source file to speed up compiling.
 

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.

49}
#define DEFAULT_FU_NAME
OperationContextPimpl * pimpl_
Implementation in separate source file to speed up compiling.

◆ 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}
SimValue & returnAddress()
InstructionAddress & programCounter()

◆ 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}
void advanceClock(OperationContext &)

References OperationContextPimpl::advanceClock(), and pimpl_.

Referenced by FUState::advanceClock(), GCUState::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}
const TCEString & functionUnitName()

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]

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

Definition at line 256 of file OperationContext.cc.

256 {
257 return pimpl_->memory();
258}

References OperationContextPimpl::memory(), and pimpl_.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ programCounter() [1/2]

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}
InstructionAddress & programCounter()

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

Definition at line 157 of file OperationContext.cc.

157 {
158 return pimpl_->programCounter();
159}

References pimpl_, and OperationContextPimpl::programCounter().

Here is the call graph for this function:

◆ 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}
void registerState(OperationState *state)

References pimpl_, and OperationContextPimpl::registerState().

Here is the call graph for this function:

◆ returnAddress() [1/2]

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

Definition at line 212 of file OperationContext.cc.

212 {
213 return pimpl_->returnAddress();
214}

References pimpl_, and OperationContextPimpl::returnAddress().

Here is the call graph for this function:

◆ 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}
void setCycleCountVariable(CycleCount &cycleCount)
CycleCount cycleCount() const

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}
void setMemory(Memory *memory)

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

Referenced by main(), MemoryAccessingFUState::MemoryAccessingFUState(), 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}
void setSaveReturnAddress(bool value)

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}
void setStateRegistry(StateRegistry &stateRegistry)
StateRegistry & stateRegistry()

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}
void setUpdateProgramCounter(bool value)

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}
OperationState & state(const char *name) const

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}
StateRegistry & stateRegistry()

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}
void unregisterState(const char *name)

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.

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 {
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: