OpenASIP
2.0
|
#include <TTASimulationController.hh>
Public Types | |
enum | SimulationStatus { STA_INITIALIZING, STA_INITIALIZED, STA_RUNNING, STA_STOPPED, STA_FINISHED } |
The states of simulation. More... | |
Public Member Functions | |
TTASimulationController (SimulatorFrontend &frontend, const TTAMachine::Machine &machine, const TTAProgram::Program &program) | |
virtual | ~TTASimulationController () |
virtual void | step (double count=1)=0 |
virtual void | next (int count=1)=0 |
virtual void | run ()=0 |
virtual void | runUntil (UIntWord address)=0 |
virtual void | reset ()=0 |
virtual std::string | registerFileValue (const std::string &rfName, int registerIndex=-1)=0 |
virtual SimValue | immediateUnitRegisterValue (const std::string &iuName, int index=-1)=0 |
virtual SimValue | FUPortValue (const std::string &fuName, const std::string &portName)=0 |
virtual void | prepareToStop (StopReason reason) |
virtual unsigned int | stopReasonCount () const |
virtual StopReason | stopReason (unsigned int index) const |
virtual SimulationStatus | state () const |
virtual InstructionAddress | programCounter () const =0 |
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::set< StopReason > | StopReasonContainer |
The container type for reasons why simulation stop was requested. More... | |
Protected Member Functions | |
TTASimulationController (const TTASimulationController &) | |
Copying not allowed. More... | |
TTASimulationController & | operator= (const TTASimulationController &) |
Assignment not allowed. More... | |
Protected Attributes | |
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... | |
An abstract interface class for controlling the simulation
Owns and is the main client of the machine state model.
Definition at line 69 of file TTASimulationController.hh.
|
protected |
The container type for reasons why simulation stop was requested.
Definition at line 132 of file TTASimulationController.hh.
The states of simulation.
Definition at line 72 of file TTASimulationController.hh.
TTASimulationController::TTASimulationController | ( | SimulatorFrontend & | frontend, |
const TTAMachine::Machine & | machine, | ||
const TTAProgram::Program & | program | ||
) |
Constructor.
Exception | Exceptions while building the simulation models are thrown forward. |
Definition at line 60 of file TTASimulationController.cc.
|
virtual |
|
protected |
Copying not allowed.
|
virtual |
Returns true in case simulation cannot be finished automatically.
In order for this method to return false, it means that while initializing the SimulationController, a probable ending point in the program was detected and it is possible that when running the simulation it is possible to finish it automatically at that position. If this method returns true it is impossible to finish simulation automatically.
Definition at line 197 of file TTASimulationController.cc.
References automaticFinishImpossible_.
Referenced by SimulatorFrontend::automaticFinishImpossible().
|
virtual |
Returns the count of clock cycles simulated.
Reimplemented in CompiledSimController.
Definition at line 161 of file TTASimulationController.cc.
References clockCount_.
Referenced by SimulatorFrontend::cycleCount(), ExecutionTracker::handleEvent(), StopPointManager::handleEvent(), and StopPointManager::stopCausingStopPointCount().
|
virtual |
Initializes the variables that are used in programEnded() to evaluate whether the simulated program has simulated to its end.
program | The simulated program. |
machine | The simulated machine. |
Definition at line 209 of file TTASimulationController.cc.
References __func__, TTAProgram::Instruction::address(), automaticFinishImpossible_, TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::delaySlots(), TTAProgram::CodeSnippet::endAddress(), firstIllegalInstructionIndex_, TTAProgram::CodeSnippet::firstInstruction(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isReturn(), TTAProgram::Address::location(), machine, TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Procedure::name(), program, and TTAProgram::CodeSnippet::startAddress().
Referenced by CompiledSimulation::CompiledSimulation(), SimulationController::findExitPoints(), CompiledSimCodeGenerator::generateSimulationCode(), and RemoteController::RemoteController().
|
virtual |
Returns the simulator frontend.
Definition at line 181 of file TTASimulationController.cc.
References frontend_.
Referenced by ExecutionTracker::ExecutionTracker(), memorySystem(), SimulationController::SimulationController(), and ExecutionTracker::~ExecutionTracker().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::FUPortValue().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::immediateUnitRegisterValue().
|
virtual |
Returns the address of the last executed instruction.
Definition at line 147 of file TTASimulationController.cc.
References frontend_, lastExecutedInstruction_, and SimulatorFrontend::selectedCore().
Referenced by ExecutionTracker::handleEvent(), and SimulatorFrontend::lastExecutedInstruction().
|
virtual |
Returns a reference to the memory system.
Definition at line 171 of file TTASimulationController.cc.
References frontend(), and SimulatorFrontend::memorySystem().
Referenced by OTASimulationController::advanceMachineCycle(), SimulatorFrontend::initializeDataMemories(), CompiledSimController::reset(), and SimulationController::simulateCycle().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::next().
|
protected |
Assignment not allowed.
|
virtual |
Get ready to return control to the client.
Functions name is has "prepare" in its name even though it always is able to stop the simulation. The reason for this is that it does not stop the simulation in the middle of simulating a clock cycle, but after the current clock cycle is simulated.
reason | The reason why simulation should be stopped. |
Reimplemented in CompiledSimController.
Definition at line 90 of file TTASimulationController.cc.
References stopReasons_, and stopRequested_.
Referenced by StopPointManager::handleEvent(), SimulationController::next(), CompiledSimController::prepareToStop(), SimulatorFrontend::prepareToStop(), SimulationController::runUntil(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), and SimulationController::step().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, TCEDBGController, CustomDBGController, and SimulationController.
Referenced by SimulatorFrontend::programCounter().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::registerFileValue().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::killSimulation().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::run().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::runUntil().
|
virtual |
Returns the state of the simulation.
Definition at line 137 of file TTASimulationController.cc.
References state_.
Referenced by SimulatorFrontend::hasSimulationEnded(), SimulatorFrontend::isSimulationInitialized(), SimulatorFrontend::isSimulationRunning(), and SimulatorFrontend::isSimulationStopped().
|
pure virtual |
Implemented in RemoteController, CompiledSimController, SimulationController, TCEDBGController, and CustomDBGController.
Referenced by SimulatorFrontend::step().
|
virtual |
Returns the stop reason with the given index.
index | The wanted index. |
OutOfRange | If the given index is out of range. |
Definition at line 113 of file TTASimulationController.cc.
References __func__, stopReasonCount(), and stopReasons_.
Referenced by SimulatorFrontend::stopReason().
|
virtual |
Returns the count of stop reasons.
Definition at line 101 of file TTASimulationController.cc.
References stopReasons_.
Referenced by stopReason(), and SimulatorFrontend::stopReasonCount().
|
mutableprotected |
If this is true, simulation cannot be finished automatically.
Definition at line 155 of file TTASimulationController.hh.
Referenced by automaticFinishImpossible(), and findProgramExitPoints().
|
protected |
How many clock cycles have been simulated.
Definition at line 149 of file TTASimulationController.hh.
Referenced by clockCount(), SimulationController::reset(), CompiledSimController::reset(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), and SimulationController::SimulationController().
|
mutableprotected |
The index of the first illegal instruction in the instruction sequence.
Definition at line 158 of file TTASimulationController.hh.
Referenced by findProgramExitPoints(), OTASimulationController::simulateCycle(), and SimulationController::simulateCycle().
|
protected |
Reference to the simulator frontend.
Definition at line 135 of file TTASimulationController.hh.
Referenced by OTASimulationController::advanceMachineCycle(), frontend(), SimulationController::instructionMemory(), lastExecutedInstruction(), SimulationController::machineState(), SimulationController::next(), CompiledSimController::next(), SimulationController::programCounter(), SimulationController::registerFileValue(), CompiledSimController::reset(), SimulationController::run(), CompiledSimController::run(), SimulationController::runUntil(), CompiledSimController::runUntil(), SimulationController::selectedInstructionMemory(), SimulationController::selectedMachineState(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), SimulationController::SimulationController(), SimulationController::step(), and CompiledSimController::step().
|
protected |
The address of the first executed instruction.
Definition at line 153 of file TTASimulationController.hh.
Referenced by SimulationController::reset().
|
protected |
The address of the last executed instruction.
Definition at line 151 of file TTASimulationController.hh.
Referenced by lastExecutedInstruction(), OTASimulationController::simulateCycle(), and SimulationController::simulateCycle().
|
protected |
Program object model of the simulated program.
Definition at line 139 of file TTASimulationController.hh.
Referenced by RemoteController::loadIMemImage(), SimulationController::next(), CompiledSimController::program(), and CompiledSimController::reset().
|
protected |
The simulated Machine Object Model.
Definition at line 137 of file TTASimulationController.hh.
Referenced by RemoteController::loadIMemImage(), SimulationController::registerFileValue(), CompiledSimController::registerFileValue(), and CompiledSimController::reset().
|
protected |
The current state of the simulation.
Definition at line 147 of file TTASimulationController.hh.
Referenced by SimulationController::next(), CompiledSimController::next(), SimulationController::reset(), CompiledSimController::reset(), SimulationController::run(), CompiledSimController::run(), SimulationController::runUntil(), CompiledSimController::runUntil(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), state(), SimulationController::step(), and CompiledSimController::step().
|
protected |
The set of reasons the simulation was stopped.
Definition at line 144 of file TTASimulationController.hh.
Referenced by SimulationController::next(), CompiledSimController::next(), prepareToStop(), SimulationController::run(), CompiledSimController::run(), SimulationController::runUntil(), CompiledSimController::runUntil(), SimulationController::step(), CompiledSimController::step(), stopReason(), and stopReasonCount().
|
protected |
Flag indicating that simulation should stop.
Definition at line 142 of file TTASimulationController.hh.
Referenced by SimulationController::next(), CompiledSimController::next(), prepareToStop(), SimulationController::reset(), CompiledSimController::reset(), SimulationController::run(), CompiledSimController::run(), SimulationController::runUntil(), CompiledSimController::runUntil(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), SimulationController::step(), and CompiledSimController::step().