OpenASIP
2.0
|
#include <CompiledSimulation.hh>
Public Member Functions | |
CompiledSimulation (const TTAMachine::Machine &machine, InstructionAddress entryAddress, InstructionAddress lastInstruction, SimulatorFrontend &frontend, CompiledSimController &controller, MemorySystem &memorySystem, bool dynamicCompilation, ProcedureBBRelations &procedureBBRelations) | |
virtual | ~CompiledSimulation () |
virtual void | simulateCycle ()=0 |
virtual void | cycleEnd () |
virtual void | step (double count) |
virtual void | next (int count) |
virtual void | run () |
virtual void | runUntil (UIntWord address) |
virtual InstructionAddress | programCounter () const |
virtual InstructionAddress | lastExecutedInstruction () const |
virtual ClockCycleCount | cycleCount () const |
virtual SimValue | registerFileValue (const char *rfName, int registerIndex) |
virtual SimValue | immediateUnitRegisterValue (const char *iuName, int index) |
virtual SimValue | FUPortValue (const char *fuName, const char *portName) |
virtual void | requestToStop () |
virtual bool | stopRequested () const |
virtual bool | isFinished () const |
virtual ClockCycleCount | moveExecutionCount (int moveNumber, InstructionAddress address) const |
virtual InstructionAddress | basicBlockStart (InstructionAddress address) const |
Static Public Member Functions | |
static void | clearFUResults (FUResultType &results) |
static void | addFUResult (FUResultType &results, ClockCycleCount cycleCount, const SimValue &value, int latency) |
static void | addFUResult (FUResultType &results, ClockCycleCount cycleCount, const UIntWord &value, int latency) |
static void | FUResult (SimValue &target, FUResultType &results, ClockCycleCount cycles) |
Public Attributes | |
ClockCycleCount | cycleCount_ |
Number of cycles simulated so far. More... | |
int | basicBlockCount_ |
Number of basic blocks gone through. More... | |
InstructionAddress | jumpTarget_ |
The jump target. Allows jumping to different addresses in the code. More... | |
InstructionAddress | programCounter_ |
The program counter. i.e. which address the simulation is currently at. More... | |
InstructionAddress | lastExecutedInstruction_ |
Last executed instruction. More... | |
ClockCycleCount | cyclesToSimulate_ |
Number of cycles left to simulate until the execution returns. More... | |
bool | stopRequested_ |
Should the simulation stop or not? More... | |
bool | isFinished_ |
Is the simulation finished? More... | |
OperationPool | operationPool_ |
The operation pool. More... | |
SimulateFunction | jumpTargetFunc_ |
Next jump target as a function pointer" << endl. More... | |
bool | conflictDetected_ |
A flag for FU conflict detection. More... | |
ClockCycleCount * | moveExecCounts_ |
Move execution counts in a C style table. More... | |
ClockCycleCount * | bbExecCounts_ |
Basic block execution counts in a C style table. More... | |
Protected Member Functions | |
TTAMachine::FunctionUnit & | functionUnit (const char *name) const |
DirectAccessMemory & | FUMemory (const char *FUName) const |
MemorySystem * | memorySystem () const |
SimulatorFrontend & | frontend () const |
void | msg (const char *message) const |
void | haltSimulation (const char *file, int line, const char *procedure, const char *message) const |
void | resizeJumpTable (int newSize) |
SimulateFunction | getSimulateFunction (InstructionAddress address) |
void | setJumpTargetFunction (InstructionAddress address, SimulateFunction fp) |
void | compileAndLoadFunction (InstructionAddress address) |
SimValue * | getSymbolValue (const char *symbolName) |
void | addSymbol (const char *symbolName, SimValue &value) |
Protected Attributes | |
bool | dynamicCompilation_ |
Is this a dynamic compiled simulation? More... | |
ProcedureBBRelations & | procedureBBRelations_ |
A struct for finding out procedure begins from procedure's basic blocks. More... | |
const TTAMachine::Machine & | machine_ |
The simulated machine. More... | |
const InstructionAddress | entryAddress_ |
Entry address of the program. More... | |
const InstructionAddress | lastInstruction_ |
Last instruction of the program. More... | |
Private Member Functions | |
CompiledSimulation (const CompiledSimulation &) | |
Copying not allowed. More... | |
CompiledSimulation & | operator= (const CompiledSimulation &) |
Assignment not allowed. More... | |
Private Attributes | |
CompiledSimulationPimpl * | pimpl_ |
Private implementation in a separate source file. More... | |
An abstract class that is used as a base for all the compiled simulations
The derived classes are generated by CompiledSimCodeGenerator and then get loaded as plugins by the CompiledSimController.
Definition at line 112 of file CompiledSimulation.hh.
CompiledSimulation::CompiledSimulation | ( | const TTAMachine::Machine & | machine, |
InstructionAddress | entryAddress, | ||
InstructionAddress | lastInstruction, | ||
SimulatorFrontend & | frontend, | ||
CompiledSimController & | controller, | ||
MemorySystem & | memorySystem, | ||
bool | dynamicCompilation, | ||
ProcedureBBRelations & | procedureBBRelations | ||
) |
The constructor
Grabs all shared data from machine and program and saves them for easy access for later usage.
machine | The simulated machine |
program | The simulated program |
frontend | The simulation frontend |
memorySystem | The memory system |
Definition at line 72 of file CompiledSimulation.cc.
References bbExecCounts_, CompiledSimulationPimpl::controller_, CompiledSimulationPimpl::exitPoints_, TTASimulationController::findProgramExitPoints(), frontend(), CompiledSimulationPimpl::frontend_, machine_, memorySystem(), CompiledSimulationPimpl::memorySystem_, TTAProgram::Program::moveCount(), moveExecCounts_, pimpl_, and CompiledSimController::program().
|
virtual |
The destructor. Frees private implementation
Definition at line 120 of file CompiledSimulation.cc.
References bbExecCounts_, moveExecCounts_, and pimpl_.
|
private |
Copying not allowed.
|
inlinestatic |
|
inlinestatic |
|
protected |
Adds a new symbol name -> SimValue pair to the symbols map
symbolName | the symbol name |
value | the SimValue |
Definition at line 597 of file CompiledSimulation.cc.
References pimpl_, and CompiledSimulationPimpl::symbols_.
|
virtual |
Returns start of the basic block for given address of a basic block
address | address of a basic block |
Definition at line 389 of file CompiledSimulation.cc.
References CompiledSimController::basicBlockStart(), CompiledSimulationPimpl::controller_, and pimpl_.
Referenced by moveExecutionCount().
|
inlinestatic |
|
protected |
Compiles and loads all simulate functions belonging to a procedure containing the given address.
address | (any) address of a procedure to compile |
Definition at line 535 of file CompiledSimulation.cc.
References ProcedureBBRelations::basicBlockFiles, ProcedureBBRelations::basicBlockStarts, CompiledSimSymbolGenerator::basicBlockSymbol(), CompiledSimulationPimpl::compiler_, CompiledSimCompiler::compileToSO(), CompiledSimulationPimpl::controller_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::directoryOfPath(), FileSystem::fileNameBody(), PluginTools::importSymbol(), pimpl_, CompiledSimulationPimpl::pluginTools_, procedureBBRelations_, ProcedureBBRelations::procedureStart, PluginTools::registerModule(), setJumpTargetFunction(), and Conversion::toString().
Referenced by getSimulateFunction().
|
virtual |
Returns the current cycle count
Definition at line 242 of file CompiledSimulation.cc.
References cycleCount_.
|
virtual |
Lets the simulator frontend handle a single cycle end.
Used for example when generating traces.
Definition at line 138 of file CompiledSimulation.cc.
References SimulatorFrontend::eventHandler(), CompiledSimulationPimpl::frontend_, Informer::handleEvent(), lastExecutedInstruction_, pimpl_, programCounter_, and SimulationEventHandler::SE_CYCLE_END.
|
protected |
Returns a reference to the simulator frontend
Definition at line 440 of file CompiledSimulation.cc.
References CompiledSimulationPimpl::frontend_, and pimpl_.
Referenced by CompiledSimulation().
|
protected |
Returns a memory object of the given function unit
FUName | name of the function unit |
InstanceNotFound | If an item is not found |
Definition at line 413 of file CompiledSimulation.cc.
References assert, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MemorySystem::memory(), and memorySystem().
|
protected |
Returns a function unit of the given name
name | name of the function unit to return |
InstanceNotFound | If a function unit is not found |
Definition at line 401 of file CompiledSimulation.cc.
References TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and machine_.
Referenced by FUPortValue().
|
virtual |
Returns the value of the given FU port
fuName | Name of the FU |
portIndex | index of the port in the FU |
InstanceNotFound | If the FU port cannot be found |
Definition at line 306 of file CompiledSimulation.cc.
References __func__, CompiledSimulationPimpl::controller_, TTAMachine::Machine::controlUnit(), functionUnit(), machine_, pimpl_, TTAMachine::FunctionUnit::port(), CompiledSimSymbolGenerator::portSymbol(), CompiledSimulationPimpl::symbols_, and Conversion::toString().
|
inlinestatic |
|
protected |
Gets the simulate function of given address from the jump table.
If this is a dynamic compiled simulation, it'll first check if the simulate- function is available. If not, it will compile the required files first and then loads the simulate function symbols.
address | address to get the simulate function for |
SimulationExecutionError | If the jump function couldn't be gotten |
Definition at line 494 of file CompiledSimulation.cc.
References compileAndLoadFunction(), dynamicCompilation_, CompiledSimulationPimpl::jumpTable_, pimpl_, and Conversion::toString().
|
protected |
Returns value of the given symbol (be it RF, FU, or IU)
symbolName | Symbol name in the generated code |
Definition at line 579 of file CompiledSimulation.cc.
References pimpl_, and CompiledSimulationPimpl::symbols_.
|
protected |
Halts simulation by throwing an exception with a message attached to it
file | file where the exception happened, i.e. FILE |
line | line where the exception happened, i.e. LINE |
procedure | function where the exception happened, i.e. FUNCTION |
message | message to attach |
SimulationExecutionError | thrown always |
Definition at line 464 of file CompiledSimulation.cc.
|
virtual |
Returns the value of the selected immediate unit register
iuName | The name of the immediate unit |
index | Index of the immediate register |
InstanceNotFound | If the immediate unit cannot be found |
Definition at line 280 of file CompiledSimulation.cc.
References __func__, CompiledSimulationPimpl::controller_, CompiledSimSymbolGenerator::immediateRegisterSymbol(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, pimpl_, CompiledSimulationPimpl::symbols_, and Conversion::toString().
|
virtual |
Returns true if the simulation is finished
Definition at line 354 of file CompiledSimulation.cc.
References isFinished_.
|
virtual |
Returns address of the last executed instruction
Definition at line 233 of file CompiledSimulation.cc.
References lastExecutedInstruction_.
|
protected |
Returns a pointer to the memory system
Definition at line 429 of file CompiledSimulation.cc.
References assert, CompiledSimulationPimpl::memorySystem_, and pimpl_.
Referenced by CompiledSimulation(), and FUMemory().
|
virtual |
Returns move execution count for move #moveNumber.
moveNumber | move number as in POM |
Definition at line 365 of file CompiledSimulation.cc.
References basicBlockStart(), bbExecCounts_, CompiledSimulationPimpl::controller_, CompiledSimulationPimpl::exitPoints_, TTAProgram::Move::isUnconditional(), moveExecCounts_, pimpl_, program, and CompiledSimController::program().
Referenced by CompiledSimUtilizationStats::calculate().
|
protected |
A short cut for printing debugging info from the compiled code.
message | The message string to be shown on the log stream |
Definition at line 450 of file CompiledSimulation.cc.
References Application::logStream().
Referenced by next().
|
virtual |
Throws an exception since this feature is not supported yet!
SimulationExecutionError | always thrown |
Definition at line 170 of file CompiledSimulation.cc.
References msg().
|
private |
Assignment not allowed.
|
virtual |
Returns the value of the current PC
Definition at line 223 of file CompiledSimulation.cc.
References programCounter_.
|
virtual |
Returns the value of the selected register
rfName | The name of the register file |
registerIndex | index of the register in the RF |
InstanceNotFound | If the RF cannot be found |
Definition at line 255 of file CompiledSimulation.cc.
References __func__, CompiledSimulationPimpl::controller_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, pimpl_, TTAMachine::Machine::registerFileNavigator(), CompiledSimSymbolGenerator::registerSymbol(), CompiledSimulationPimpl::symbols_, and Conversion::toString().
|
virtual |
Sets the simulation to be requested to stop
Definition at line 332 of file CompiledSimulation.cc.
References stopRequested_.
|
protected |
Resizes the jump table
newSize | New size |
Definition at line 478 of file CompiledSimulation.cc.
References CompiledSimulationPimpl::jumpTable_, and pimpl_.
|
virtual |
Runs the simulation until it is finished or an exception occurs
address | An address the simulation is allowed to stop after |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Definition at line 189 of file CompiledSimulation.cc.
References cyclesToSimulate_, isFinished_, MAX_CYCLES, simulateCycle(), and stopRequested_.
|
virtual |
Advance the simulation until a given address is reached
address | An address the simulation is allowed to stop after |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Definition at line 207 of file CompiledSimulation.cc.
References cycleCount_, cyclesToSimulate_, isFinished_, jumpTarget_, MAX_CYCLES, simulateCycle(), and stopRequested_.
|
protected |
Sets a jump target function for given address at the jump table
address | address to set a jump function for |
fp | function pointer to set at the address |
Definition at line 522 of file CompiledSimulation.cc.
References CompiledSimulationPimpl::jumpTable_, and pimpl_.
Referenced by compileAndLoadFunction().
|
pure virtual |
Referenced by run(), runUntil(), and step().
|
virtual |
Advance the simulation by a given amout of cycles.
count | The number of cycles the simulation should be advanced at least |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Definition at line 155 of file CompiledSimulation.cc.
References cycleCount_, cyclesToSimulate_, isFinished_, simulateCycle(), and stopRequested_.
|
virtual |
Returns true if the simulation is requested to stop
This can be either because the simulation has finished or the requested amount of cycles has been simulated.
Definition at line 345 of file CompiledSimulation.cc.
References stopRequested_.
int CompiledSimulation::basicBlockCount_ |
Number of basic blocks gone through.
Definition at line 164 of file CompiledSimulation.hh.
ClockCycleCount* CompiledSimulation::bbExecCounts_ |
Basic block execution counts in a C style table.
Definition at line 192 of file CompiledSimulation.hh.
Referenced by CompiledSimulation(), moveExecutionCount(), and ~CompiledSimulation().
bool CompiledSimulation::conflictDetected_ |
A flag for FU conflict detection.
Definition at line 184 of file CompiledSimulation.hh.
ClockCycleCount CompiledSimulation::cycleCount_ |
Number of cycles simulated so far.
Definition at line 162 of file CompiledSimulation.hh.
Referenced by cycleCount(), runUntil(), and step().
ClockCycleCount CompiledSimulation::cyclesToSimulate_ |
Number of cycles left to simulate until the execution returns.
Definition at line 172 of file CompiledSimulation.hh.
Referenced by run(), runUntil(), and step().
|
protected |
Is this a dynamic compiled simulation?
Definition at line 236 of file CompiledSimulation.hh.
Referenced by getSimulateFunction().
|
protected |
Entry address of the program.
Definition at line 245 of file CompiledSimulation.hh.
bool CompiledSimulation::isFinished_ |
Is the simulation finished?
Definition at line 176 of file CompiledSimulation.hh.
Referenced by isFinished(), run(), runUntil(), and step().
InstructionAddress CompiledSimulation::jumpTarget_ |
The jump target. Allows jumping to different addresses in the code.
Definition at line 166 of file CompiledSimulation.hh.
Referenced by runUntil().
SimulateFunction CompiledSimulation::jumpTargetFunc_ |
Next jump target as a function pointer" << endl.
Definition at line 181 of file CompiledSimulation.hh.
InstructionAddress CompiledSimulation::lastExecutedInstruction_ |
Last executed instruction.
Definition at line 170 of file CompiledSimulation.hh.
Referenced by cycleEnd(), and lastExecutedInstruction().
|
protected |
Last instruction of the program.
Definition at line 247 of file CompiledSimulation.hh.
|
protected |
The simulated machine.
Definition at line 242 of file CompiledSimulation.hh.
Referenced by CompiledSimulation(), FUMemory(), functionUnit(), FUPortValue(), immediateUnitRegisterValue(), and registerFileValue().
ClockCycleCount* CompiledSimulation::moveExecCounts_ |
Move execution counts in a C style table.
Definition at line 189 of file CompiledSimulation.hh.
Referenced by CompiledSimulation(), moveExecutionCount(), and ~CompiledSimulation().
OperationPool CompiledSimulation::operationPool_ |
The operation pool.
Definition at line 179 of file CompiledSimulation.hh.
|
private |
Private implementation in a separate source file.
Definition at line 256 of file CompiledSimulation.hh.
Referenced by addSymbol(), basicBlockStart(), compileAndLoadFunction(), CompiledSimulation(), cycleEnd(), frontend(), FUPortValue(), getSimulateFunction(), getSymbolValue(), immediateUnitRegisterValue(), memorySystem(), moveExecutionCount(), registerFileValue(), resizeJumpTable(), setJumpTargetFunction(), and ~CompiledSimulation().
|
protected |
A struct for finding out procedure begins from procedure's basic blocks.
Definition at line 239 of file CompiledSimulation.hh.
Referenced by compileAndLoadFunction().
InstructionAddress CompiledSimulation::programCounter_ |
The program counter. i.e. which address the simulation is currently at.
Definition at line 168 of file CompiledSimulation.hh.
Referenced by cycleEnd(), and programCounter().
bool CompiledSimulation::stopRequested_ |
Should the simulation stop or not?
Definition at line 174 of file CompiledSimulation.hh.
Referenced by requestToStop(), run(), runUntil(), step(), and stopRequested().