OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CompiledSimulation Class Referenceabstract

#include <CompiledSimulation.hh>

Collaboration diagram for CompiledSimulation:
Collaboration graph

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.
 
int basicBlockCount_
 Number of basic blocks gone through.
 
InstructionAddress jumpTarget_
 The jump target. Allows jumping to different addresses in the code.
 
InstructionAddress programCounter_
 The program counter. i.e. which address the simulation is currently at.
 
InstructionAddress lastExecutedInstruction_
 Last executed instruction.
 
ClockCycleCount cyclesToSimulate_
 Number of cycles left to simulate until the execution returns.
 
bool stopRequested_
 Should the simulation stop or not?
 
bool isFinished_
 Is the simulation finished?
 
OperationPool operationPool_
 The operation pool.
 
SimulateFunction jumpTargetFunc_
 Next jump target as a function pointer" << endl.
 
bool conflictDetected_
 A flag for FU conflict detection.
 
ClockCycleCountmoveExecCounts_
 Move execution counts in a C style table.
 
ClockCycleCountbbExecCounts_
 Basic block execution counts in a C style table.
 

Protected Member Functions

TTAMachine::FunctionUnitfunctionUnit (const char *name) const
 
DirectAccessMemoryFUMemory (const char *FUName) const
 
MemorySystemmemorySystem () const
 
SimulatorFrontendfrontend () 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)
 
SimValuegetSymbolValue (const char *symbolName)
 
void addSymbol (const char *symbolName, SimValue &value)
 

Protected Attributes

bool dynamicCompilation_
 Is this a dynamic compiled simulation?
 
ProcedureBBRelationsprocedureBBRelations_
 A struct for finding out procedure begins from procedure's basic blocks.
 
const TTAMachine::Machinemachine_
 The simulated machine.
 
const InstructionAddress entryAddress_
 Entry address of the program.
 
const InstructionAddress lastInstruction_
 Last instruction of the program.
 

Private Member Functions

 CompiledSimulation (const CompiledSimulation &)
 Copying not allowed.
 
CompiledSimulationoperator= (const CompiledSimulation &)
 Assignment not allowed.
 

Private Attributes

CompiledSimulationPimplpimpl_
 Private implementation in a separate source file.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CompiledSimulation() [1/2]

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.

Parameters
machineThe simulated machine
programThe simulated program
frontendThe simulation frontend
memorySystemThe memory system

Definition at line 72 of file CompiledSimulation.cc.

80 :
81 cycleCount_(0),
83 jumpTarget_(entryAddress),
84 programCounter_(entryAddress),
87 stopRequested_(false),
88 isFinished_(false),
89 conflictDetected_(false),
90 dynamicCompilation_(dynamicCompilation),
91 procedureBBRelations_(procedureBBRelations),
93 entryAddress_(entryAddress),
94 lastInstruction_(lastInstruction), pimpl_(new CompiledSimulationPimpl()) {
97 pimpl_->controller_ = &controller;
98
99 // Allocate memory for calculating move and basic block execution counts
100 int moveCount = pimpl_->controller_->program().moveCount();
101 moveExecCounts_ = new ClockCycleCount[moveCount];
102 for (int i = 0; i < moveCount; ++i) {
103 moveExecCounts_[i] = 0;
104 }
105
106 int bbCount = lastInstruction - entryAddress + 1;
107 bbExecCounts_ = new ClockCycleCount[bbCount];
108 for (int i = 0; i < bbCount; ++i) {
109 bbExecCounts_[i] = 0;
110 }
111
112 // Find program exit points
115}
static const ClockCycleCount MAX_CYCLES
TTAMachine::Machine * machine
the architecture definition of the estimated processor
CycleCount ClockCycleCount
Alias for ClockCycleCount.
const TTAProgram::Program & program() const
MemorySystem * memorySystem_
The memory system.
std::set< InstructionAddress > exitPoints_
Program exit points in a set.
CompiledSimController * controller_
Simulation controller.
SimulatorFrontend * frontend_
The simulator frontend.
const InstructionAddress entryAddress_
Entry address of the program.
MemorySystem * memorySystem() const
ProcedureBBRelations & procedureBBRelations_
A struct for finding out procedure begins from procedure's basic blocks.
const TTAMachine::Machine & machine_
The simulated machine.
ClockCycleCount * moveExecCounts_
Move execution counts in a C style table.
bool stopRequested_
Should the simulation stop or not?
SimulatorFrontend & frontend() const
const InstructionAddress lastInstruction_
Last instruction of the program.
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.
bool conflictDetected_
A flag for FU conflict detection.
ClockCycleCount * bbExecCounts_
Basic block execution counts in a C style table.
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?
int basicBlockCount_
Number of basic blocks gone through.
int moveCount() const
Definition Program.cc:494
virtual std::set< InstructionAddress > findProgramExitPoints(const TTAProgram::Program &program, const TTAMachine::Machine &machine) const

