58 std::numeric_limits<ClockCycleCount>::max();
79 bool dynamicCompilation,
83 jumpTarget_(entryAddress),
84 programCounter_(entryAddress),
85 lastExecutedInstruction_(0),
87 stopRequested_(
false),
89 conflictDetected_(
false),
90 dynamicCompilation_(dynamicCompilation),
91 procedureBBRelations_(procedureBBRelations),
93 entryAddress_(entryAddress),
102 for (
int i = 0; i < moveCount; ++i) {
106 int bbCount = lastInstruction - entryAddress + 1;
108 for (
int i = 0; i < bbCount; ++i) {
173 "Command nexti not yet supported in the compiled simulation!");
259 std::string registerFile = symbolGen.
registerSymbol(rf, registerIndex);
261 CompiledSimulationPimpl::Symbols::const_iterator rfIterator =
264 return *(rfIterator->second);
267 "Register file " + std::string(rfName) +
" not found.");
287 CompiledSimulationPimpl::Symbols::const_iterator iuIterator =
290 return *(iuIterator->second);
293 "Immediate unit " + std::string(iuName) +
" not found.");
318 CompiledSimulationPimpl::Symbols::const_iterator fuPortIterator =
321 return *(fuPortIterator->second);
324 "FU port " + std::string(fuPort) +
" not found.");
376 programStartAddress);
420 FUName)->addressSpace()).get());
467 const char* procedure,
468 const char* message)
const {
498 if (targetFunction != 0) {
499 return targetFunction;
505 if (targetFunction != 0) {
506 return targetFunction;
512 ". Please try with the interpretive simulation engine." );
541 std::set<std::string> compiledFiles;
546 typedef ProcedureBBRelations::BasicBlockStarts::iterator BBIterator;
547 std::pair<BBIterator, BBIterator> equalRange =
551 for (BBIterator it = equalRange.first; it != equalRange.second; ++it) {
555 if (compiledFiles.find(file) == compiledFiles.end()) {
561 compiledFiles.insert(file);
581 CompiledSimulationPimpl::Symbols::iterator it =
pimpl_->
symbols_.find(
582 std::string(symbolName));
#define assert(condition)
UInt32 InstructionAddress
static const ClockCycleCount MAX_CYCLES
void(* SimulateFunction)(void *engine)
Type for the simulateXXXXX basic block functions.
TTAMachine::Machine * machine
the architecture definition of the estimated processor
find Finds info of the inner loops in the program
find Finds info of the inner loops in the false
CycleCount ClockCycleCount
Alias for ClockCycleCount.
static std::ostream & logStream()
int compileToSO(const std::string &path, const std::string &flags="", bool verbose=false) const
const TTAProgram::Program & program() const
InstructionAddress basicBlockStart(InstructionAddress address) const
std::string basicBlockSymbol(InstructionAddress startAddress) const
std::string portSymbol(const TTAMachine::Port &port) const
std::string registerSymbol(const TTAProgram::Terminal &terminal) const
std::string immediateRegisterSymbol(const TTAProgram::Terminal &terminal) const
MemorySystem * memorySystem_
The memory system.
std::set< InstructionAddress > exitPoints_
Program exit points in a set.
CompiledSimController * controller_
Simulation controller.
Symbols symbols_
A Symbol map for easily getting the SimValues out of the simulation.
CompiledSimCompiler compiler_
The Compiled Simulation compiler.
SimulatorFrontend * frontend_
The simulator frontend.
JumpTable jumpTable_
The jump table.
PluginTools pluginTools_
Plugintools used to load the compiled .so files.
MemorySystem * memorySystem() const
virtual ClockCycleCount moveExecutionCount(int moveNumber, InstructionAddress address) const
CompiledSimulation(const TTAMachine::Machine &machine, InstructionAddress entryAddress, InstructionAddress lastInstruction, SimulatorFrontend &frontend, CompiledSimController &controller, MemorySystem &memorySystem, bool dynamicCompilation, ProcedureBBRelations &procedureBBRelations)
void setJumpTargetFunction(InstructionAddress address, SimulateFunction fp)
virtual InstructionAddress lastExecutedInstruction() const
ProcedureBBRelations & procedureBBRelations_
A struct for finding out procedure begins from procedure's basic blocks.
virtual void simulateCycle()=0
SimulateFunction getSimulateFunction(InstructionAddress address)
virtual void requestToStop()
const TTAMachine::Machine & machine_
The simulated machine.
virtual void step(double count)
virtual SimValue registerFileValue(const char *rfName, int registerIndex)
ClockCycleCount * moveExecCounts_
Move execution counts in a C style table.
bool stopRequested_
Should the simulation stop or not?
virtual void runUntil(UIntWord address)
SimulatorFrontend & frontend() const
virtual ClockCycleCount cycleCount() const
virtual bool isFinished() const
ClockCycleCount cycleCount_
Number of cycles simulated so far.
CompiledSimulationPimpl * pimpl_
Private implementation in a separate source file.
bool isFinished_
Is the simulation finished?
InstructionAddress programCounter_
The program counter. i.e. which address the simulation is currently at.
InstructionAddress lastExecutedInstruction_
Last executed instruction.
DirectAccessMemory & FUMemory(const char *FUName) const
virtual bool stopRequested() const
void resizeJumpTable(int newSize)
void addSymbol(const char *symbolName, SimValue &value)
virtual InstructionAddress programCounter() const
virtual void next(int count)
void msg(const char *message) const
void compileAndLoadFunction(InstructionAddress address)
void haltSimulation(const char *file, int line, const char *procedure, const char *message) const
ClockCycleCount * bbExecCounts_
Basic block execution counts in a C style table.
virtual SimValue immediateUnitRegisterValue(const char *iuName, int index)
SimValue * getSymbolValue(const char *symbolName)
virtual SimValue FUPortValue(const char *fuName, const char *portName)
ClockCycleCount cyclesToSimulate_
Number of cycles left to simulate until the execution returns.
InstructionAddress jumpTarget_
The jump target. Allows jumping to different addresses in the code.
bool dynamicCompilation_
Is this a dynamic compiled simulation?
TTAMachine::FunctionUnit & functionUnit(const char *name) const
virtual ~CompiledSimulation()
virtual InstructionAddress basicBlockStart(InstructionAddress address) const
static std::string toString(const T &source)
static const std::string DIRECTORY_SEPARATOR
static std::string fileNameBody(const std::string &fileName)
static std::string directoryOfPath(const std::string fileName)
MemoryPtr memory(const TTAMachine::AddressSpace &as)
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
SimulationEventHandler & eventHandler()
virtual BaseFUPort * port(const std::string &name) const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
virtual FunctionUnitNavigator functionUnitNavigator() const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
virtual ControlUnit * controlUnit() const
InstructionAddress location() const
bool isUnconditional() const
Address startAddress() const
virtual std::set< InstructionAddress > findProgramExitPoints(const TTAProgram::Program &program, const TTAMachine::Machine &machine) const
A struct for tracking basic blocks and their relation to their procedures.
std::map< InstructionAddress, std::string > basicBlockFiles
Basic block starts and their corresponding .cpp files.
std::map< InstructionAddress, InstructionAddress > procedureStart
Procedure start per basic block starts.
BasicBlockStarts basicBlockStarts
All basic block start addresses per procedure start.