OpenASIP
2.0
|
#include <OperationContextPimpl.hh>
Public Types | |
typedef std::map< std::string, OperationState * > | StateRegistry |
Type of state registry. More... | |
Public Member Functions | |
~OperationContextPimpl () | |
void | setStateRegistry (StateRegistry &stateRegistry) |
void | unsetStateRegistry () |
StateRegistry & | stateRegistry () |
Private Member Functions | |
OperationContextPimpl (const TCEString &name) | |
OperationContextPimpl (const TCEString &name, Memory *memory, InstructionAddress &programCounter, SimValue &returnAddress, int delayCycles) | |
Memory & | memory () |
void | setMemory (Memory *memory) |
int | contextId () const |
CycleCount | cycleCount () const |
void | setCycleCountVariable (CycleCount &cycleCount) |
InstructionAddress & | programCounter () |
InstructionAddress & | irfBlockStart () |
void | setUpdateProgramCounter (bool value) |
bool | updateProgramCounter () const |
void | setSaveReturnAddress (bool value) |
bool | saveReturnAddress () |
SimValue & | returnAddress () |
void | advanceClock (OperationContext &) |
bool | isEmpty () const |
bool | hasMemoryModel () const |
const TCEString & | functionUnitName () |
int | branchDelayCycles () |
void | registerState (OperationState *state) |
void | unregisterState (const char *name) |
OperationState & | state (const char *name) const |
bool | hasState (const char *name) const |
void | initializeContextId () |
Private Attributes | |
Memory * | memory_ |
The Memory model instance. More... | |
int | contextId_ |
Unique number that identifies a context instance. More... | |
InstructionAddress & | programCounter_ |
Simulates the program counter value. More... | |
SimValue & | returnAddress_ |
Simulates the procedure return address. More... | |
StateRegistry * | stateRegistry_ |
The state registry. More... | |
bool | saveReturnAddress_ |
Should the return address be saved? More... | |
bool | updateProgramCounter_ |
Should program counter be updated? More... | |
CycleCount | cycleCount_ |
Number of times advanceClock() has been called since the creation. More... | |
CycleCount * | cycleCountVar_ |
The external variable that contains the current simulation cycle count. More... | |
const TCEString | FUName_ |
Name of the FU instance – passed down from MachineStateBuilder. More... | |
int | branchDelayCycles_ |
Amount of delay cycles caused by pipeline. More... | |
Static Private Attributes | |
static int | nextContextId_ = 0 |
Context id for the next created context instance. More... | |
Friends | |
class | OperationContext |
Definition at line 47 of file OperationContextPimpl.hh.
typedef std::map<std::string, OperationState*> OperationContextPimpl::StateRegistry |
Type of state registry.
Definition at line 54 of file OperationContextPimpl.hh.
OperationContextPimpl::~OperationContextPimpl | ( | ) |
Default destructor
Definition at line 101 of file OperationContextPimpl.cc.
References stateRegistry_.
|
private |
Constructor for contexts suitable for basic operations.
Definition at line 54 of file OperationContextPimpl.cc.
References initializeContextId(), and stateRegistry_.
|
private |
Constructor for contexts suitable for any kinds of operations.
memory | The memory model instance. |
nww | The natural word width of the memory model. |
programCounter | The program counter register. |
returnAddress | The return address register. |
syscallHandler | The syscall handler register. |
syscallNumber | The syscall code register. |
Definition at line 79 of file OperationContextPimpl.cc.
References initializeContextId(), and stateRegistry_.
|
private |
Advances the internal clock of each registered operation state object.
Definition at line 155 of file OperationContextPimpl.cc.
References cycleCount_, and stateRegistry_.
Referenced by OperationContext::advanceClock().
|
private |
Returns the amount of pipeline delay cycles.
Definition at line 360 of file OperationContextPimpl.cc.
References branchDelayCycles_.
Referenced by OperationContext::branchDelayCycles().
|
private |
Returns the unique id of the OperationContext instance.
Definition at line 237 of file OperationContextPimpl.cc.
References contextId_.
Referenced by OperationContext::contextId().
|
private |
Returns the count of cycles simulated.
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 348 of file OperationContextPimpl.cc.
References cycleCount_, and cycleCountVar_.
Referenced by OperationContext::cycleCount(), and setCycleCountVariable().
|
private |
Returns the FU name of the OperationContext instance.
Definition at line 247 of file OperationContextPimpl.cc.
References FUName_.
Referenced by OperationContext::functionUnitName().
|
private |
Returns true if the context has memory model associated with it.
Definition at line 336 of file OperationContextPimpl.cc.
References memory_.
|
private |
Checks if state with given name can be found in the context.
name | Name of the state. |
Definition at line 113 of file OperationContextPimpl.cc.
References state().
Referenced by registerState(), and unregisterState().
|
private |
Generates an unique context id for the current OperationContext instance.
Definition at line 126 of file OperationContextPimpl.cc.
References contextId_, and nextContextId_.
Referenced by OperationContextPimpl().
|
private |
|
private |
Returns true if there are no operation state objects stored in the context.
Definition at line 326 of file OperationContextPimpl.cc.
References stateRegistry_.
Referenced by OperationContext::isEmpty().
|
private |
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.
Definition at line 214 of file OperationContextPimpl.cc.
References memory_.
Referenced by OperationContext::memory(), and setMemory().
|
private |
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.
Definition at line 261 of file OperationContextPimpl.cc.
References programCounter_.
Referenced by OperationContext::programCounter().
|
private |
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.
name | The identifier for the registered state instance. |
stateToRegister | The state instance. |
Definition at line 178 of file OperationContextPimpl.cc.
References assert, hasState(), and OperationState::name().
Referenced by OperationContext::registerState().
|
private |
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.
Definition at line 290 of file OperationContextPimpl.cc.
References returnAddress_.
Referenced by OperationContext::returnAddress().
|
private |
Returns true if RA should saved before executing next control flow operation.
Definition at line 314 of file OperationContextPimpl.cc.
References saveReturnAddress_.
Referenced by OperationContext::saveReturnAddress().
|
inlineprivate |
Definition at line 74 of file OperationContextPimpl.hh.
References cycleCount(), and cycleCountVar_.
Referenced by OperationContext::setCycleCountVariable().
|
private |
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.
memory | The Memory instance. |
Definition at line 227 of file OperationContextPimpl.cc.
References memory(), and memory_.
Referenced by OperationContext::setMemory().
|
private |
Makes the return address to be saved in the RA register.
This is used by CALL instruction to save the RA before jumping.
value | Value to set to. |
Definition at line 303 of file OperationContextPimpl.cc.
References saveReturnAddress_.
Referenced by OperationContext::setSaveReturnAddress().
|
inline |
Definition at line 56 of file OperationContextPimpl.hh.
References stateRegistry(), and stateRegistry_.
Referenced by OperationContext::setStateRegistry().
|
private |
TODO
Definition at line 269 of file OperationContextPimpl.cc.
References updateProgramCounter_.
Referenced by OperationContext::setUpdateProgramCounter().
|
private |
Looks up the (concrete) operation state identified by the string name.
name | The state identifier. |
KeyNotFound | If state by name couldn't be found. |
Definition at line 139 of file OperationContextPimpl.cc.
References __func__, and stateRegistry_.
Referenced by hasState(), and OperationContext::state().
|
inline |
Definition at line 59 of file OperationContextPimpl.hh.
References stateRegistry_.
Referenced by setStateRegistry(), and OperationContext::stateRegistry().
|
private |
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 197 of file OperationContextPimpl.cc.
References assert, hasState(), and stateRegistry_.
Referenced by OperationContext::unregisterState().
|
inline |
Definition at line 58 of file OperationContextPimpl.hh.
References stateRegistry_.
Referenced by OperationContext::unsetStateRegistry().
|
private |
TODO
Definition at line 277 of file OperationContextPimpl.cc.
References updateProgramCounter_.
Referenced by OperationContext::updateProgramCounter().
|
friend |
Definition at line 49 of file OperationContextPimpl.hh.
|
private |
Amount of delay cycles caused by pipeline.
Definition at line 127 of file OperationContextPimpl.hh.
Referenced by branchDelayCycles().
|
private |
Unique number that identifies a context instance.
Definition at line 105 of file OperationContextPimpl.hh.
Referenced by contextId(), and initializeContextId().
|
private |
Number of times advanceClock() has been called since the creation.
Definition at line 120 of file OperationContextPimpl.hh.
Referenced by advanceClock(), and cycleCount().
|
private |
The external variable that contains the current simulation cycle count.
Definition at line 123 of file OperationContextPimpl.hh.
Referenced by cycleCount(), and setCycleCountVariable().
|
private |
Name of the FU instance – passed down from MachineStateBuilder.
Definition at line 125 of file OperationContextPimpl.hh.
Referenced by functionUnitName().
|
private |
The Memory model instance.
Definition at line 103 of file OperationContextPimpl.hh.
Referenced by hasMemoryModel(), memory(), and setMemory().
|
staticprivate |
Context id for the next created context instance.
Id given for the next created OperationContext instance.
Definition at line 107 of file OperationContextPimpl.hh.
Referenced by initializeContextId().
|
private |
Simulates the program counter value.
Definition at line 109 of file OperationContextPimpl.hh.
Referenced by programCounter().
|
private |
Simulates the procedure return address.
Definition at line 111 of file OperationContextPimpl.hh.
Referenced by returnAddress().
|
private |
Should the return address be saved?
Definition at line 115 of file OperationContextPimpl.hh.
Referenced by saveReturnAddress(), and setSaveReturnAddress().
|
private |
The state registry.
Definition at line 113 of file OperationContextPimpl.hh.
Referenced by advanceClock(), isEmpty(), OperationContextPimpl(), setStateRegistry(), state(), stateRegistry(), unregisterState(), unsetStateRegistry(), and ~OperationContextPimpl().
|
private |
Should program counter be updated?
Definition at line 117 of file OperationContextPimpl.hh.
Referenced by setUpdateProgramCounter(), and updateProgramCounter().