References bbExecCounts_, CompiledSimulationPimpl::controller_, CompiledSimulationPimpl::exitPoints_, TTASimulationController::findProgramExitPoints(), frontend(), CompiledSimulationPimpl::frontend_, machine_, memorySystem(), CompiledSimulationPimpl::memorySystem_, TTAProgram::Program::moveCount(), moveExecCounts_, pimpl_, and CompiledSimController::program().

Here is the call graph for this function:

◆ ~CompiledSimulation()

CompiledSimulation::~CompiledSimulation ( )
virtual

The destructor. Frees private implementation

Definition at line 120 of file CompiledSimulation.cc.

120 {
121 delete[] bbExecCounts_;
122 bbExecCounts_ = NULL;
123
124 delete[] moveExecCounts_;
125 moveExecCounts_ = NULL;
126
127 delete pimpl_;
128 pimpl_ = NULL;
129
130}

References bbExecCounts_, moveExecCounts_, and pimpl_.

◆ CompiledSimulation() [2/2]

CompiledSimulation::CompiledSimulation ( const CompiledSimulation )
private

Copying not allowed.

Member Function Documentation

◆ addFUResult() [1/2]

static void CompiledSimulation::addFUResult ( FUResultType results,
ClockCycleCount  cycleCount,
const SimValue value,
int  latency 
)
inlinestatic

◆ addFUResult() [2/2]

static void CompiledSimulation::addFUResult ( FUResultType results,
ClockCycleCount  cycleCount,
const UIntWord value,
int  latency 
)
inlinestatic

◆ addSymbol()

void CompiledSimulation::addSymbol ( const char *  symbolName,
SimValue value 
)
protected

Adds a new symbol name -> SimValue pair to the symbols map

Parameters
symbolNamethe symbol name
valuethe SimValue

Definition at line 597 of file CompiledSimulation.cc.

597 {
598 pimpl_->symbols_[std::string(symbolName)] = &value;
599}
Symbols symbols_
A Symbol map for easily getting the SimValues out of the simulation.

References pimpl_, and CompiledSimulationPimpl::symbols_.

◆ basicBlockStart()

InstructionAddress CompiledSimulation::basicBlockStart ( InstructionAddress  address) const
virtual

Returns start of the basic block for given address of a basic block

Parameters
addressaddress of a basic block
Returns
start address of the basic block

Definition at line 389 of file CompiledSimulation.cc.

389 {
390 return pimpl_->controller_->basicBlockStart(address);
391}
InstructionAddress basicBlockStart(InstructionAddress address) const

References CompiledSimController::basicBlockStart(), CompiledSimulationPimpl::controller_, and pimpl_.

Referenced by moveExecutionCount().

Here is the call graph for this function:

◆ clearFUResults()

static void CompiledSimulation::clearFUResults ( FUResultType results)
inlinestatic

◆ compileAndLoadFunction()

void CompiledSimulation::compileAndLoadFunction ( InstructionAddress  address)
protected

Compiles and loads all simulate functions belonging to a procedure containing the given address.

Parameters
address(any) address of a procedure to compile

Definition at line 535 of file CompiledSimulation.cc.

