OpenASIP
2.0
|
#include <SimulationController.hh>
Public Member Functions | |
SimulationController (SimulatorFrontend &frontend, const TTAMachine::Machine &machine, const TTAProgram::Program &program, bool fuResourceConflictDetection=true, bool detailedSimulation=false) | |
virtual | ~SimulationController () |
virtual void | step (double count=1) |
virtual void | next (int count=1) |
virtual void | run () |
virtual void | runUntil (UIntWord address) |
virtual void | reset () |
virtual InstructionAddress | programCounter () const |
virtual MachineState & | machineState (int core=-1) |
virtual const InstructionMemory & | instructionMemory (int core=-1) const |
virtual std::string | registerFileValue (const std::string &rfName, int registerIndex=-1) |
virtual SimValue | immediateUnitRegisterValue (const std::string &iuName, int index=-1) |
virtual SimValue | FUPortValue (const std::string &fuName, const std::string &portName) |
Public Member Functions inherited from TTASimulationController | |
TTASimulationController (SimulatorFrontend &frontend, const TTAMachine::Machine &machine, const TTAProgram::Program &program) | |
virtual | ~TTASimulationController () |
virtual void | prepareToStop (StopReason reason) |
virtual unsigned int | stopReasonCount () const |
virtual StopReason | stopReason (unsigned int index) const |
virtual SimulationStatus | state () const |
virtual InstructionAddress | lastExecutedInstruction (int coreId=-1) const |
virtual ClockCycleCount | clockCount () const |
virtual MemorySystem & | memorySystem (int coreId=-1) |
virtual SimulatorFrontend & | frontend () |
virtual bool | automaticFinishImpossible () const |
virtual std::set< InstructionAddress > | findProgramExitPoints (const TTAProgram::Program &program, const TTAMachine::Machine &machine) const |
Protected Types | |
typedef std::vector< MachineState * > | MachineStateContainer |
Protected Types inherited from TTASimulationController | |
typedef std::set< StopReason > | StopReasonContainer |
The container type for reasons why simulation stop was requested. More... | |
Protected Member Functions | |
virtual bool | simulateCycle () |
Protected Member Functions inherited from TTASimulationController | |
TTASimulationController (const TTASimulationController &) | |
Copying not allowed. More... | |
TTASimulationController & | operator= (const TTASimulationController &) |
Assignment not allowed. More... | |
Protected Attributes | |
MachineStateContainer | machineStates_ |
The machine state models for the simulated cores. More... | |
std::vector< InstructionMemory * > | instructionMemories_ |
The instruction memory models of cores. More... | |
Protected Attributes inherited from TTASimulationController | |
SimulatorFrontend & | frontend_ |
Reference to the simulator frontend. More... | |
const TTAMachine::Machine & | sourceMachine_ |
The simulated Machine Object Model. More... | |
const TTAProgram::Program & | program_ |
Program object model of the simulated program. More... | |
bool | stopRequested_ |
Flag indicating that simulation should stop. More... | |
StopReasonContainer | stopReasons_ |
The set of reasons the simulation was stopped. More... | |
SimulationStatus | state_ |
The current state of the simulation. More... | |
ClockCycleCount | clockCount_ |
How many clock cycles have been simulated. More... | |
std::vector< InstructionAddress > | lastExecutedInstruction_ |
The address of the last executed instruction. More... | |
InstructionAddress | initialPC_ |
The address of the first executed instruction. More... | |
bool | automaticFinishImpossible_ |
If this is true, simulation cannot be finished automatically. More... | |
InstructionAddress | firstIllegalInstructionIndex_ |
The index of the first illegal instruction in the instruction sequence. More... | |
Private Member Functions | |
SimulationController (const SimulationController &) | |
Copying not allowed. More... | |
SimulationController & | operator= (const SimulationController &) |
Assignment not allowed. More... | |
void | buildFUResourceConflictDetectors (const TTAMachine::Machine &machine) |
void | findExitPoints (const TTAProgram::Program &program, const TTAMachine::Machine &machine) |
MachineState & | selectedMachineState () |
InstructionMemory & | selectedInstructionMemory () |
Private Attributes | |
MultiCoreFUConflictDetectorIndex | fuConflictDetectors_ |
The FU resource conflict detectors used to detect conflicts during simulation. More... | |
std::vector< FUResourceConflictDetector * > | conflictDetectorVector_ |
Resource conflict detectors in a more quickly traversed container. More... | |
std::vector< InstructionAddress > | tmpExecutedInstructions_ |
Temporary place for lastExecuted Instruction. More... | |
Additional Inherited Members | |
Public Types inherited from TTASimulationController | |
enum | SimulationStatus { STA_INITIALIZING, STA_INITIALIZED, STA_RUNNING, STA_STOPPED, STA_FINISHED } |
The states of simulation. More... | |
Controls the simulation running in stand-alone mode.
Supports also homogeneous multicore simulation when ADF's core-count > 1.
Owns and is the main client of the machine state model.
Definition at line 46 of file SimulationController.hh.
|
protected |
Definition at line 87 of file SimulationController.hh.
SimulationController::SimulationController | ( | SimulatorFrontend & | frontend, |
const TTAMachine::Machine & | machine, | ||
const TTAProgram::Program & | program, | ||
bool | fuResourceConflictDetection = true , |
||
bool | detailedSimulation = false |
||
) |
Constructor.
machine | Machine to be simulated. |
memSys | Memory system. |
fuResourceConflictDetection | Should the model detect FU resource conflicts. |
Exception | Exceptions while building the simulation models are thrown forward. |
Definition at line 87 of file SimulationController.cc.
References MachineStateBuilder::build(), SimProgramBuilder::build(), buildFUResourceConflictDetectors(), TTASimulationController::clockCount_, FUState::context(), findExitPoints(), TTASimulationController::frontend(), TTASimulationController::frontend_, fuConflictDetectors_, MachineState::fuState(), MachineState::FUStateCount(), instructionMemories_, instructionMemory(), machine, machineState(), machineStates_, SimulatorFrontend::memorySystem(), program, reset(), SimulatorFrontend::selectCore(), and OperationContext::setCycleCountVariable().
|
virtual |
Destructor.
Definition at line 134 of file SimulationController.cc.
References conflictDetectorVector_, SequenceTools::deleteAllItems(), instructionMemories_, and machineStates_.
|
private |
Copying not allowed.
|
private |
Builds the FU resource conflict detectors for each FU in the machine.
Uses the "lazy FSA" detection model.
Definition at line 522 of file SimulationController.cc.
References conflictDetectorVector_, TTAMachine::Machine::Navigator< ComponentType >::count(), fuConflictDetectors_, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, and TTAMachine::Component::name().
Referenced by SimulationController().
|
private |
Definition at line 398 of file SimulationController.cc.
References TTASimulationController::findProgramExitPoints(), instructionMemories_, machine, and program.
Referenced by SimulationController().
|
virtual |
Returns the current value of a FU port
fuName | name of the function unit |
portName | name of the FU port |
Implements TTASimulationController.
Definition at line 510 of file SimulationController.cc.
References selectedMachineState().
|
virtual |
Returns the current value of a IU register
iuName | name of the immediate unit |
index | index of the register |
Implements TTASimulationController.
Definition at line 495 of file SimulationController.cc.
References selectedMachineState().
|
virtual |
Definition at line 543 of file SimulationController.cc.
References TTASimulationController::frontend_, instructionMemories_, and SimulatorFrontend::selectedCore().
Referenced by SimulationController().
|
virtual |
Returns a reference to the currently selected machine state model.
Definition at line 145 of file SimulationController.cc.
References TTASimulationController::frontend_, machineStates_, and SimulatorFrontend::selectedCore().
Referenced by OTASimulationController::advanceMachineCycle(), SimulatorFrontend::machineState(), OTASimulationController::simulateCycle(), simulateCycle(), and SimulationController().
|
virtual |
Advance simulation by a given amout of steps and skip procedure calls.
count | Number of steps to simulate. |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Implements TTASimulationController.
Definition at line 297 of file SimulationController.cc.
References SimulatorFrontend::eventHandler(), TTASimulationController::frontend_, Informer::handleEvent(), TTAProgram::Program::instructionAt(), TTAProgram::Instruction::parent(), TTASimulationController::prepareToStop(), TTASimulationController::program_, programCounter(), SimulationEventHandler::SE_SIMULATION_STOPPED, simulateCycle(), SRE_AFTER_STEPPING, SRE_AFTER_UNTIL, TTASimulationController::STA_FINISHED, TTASimulationController::STA_RUNNING, TTASimulationController::STA_STOPPED, TTASimulationController::state_, TTASimulationController::stopReasons_, and TTASimulationController::stopRequested_.
|
private |
Assignment not allowed.
|
virtual |
Returns the program counter value of the currently selected core.
Implements TTASimulationController.
Definition at line 444 of file SimulationController.cc.
References TTASimulationController::frontend_, machineStates_, and SimulatorFrontend::selectedCore().
Referenced by next(), and runUntil().
|
virtual |
Returns a string containing the value(s) of the register file
rfName | name of the register file to search for |
registerIndex | index of the register. if -1, all registers are listed |
InstanceNotFound | If the register cannot be found. |
Implements TTASimulationController.
Definition at line 457 of file SimulationController.cc.
References SimulatorFrontend::findRegister(), TTASimulationController::frontend_, SimValue::hexValue(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Machine::registerFileNavigator(), TTASimulationController::sourceMachine_, Conversion::toString(), and ReadableState::value().
|
virtual |
Resets the simulation so it can be started from the beginning.
Resets the program counter to its initial value, and also clears the instrution execution counts and states of possible FU resource conflict detectors.
Implements TTASimulationController.
Definition at line 421 of file SimulationController.cc.
References TTASimulationController::clockCount_, conflictDetectorVector_, TTASimulationController::initialPC_, instructionMemories_, machineStates_, TTASimulationController::STA_INITIALIZED, TTASimulationController::STA_INITIALIZING, TTASimulationController::state_, and TTASimulationController::stopRequested_.
Referenced by SimulationController().
|
virtual |
Advance simulation until a condition for stopping is enabled.
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Implements TTASimulationController.
Definition at line 346 of file SimulationController.cc.
References SimulatorFrontend::eventHandler(), TTASimulationController::frontend_, Informer::handleEvent(), SimulationEventHandler::SE_SIMULATION_STOPPED, simulateCycle(), TTASimulationController::STA_FINISHED, TTASimulationController::STA_RUNNING, TTASimulationController::STA_STOPPED, TTASimulationController::state_, TTASimulationController::stopReasons_, and TTASimulationController::stopRequested_.
|
virtual |
Advance simulation until given address is reached.
address | The instruction address to reach. |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Implements TTASimulationController.
Definition at line 369 of file SimulationController.cc.
References SimulatorFrontend::eventHandler(), TTASimulationController::frontend_, Informer::handleEvent(), TTASimulationController::prepareToStop(), programCounter(), SimulationEventHandler::SE_SIMULATION_STOPPED, selectedMachineState(), simulateCycle(), SRE_AFTER_UNTIL, TTASimulationController::STA_FINISHED, TTASimulationController::STA_RUNNING, TTASimulationController::STA_STOPPED, TTASimulationController::state_, TTASimulationController::stopReasons_, and TTASimulationController::stopRequested_.
|
private |
Definition at line 554 of file SimulationController.cc.
References TTASimulationController::frontend_, instructionMemories_, and SimulatorFrontend::selectedCore().
|
private |
Definition at line 549 of file SimulationController.cc.
References TTASimulationController::frontend_, machineStates_, and SimulatorFrontend::selectedCore().
Referenced by FUPortValue(), immediateUnitRegisterValue(), and runUntil().
|
protectedvirtual |
Simulates a cycle.
Reimplemented in OTASimulationController.
Definition at line 158 of file SimulationController.cc.
References FUResourceConflictDetector::advanceClock(), GCUState::advanceClock(), MachineState::advanceClockOfAllFUStates(), MachineState::advanceClockOfAllGuardStates(), MachineState::advanceClockOfAllLongImmediateUnitStates(), MemorySystem::advanceClockOfLocalMemories(), MemorySystem::advanceClockOfSharedMemories(), MachineState::clearBuses(), TTASimulationController::clockCount_, conflictDetectorVector_, FUState::endClock(), MachineState::endClockOfAllFUStates(), Exception::errorMessage(), SimulatorFrontend::eventHandler(), ExecutableInstruction::execute(), TTASimulationController::firstIllegalInstructionIndex_, TTASimulationController::frontend_, MachineState::gcuState(), Informer::handleEvent(), instructionMemories_, ExecutableInstruction::isExitPoint(), MachineState::isFinished(), FUResourceConflictDetector::isIdle(), FUState::isIdle(), TTASimulationController::lastExecutedInstruction_, machineState(), machineStates_, TTASimulationController::memorySystem(), SimulatorFrontend::memorySystem(), TTASimulationController::prepareToStop(), GCUState::programCounter(), SimulatorFrontend::reportSimulatedProgramError(), SimulatorFrontend::RES_FATAL, SimulationEventHandler::SE_CYCLE_END, SimulationEventHandler::SE_NEW_INSTRUCTION, SimulatorFrontend::selectCore(), MachineState::setFinished(), SRE_RUNTIME_ERROR, TTASimulationController::STA_FINISHED, TTASimulationController::state_, TTASimulationController::stopRequested_, and tmpExecutedInstructions_.
Referenced by next(), run(), runUntil(), and step().
|
virtual |
Advance simulation by a given amout of cycles.
count | The number of cycles the simulation is advanced. |
SimulationExecutionError | If a runtime error occurs in the simulated program. |
Implements TTASimulationController.
Definition at line 265 of file SimulationController.cc.
References assert, SimulatorFrontend::eventHandler(), TTASimulationController::frontend_, Informer::handleEvent(), TTASimulationController::prepareToStop(), SimulationEventHandler::SE_SIMULATION_STOPPED, simulateCycle(), SRE_AFTER_STEPPING, TTASimulationController::STA_FINISHED, TTASimulationController::STA_INITIALIZED, TTASimulationController::STA_RUNNING, TTASimulationController::STA_STOPPED, TTASimulationController::state_, TTASimulationController::stopReasons_, and TTASimulationController::stopRequested_.
|
private |
Resource conflict detectors in a more quickly traversed container.
Definition at line 112 of file SimulationController.hh.
Referenced by buildFUResourceConflictDetectors(), reset(), simulateCycle(), and ~SimulationController().
|
private |
The FU resource conflict detectors used to detect conflicts during simulation.
Definition at line 110 of file SimulationController.hh.
Referenced by buildFUResourceConflictDetectors(), and SimulationController().
|
protected |
The instruction memory models of cores.
Definition at line 92 of file SimulationController.hh.
Referenced by findExitPoints(), instructionMemory(), reset(), selectedInstructionMemory(), OTASimulationController::simulateCycle(), simulateCycle(), SimulationController(), and ~SimulationController().
|
protected |
The machine state models for the simulated cores.
Definition at line 90 of file SimulationController.hh.
Referenced by OTASimulationController::advanceMachineCycle(), machineState(), programCounter(), reset(), selectedMachineState(), OTASimulationController::simulateCycle(), simulateCycle(), SimulationController(), and ~SimulationController().
|
private |
Temporary place for lastExecuted Instruction.
Definition at line 114 of file SimulationController.hh.
Referenced by simulateCycle().