535 {
536
537 InstructionAddress procedureStart =
539
540 // Files compiled so far
541 std::set<std::string> compiledFiles;
542
544
545 // Get basic blocks of a procedure
546 typedef ProcedureBBRelations::BasicBlockStarts::iterator BBIterator;
547 std::pair<BBIterator, BBIterator> equalRange =
548 procedureBBRelations_.basicBlockStarts.equal_range(procedureStart);
549
550 // Loop all basic blocks of a procedure, then compile all its files
551 for (BBIterator it = equalRange.first; it != equalRange.second; ++it) {
552 std::string file = procedureBBRelations_.basicBlockFiles[it->second];
553
554 // Compile the file if it hasn't been already
555 if (compiledFiles.find(file) == compiledFiles.end()) {
557 std::string soPath = FileSystem::directoryOfPath(file)
559 + FileSystem::fileNameBody(file) + ".so";
561 compiledFiles.insert(file);
562 }
563
564 // Load the generated simulate function
567 symbolGen.basicBlockSymbol(it->second), fn);
568 setJumpTargetFunction(it->second, fn);
569 }
570}
UInt32 InstructionAddress
Definition BaseType.hh:175
void(* SimulateFunction)(void *engine)
Type for the simulateXXXXX basic block functions.
int compileToSO(const std::string &path, const std::string &flags="", bool verbose=false) const
CompiledSimCompiler compiler_
The Compiled Simulation compiler.
PluginTools pluginTools_
Plugintools used to load the compiled .so files.
void setJumpTargetFunction(InstructionAddress address, SimulateFunction fp)
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)
Definition FileSystem.cc:79
void importSymbol(const std::string &symbolName, T *&target, const std::string &module)
void registerModule(const std::string &module)
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.

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().

Here is the call graph for this function:

◆ cycleCount()

ClockCycleCount CompiledSimulation::cycleCount ( ) const
virtual

Returns the current cycle count

Returns
the current cycle count

Definition at line 242 of file CompiledSimulation.cc.

242 {
243 return cycleCount_;
244}

References cycleCount_.

◆ cycleEnd()

void CompiledSimulation::cycleEnd ( )
virtual

Lets the simulator frontend handle a single cycle end.

Used for example when generating traces.

Definition at line 138 of file CompiledSimulation.cc.

138 {
143}
void handleEvent(int event)
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
SimulationEventHandler & eventHandler()

References SimulatorFrontend::eventHandler(), CompiledSimulationPimpl::frontend_, Informer::handleEvent(), lastExecutedInstruction_, pimpl_, programCounter_, and SimulationEventHandler::SE_CYCLE_END.

Here is the call graph for this function:

◆ frontend()

SimulatorFrontend & CompiledSimulation::frontend ( ) const
protected

Returns a reference to the simulator frontend

Returns
a reference to the simulator frontend

Definition at line 440 of file CompiledSimulation.cc.

440 {
441 return *(pimpl_->frontend_);
442}

References CompiledSimulationPimpl::frontend_, and pimpl_.

Referenced by CompiledSimulation().

◆ FUMemory()

DirectAccessMemory & CompiledSimulation::FUMemory ( const char *  FUName) const
protected

Returns a memory object of the given function unit

Parameters
FUNamename of the function unit
Returns
memory object of the given function unit
Exceptions
InstanceNotFoundIf an item is not found

Definition at line 413 of file CompiledSimulation.cc.

413 {
414 assert(
415 machine_.functionUnitNavigator().item(FUName)->addressSpace() != NULL);
416 return
417 dynamic_cast<DirectAccessMemory&>(
420 FUName)->addressSpace()).get());
421}
#define assert(condition)
MemoryPtr memory(const TTAMachine::AddressSpace &as)
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380

References assert, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MemorySystem::memory(), and memorySystem().

Here is the call graph for this function:

◆ functionUnit()

TTAMachine::FunctionUnit & CompiledSimulation::functionUnit ( const char *  name) const
protected

Returns a function unit of the given name

Parameters
namename of the function unit to return
Returns
function unit of given name
Exceptions
InstanceNotFoundIf a function unit is not found

Definition at line 401 of file CompiledSimulation.cc.

401 {
402 return *machine_.functionUnitNavigator().item(name);
403}

References TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and machine_.

Referenced by FUPortValue().

Here is the call graph for this function:

◆ FUPortValue()

SimValue CompiledSimulation::FUPortValue ( const char *  fuName,
const char *  portName 
)
virtual

Returns the value of the given FU port

Parameters
fuNameName of the FU
portIndexindex of the port in the FU
Returns
A SimValue containing the port's present value
Exceptions
InstanceNotFoundIf the FU port cannot be found

Definition at line 306 of file CompiledSimulation.cc.

306 {
307
309 FunctionUnit* fu = NULL;
310 try {
311 fu = &functionUnit(fuName);
312 } catch(InstanceNotFound& e) {
313 fu = machine_.controlUnit();
314 }
315
316 std::string fuPort = symbolGen.portSymbol(*fu->port(portName));
317
318 CompiledSimulationPimpl::Symbols::const_iterator fuPortIterator =
319 pimpl_->symbols_.find(fuPort);
320 if (fuPortIterator != pimpl_->symbols_.end()) {
321 return *(fuPortIterator->second);
322 } else {
323 throw InstanceNotFound(__FILE__, __LINE__, __func__,
324 "FU port " + std::string(fuPort) + " not found.");
325 }
326}
#define __func__
TTAMachine::FunctionUnit & functionUnit(const char *name) const
virtual BaseFUPort * port(const std::string &name) const
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References __func__, CompiledSimulationPimpl::controller_, TTAMachine::Machine::controlUnit(), functionUnit(), machine_, pimpl_, TTAMachine::FunctionUnit::port(), CompiledSimSymbolGenerator::portSymbol(), CompiledSimulationPimpl::symbols_, and Conversion::toString().

Here is the call graph for this function:

◆ FUResult()

static void CompiledSimulation::FUResult ( SimValue target,
FUResultType results,
ClockCycleCount  cycles 
)
inlinestatic

◆ getSimulateFunction()

SimulateFunction CompiledSimulation::getSimulateFunction ( InstructionAddress  address)
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.

Parameters
addressaddress to get the simulate function for
Returns
Simulate Function of given address from the jump table
Exceptions
SimulationExecutionErrorIf the jump function couldn't be gotten

Definition at line 494 of file CompiledSimulation.cc.

494 {
495
496 // Is there an already existing simulate function in the given address?
497 SimulateFunction targetFunction = pimpl_->jumpTable_[address];
498 if (targetFunction != 0) {
499 return targetFunction;
500 }
501
503 compileAndLoadFunction(address);
504 targetFunction = pimpl_->jumpTable_[address];
505 if (targetFunction != 0) {
506 return targetFunction;
507 }
508 }
509
510 throw SimulationExecutionError(__FILE__, __LINE__, __FUNCTION__,
511 "Cannot simulate jump to address " + Conversion::toString(address) +
512 ". Please try with the interpretive simulation engine." );
513}
JumpTable jumpTable_
The jump table.
void compileAndLoadFunction(InstructionAddress address)

References compileAndLoadFunction(), dynamicCompilation_, CompiledSimulationPimpl::jumpTable_, pimpl_, and Conversion::toString().

Here is the call graph for this function:

◆ getSymbolValue()

SimValue * CompiledSimulation::getSymbolValue ( const char *  symbolName)
protected

Returns value of the given symbol (be it RF, FU, or IU)

Parameters
symbolNameSymbol name in the generated code
Returns
a pointer to the symbol's SimValue or 0 if the symbol wasn't found

Definition at line 579 of file CompiledSimulation.cc.

579 {
580
581 CompiledSimulationPimpl::Symbols::iterator it = pimpl_->symbols_.find(
582 std::string(symbolName));
583
584 if (it != pimpl_->symbols_.end()) {
585 return it->second;
586 } else {
587 return 0;
588 }
589}

References pimpl_, and CompiledSimulationPimpl::symbols_.

◆ haltSimulation()

void CompiledSimulation::haltSimulation ( const char *  file,
int  line,
const char *  procedure,
const char *  message 
) const
protected

Halts simulation by throwing an exception with a message attached to it

Parameters
filefile where the exception happened, i.e. FILE
lineline where the exception happened, i.e. LINE
procedurefunction where the exception happened, i.e. FUNCTION
messagemessage to attach
Exceptions
SimulationExecutionErrorthrown always

Definition at line 464 of file CompiledSimulation.cc.

468 {
469 throw SimulationExecutionError(file, line, procedure, message);
470}

◆ immediateUnitRegisterValue()

SimValue CompiledSimulation::immediateUnitRegisterValue ( const char *  iuName,
int  index 
)
virtual

Returns the value of the selected immediate unit register

Parameters
iuNameThe name of the immediate unit
indexIndex of the immediate register
Returns
A SimValue containing the present immediate register value
Exceptions
InstanceNotFoundIf the immediate unit cannot be found

Definition at line 280 of file CompiledSimulation.cc.

280 {
281
284 std::string immediateUnit = symbolGen.immediateRegisterSymbol(
285 iu, index);
286
287 CompiledSimulationPimpl::Symbols::const_iterator iuIterator =
288 pimpl_->symbols_.find(immediateUnit);
289 if (iuIterator != pimpl_->symbols_.end()) {
290 return *(iuIterator->second);
291 } else {
292 throw InstanceNotFound(__FILE__, __LINE__, __func__,
293 "Immediate unit " + std::string(iuName) + " not found.");
294 }
295}
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416

References __func__, CompiledSimulationPimpl::controller_, CompiledSimSymbolGenerator::immediateRegisterSymbol(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, pimpl_, CompiledSimulationPimpl::symbols_, and Conversion::toString().

Here is the call graph for this function:

◆ isFinished()

bool CompiledSimulation::isFinished ( ) const
virtual

Returns true if the simulation is finished

Returns
true if the simulation is finished

Definition at line 354 of file CompiledSimulation.cc.

354 {
355 return isFinished_;
356}

References isFinished_.

◆ lastExecutedInstruction()

InstructionAddress CompiledSimulation::lastExecutedInstruction ( ) const
virtual

Returns address of the last executed instruction

Returns
Address of the last executed instruction

Definition at line 233 of file CompiledSimulation.cc.

233 {
235}

References lastExecutedInstruction_.

◆ memorySystem()

MemorySystem * CompiledSimulation::memorySystem ( ) const
protected

Returns a pointer to the memory system

Returns
a pointer to the memory system

Definition at line 429 of file CompiledSimulation.cc.

429 {
430 assert (pimpl_->memorySystem_ != NULL);
431 return pimpl_->memorySystem_;
432}

References assert, CompiledSimulationPimpl::memorySystem_, and pimpl_.

Referenced by CompiledSimulation(), and FUMemory().

◆ moveExecutionCount()

ClockCycleCount CompiledSimulation::moveExecutionCount ( int  moveNumber,
InstructionAddress  address 
) const
virtual

Returns move execution count for move #moveNumber.

Parameters
moveNumbermove number as in POM
Returns
move execution count

Definition at line 365 of file CompiledSimulation.cc.

367 {
369 InstructionAddress programStartAddress = program.startAddress().location();
370 const Move& move = program.moveAt(moveNumber);
371
372 if (move.isUnconditional() && pimpl_->exitPoints_.find(address) ==
373 pimpl_->exitPoints_.end()) {
374 // Grab the whole basic block execution count
375 InstructionAddress bbStart = basicBlockStart(address -
376 programStartAddress);
377 return bbExecCounts_[bbStart];
378 } else { // guarded move or an exit point, grab single move execution count
379 return moveExecCounts_[moveNumber];
380 }
381}
find Finds info of the inner loops in the program
virtual InstructionAddress basicBlockStart(InstructionAddress address) const
InstructionAddress location() const
bool isUnconditional() const
Definition Move.cc:154
Address startAddress() const
Definition Program.cc:286

References basicBlockStart(), bbExecCounts_, CompiledSimulationPimpl::controller_, CompiledSimulationPimpl::exitPoints_, TTAProgram::Move::isUnconditional(), TTAProgram::Address::location(), moveExecCounts_, pimpl_, program, CompiledSimController::program(), and TTAProgram::Program::startAddress().

Referenced by CompiledSimUtilizationStats::calculate().

Here is the call graph for this function:

◆ msg()

void CompiledSimulation::msg ( const char *  message) const
protected

A short cut for printing debugging info from the compiled code.

Parameters
messageThe message string to be shown on the log stream

Definition at line 450 of file CompiledSimulation.cc.

450 {
451 Application::logStream() << message << std::endl;
452}
static std::ostream & logStream()

References Application::logStream().

Referenced by next().

Here is the call graph for this function:

◆ next()

void CompiledSimulation::next ( int  count)
virtual

Throws an exception since this feature is not supported yet!

Exceptions
SimulationExecutionErroralways thrown

Definition at line 170 of file CompiledSimulation.cc.

170 {
171
172 std::string msg(
173 "Command nexti not yet supported in the compiled simulation!");
174 throw SimulationExecutionError(__FILE__, __LINE__, __FUNCTION__, msg);
175
176 if (count) {}
177}
void msg(const char *message) const

References msg().

Here is the call graph for this function:

◆ operator=()

CompiledSimulation & CompiledSimulation::operator= ( const CompiledSimulation )
private

Assignment not allowed.

◆ programCounter()

InstructionAddress CompiledSimulation::programCounter ( ) const
virtual

Returns the value of the current PC

Returns
the value of the current PC

Definition at line 223 of file CompiledSimulation.cc.

223 {
224 return programCounter_;
225}

References programCounter_.

◆ registerFileValue()

SimValue CompiledSimulation::registerFileValue ( const char *  rfName,
int  registerIndex 
)
virtual

Returns the value of the selected register

Parameters
rfNameThe name of the register file
registerIndexindex of the register in the RF
Returns
A SimValue containing the present register value
Exceptions
InstanceNotFoundIf the RF cannot be found

Definition at line 255 of file CompiledSimulation.cc.

255 {
256
259 std::string registerFile = symbolGen.registerSymbol(rf, registerIndex);
260
261 CompiledSimulationPimpl::Symbols::const_iterator rfIterator =
262 pimpl_->symbols_.find(registerFile);
263 if (rfIterator != pimpl_->symbols_.end()) {
264 return *(rfIterator->second);
265 } else {
266 throw InstanceNotFound(__FILE__, __LINE__, __func__,
267 "Register file " + std::string(rfName) + " not found.");
268 }
269}
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450

References __func__, CompiledSimulationPimpl::controller_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, pimpl_, TTAMachine::Machine::registerFileNavigator(), CompiledSimSymbolGenerator::registerSymbol(), CompiledSimulationPimpl::symbols_, and Conversion::toString().

Here is the call graph for this function:

◆ requestToStop()

void CompiledSimulation::requestToStop ( )
virtual

Sets the simulation to be requested to stop

Definition at line 332 of file CompiledSimulation.cc.

332 {
333 stopRequested_ = true;
334}

References stopRequested_.

◆ resizeJumpTable()

void CompiledSimulation::resizeJumpTable ( int  newSize)
protected

Resizes the jump table

Parameters
newSizeNew size

Definition at line 478 of file CompiledSimulation.cc.

478 {
479 pimpl_->jumpTable_.resize(newSize, 0);
480}

References CompiledSimulationPimpl::jumpTable_, and pimpl_.

◆ run()

void CompiledSimulation::run ( )
virtual

Runs the simulation until it is finished or an exception occurs

Note
Advances only at an accuracy of a one basic block!
Parameters
addressAn address the simulation is allowed to stop after
Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.

Definition at line 189 of file CompiledSimulation.cc.

189 {
191 stopRequested_ = false;
192 while (!isFinished_ && !stopRequested_) {
194 }
195}
virtual void simulateCycle()=0

References cyclesToSimulate_, isFinished_, MAX_CYCLES, simulateCycle(), and stopRequested_.

Here is the call graph for this function:

◆ runUntil()

void CompiledSimulation::runUntil ( UIntWord  address)
virtual

Advance the simulation until a given address is reached

Note
Advances only at an accuracy of a one basic block!
Parameters
addressAn address the simulation is allowed to stop after
Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.

Definition at line 207 of file CompiledSimulation.cc.

207 {
209 stopRequested_ = false;
210 while ((!stopRequested_ && !isFinished_ &&
211 (jumpTarget_ != address || cycleCount_ == 0))) {
213 }
214}

References cycleCount_, cyclesToSimulate_, isFinished_, jumpTarget_, MAX_CYCLES, simulateCycle(), and stopRequested_.

Here is the call graph for this function:

◆ setJumpTargetFunction()

void CompiledSimulation::setJumpTargetFunction ( InstructionAddress  address,
SimulateFunction  fp 
)
protected

Sets a jump target function for given address at the jump table

Parameters
addressaddress to set a jump function for
fpfunction pointer to set at the address

Definition at line 522 of file CompiledSimulation.cc.

524 {
525 pimpl_->jumpTable_[address] = fp;
526}

References CompiledSimulationPimpl::jumpTable_, and pimpl_.

Referenced by compileAndLoadFunction().

◆ simulateCycle()

virtual void CompiledSimulation::simulateCycle ( )
pure virtual

Referenced by run(), runUntil(), and step().

◆ step()

void CompiledSimulation::step ( double  count)
virtual

Advance the simulation by a given amout of cycles.

Note
Advances only at an accuracy of a one basic block!
Parameters
countThe number of cycles the simulation should be advanced at least
Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.

Definition at line 155 of file CompiledSimulation.cc.

155 {
156 cyclesToSimulate_ = cycleCount_ + static_cast<ClockCycleCount>(count);
157 stopRequested_ = false;
158
159 while (!stopRequested_ && !isFinished_) {
161 }
162}

References cycleCount_, cyclesToSimulate_, isFinished_, simulateCycle(), and stopRequested_.

Here is the call graph for this function:

◆ stopRequested()

bool CompiledSimulation::stopRequested ( ) const
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.

Returns
true if the simulation should stop

Definition at line 345 of file CompiledSimulation.cc.

345 {
346 return stopRequested_;
347}

References stopRequested_.

Member Data Documentation

◆ basicBlockCount_

int CompiledSimulation::basicBlockCount_

Number of basic blocks gone through.

Definition at line 164 of file CompiledSimulation.hh.

◆ bbExecCounts_

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().

◆ conflictDetected_

bool CompiledSimulation::conflictDetected_

A flag for FU conflict detection.

Definition at line 184 of file CompiledSimulation.hh.

◆ cycleCount_

ClockCycleCount CompiledSimulation::cycleCount_

Number of cycles simulated so far.

Definition at line 162 of file CompiledSimulation.hh.

Referenced by cycleCount(), runUntil(), and step().

◆ cyclesToSimulate_

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().

◆ dynamicCompilation_

bool CompiledSimulation::dynamicCompilation_
protected

Is this a dynamic compiled simulation?

Definition at line 236 of file CompiledSimulation.hh.

Referenced by getSimulateFunction().

◆ entryAddress_

const InstructionAddress CompiledSimulation::entryAddress_
protected

Entry address of the program.

Definition at line 245 of file CompiledSimulation.hh.

◆ isFinished_

bool CompiledSimulation::isFinished_

Is the simulation finished?

Definition at line 176 of file CompiledSimulation.hh.

Referenced by isFinished(), run(), runUntil(), and step().

◆ jumpTarget_

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().

◆ jumpTargetFunc_

SimulateFunction CompiledSimulation::jumpTargetFunc_

Next jump target as a function pointer" << endl.

Definition at line 181 of file CompiledSimulation.hh.

◆ lastExecutedInstruction_

InstructionAddress CompiledSimulation::lastExecutedInstruction_

Last executed instruction.

Definition at line 170 of file CompiledSimulation.hh.

Referenced by cycleEnd(), and lastExecutedInstruction().

◆ lastInstruction_

const InstructionAddress CompiledSimulation::lastInstruction_
protected

Last instruction of the program.

Definition at line 247 of file CompiledSimulation.hh.

◆ machine_

const TTAMachine::Machine& CompiledSimulation::machine_
protected

◆ moveExecCounts_

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_

OperationPool CompiledSimulation::operationPool_

The operation pool.

Definition at line 179 of file CompiledSimulation.hh.

◆ pimpl_

CompiledSimulationPimpl* CompiledSimulation::pimpl_
private

◆ procedureBBRelations_

ProcedureBBRelations& CompiledSimulation::procedureBBRelations_
protected

A struct for finding out procedure begins from procedure's basic blocks.

Definition at line 239 of file CompiledSimulation.hh.

Referenced by compileAndLoadFunction().

◆ programCounter_

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().

◆ stopRequested_

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().


The documentation for this class was generated from the following files: