OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
SimulatorFrontend Class Reference

#include <SimulatorFrontend.hh>

Inheritance diagram for SimulatorFrontend:
Inheritance graph
Collaboration diagram for SimulatorFrontend:
Collaboration graph

Public Types

enum  RuntimeErrorSeverity { RES_MINOR , RES_FATAL }
 The severities of runtime errors. More...
 
enum  SimulationType {
  SIM_NORMAL , SIM_COMPILED , SIM_REMOTE , SIM_CUSTOM ,
  SIM_OTA
}
 Which type of simulation this SimulatorFrontend controls or connects to. More...
 

Public Member Functions

 SimulatorFrontend (SimulationType backend=SIM_NORMAL)
 
virtual ~SimulatorFrontend ()
 
virtual void loadProgram (const std::string &fileName)
 
virtual void loadMachine (const std::string &fileName)
 
void loadProgram (const TTAProgram::Program &program)
 
void loadMachine (const TTAMachine::Machine &machine)
 
void loadProcessorConfiguration (const std::string &fileName)
 
const TTAMachine::Machinemachine () const
 
const TTAProgram::Programprogram () const
 
const SimValuestateValue (std::string searchString)
 
StateDatastate (std::string searchString)
 
MachineStatemachineState (int core=-1)
 
virtual void next (int count=1)
 
virtual void step (double count=1)
 
virtual void run ()
 
virtual void runUntil (UIntWord address)
 
void prepareToStop (StopReason reason)
 
unsigned int stopReasonCount () const
 
StopReason stopReason (unsigned int index) const
 
bool stoppedByUser () const
 
virtual void killSimulation ()
 
StopPointManagerstopPointManager ()
 
MemorySystemmemorySystem (int coreId=-1)
 
bool isSimulationInitialized () const
 
bool isSimulationRunning () const
 
bool isSimulationStopped () const
 
bool isProgramLoaded () const
 
bool isMachineLoaded () const
 
bool hasSimulationEnded () const
 
bool isCompiledSimulation () const
 
bool isTCEDebugger () const
 
bool isCustomDebugger () const
 
void setCompiledSimulationLeaveDirty (bool dirty)
 
bool executionTracing () const
 
bool busTracing () const
 
bool rfAccessTracing () const
 
bool procedureTransferTracing () const
 
bool profileDataSaving () const
 
bool utilizationDataSaving () const
 
bool staticCompilation () const
 
const RFAccessTrackerrfAccessTracker () const
 
void setCompiledSimulation (bool value)
 
void setExecutionTracing (bool value)
 
void setBusTracing (bool value)
 
void setRFAccessTracing (bool value)
 
void setProcedureTransferTracing (bool value)
 
void setProfileDataSaving (bool value)
 
void setUtilizationDataSaving (bool value)
 
void forceTraceDBFileName (const std::string &fileName)
 
void setTimeout (unsigned int value)
 
void setStaticCompilation (bool value)
 
std::ostream & outputStream ()
 
void setOutputStream (std::ostream &stream)
 
std::string disassembleInstruction (UIntWord instructionAddress) const
 
std::string programLocationDescription () const
 
InstructionAddress programCounter () const
 
virtual InstructionAddress lastExecutedInstruction (int coreId=-1) const
 
ClockCycleCount cycleCount () const
 
const TTAProgram::ProcedurecurrentProcedure () 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)
 
StateDatafindRegister (const std::string &rfName, int registerIndex)
 
StateDatafindBooleanRegister ()
 
StateDatafindPort (const std::string &fuName, const std::string &portName)
 
const UtilizationStatsutilizationStatistics (int core=-1)
 
const ExecutableInstructionlastExecInstruction () const
 
const ExecutableInstructionexecutableInstructionAt (InstructionAddress address) const
 
bool automaticFinishImpossible () const
 
void setFUResourceConflictDetection (bool value)
 
bool fuResourceConflictDetection () const
 
void setNextInstructionPrinting (bool value)
 
bool nextInstructionPrinting () const
 
void setSimulationTimeStatistics (bool value)
 
bool simulationTimeStatistics () const
 
ExecutionTracelastTraceDB (int core=-1)
 
void setMemoryAccessTracking (bool value)
 
bool memoryAccessTracking () const
 
void finishSimulation ()
 
void setZeroFillMemoriesOnReset (bool val)
 
void setDetailedSimulation (bool val)
 
CycleCount lastRunCycleCount () const
 
SimulationEventHandlereventHandler ()
 
double lastRunTime () const
 
void reportSimulatedProgramError (RuntimeErrorSeverity severity, const std::string &description)
 
std::string programErrorReport (RuntimeErrorSeverity severity, std::size_t index)
 
std::size_t programErrorReportCount (RuntimeErrorSeverity severity)
 
void clearProgramErrorReports ()
 
int selectedCore () const
 
void selectCore (int core)
 
bool compareState (SimulatorFrontend &other, std::ostream *differences=NULL)
 
std::size_t callHistoryLength () const
 
void setCallHistoryLength (std::size_t length)
 
const CallPathTrackercallPathTracker (int core=-1) const
 
void initializeDataMemories (const TTAMachine::AddressSpace *onlyOne=NULL)
 

Protected Types

typedef std::pair< RuntimeErrorSeverity, std::string > ProgramErrorDescription
 A type for storing a program error description.
 
typedef std::vector< ProgramErrorDescriptionProgramErrorDescriptionList
 Container for simulated program error descriptions.
 

Protected Member Functions

virtual void initializeSimulation ()
 
void initializeTracing ()
 
void initializeDisassembler () const
 
void initializeMemorySystem ()
 
void setControllerForMemories (RemoteController *con)
 
bool hasStopReason (StopReason reason) const
 
void startTimer ()
 
void stopTimer ()
 
void setupCallHistoryTracking ()
 

Protected Attributes

const TTAMachine::MachinecurrentMachine_
 Machine to run simulation with.
 
TTASimulationControllersimCon_
 If simulation is initialized, this contains a pointer to the simulation controller.
 
bool machineOwnedByFrontend_
 Is the machine owned by SimulatorFrontend or by the client?
 
const TTAProgram::ProgramcurrentProgram_
 Program to be simulated.
 
std::string programFileName_
 The source file of the program to be simulated. Used to generate the file name of the trace data base.
 
bool programOwnedByFrontend_
 Is the program owned by SimulatorFrontend or by the client?
 
SimulationType currentBackend_
 Type of "backend" this Frontend has.
 
POMDisassemblerdisassembler_
 The disassembler used to print out instructions. This is initialized on demand.
 
bool executionTracing_
 Is execution tracing, i.e., storing the executed instruction addresses to the trace database, enabled.
 
bool busTracing_
 Is bus tracing, i.e., storing the values of buses in each clock cycle enabled.
 
bool rfAccessTracing_
 Is register file (concurrent) access tracking enabled.
 
bool procedureTransferTracing_
 Is procedure transfer access tracking enabled.
 
bool saveProfileData_
 Is saving of profile data to TraceDB enabled.
 
bool saveUtilizationData_
 Is saving of utilization data to TraceDB enabled.
 
std::vector< ExecutionTrace * > traceDBs_
 The database to use for execution trace data.
 
std::vector< bool > traceDBOwned_
 Whether traceDB at index is owned by simulator (or taken away by client using lastTraceDB())
 
std::vector< ExecutionTracker * > executionTrackers_
 The simple execution tracker for storing trace of executed instructions.
 
std::vector< BusTracker * > busTrackers_
 The tracker for saving bus trace.
 
std::vector< RFAccessTracker * > rfAccessTrackers_
 The register file access tracker.
 
std::vector< ProcedureTransferTracker * > procedureTransferTrackers_
 The procedure transfer tracker.
 
StopPointManagerstopPointManager_
 The breakpoint manager to be used to bookkeep breakpoints.
 
std::vector< UtilizationStats * > utilizationStats_
 Processor utilization statistics.
 
TPEF::Binarytpef_
 The source TPEF file.
 
bool fuResourceConflictDetection_
 If this is enabled before initialization, FU resource conflicts are detected (slows down simulation).
 
bool printNextInstruction_
 If true, the next simulated instructions is printed to stdout when simulation stops.
 
bool printSimulationTimeStatistics_
 True if the simulation time statistics should be printed out.
 
bool staticCompilation_
 True if the compiled simulation should use static compilation.
 
bool traceFileNameSetByUser_
 Flag that indicates is the trace file name set by user.
 
std::ostream * outputStream_
 Default output stream.
 
bool memoryAccessTracking_
 If this is enabled before initialization, memory access tracking is enabled. (slows down simulation)
 
SimulationEventHandlereventHandler_
 Per simulation instance of SimulationEventHandler.
 
ClockCycleCount lastRunCycleCount_
 The cycle count of the last non-interrupted simulation phase.
 
double lastRunTime_
 The wall clock time of the last non-interrupted simulation phase in seconds.
 
std::time_t startTime_
 The time of the last simulation start. Used to compute simulation speed.
 
CycleCount startCycleCount_
 The cycle count when the latest simulation was started. Used to compute simulation speed.
 
unsigned int simulationTimeout_
 Simulation timeout in seconds.
 
ProgramErrorDescriptionList programErrorReports_
 Runtime error reports.
 
bool leaveCompiledDirty_
 True in case the compilation simulation should not cleanup at destruction the engine source files.
 
std::size_t callHistoryLength_
 The length of call history to store in memory for the commands that need it.
 
std::vector< CallPathTracker * > callPathTrackers_
 The call path trackers for each core, in case tracking is enabled.
 
std::string forcedTraceDBFileName_
 If set, forces the SQLite filename of trace DB to this name.
 
std::vector< MemorySystem * > memorySystems_
 The simulation models of the memories in the currently loaded machine for each core.
 
bool zeroFillMemoriesOnReset_
 Set to true in case the memories should be set to zero at reset.
 
bool detailedSimulation_
 Set to true in case should build a detailed model which simulates FU stages, possibly with an external system-level model.
 

Friends

void timeoutThread (unsigned int timeout, SimulatorFrontend *simFE)
 

Detailed Description

Frontend to simulator functionality.

User interfaces use this class as the access point to simulation functionality. It acts as a "facade" hiding the complexity of simulator engine. Error messages of exceptions thrown by the methods of this class are generated using SimulatorTextGenerator, thus they can be used in user interfaces directly.

Definition at line 88 of file SimulatorFrontend.hh.

Member Typedef Documentation

◆ ProgramErrorDescription

typedef std::pair<RuntimeErrorSeverity, std::string> SimulatorFrontend::ProgramErrorDescription
protected

A type for storing a program error description.

Definition at line 287 of file SimulatorFrontend.hh.

◆ ProgramErrorDescriptionList

Container for simulated program error descriptions.

Definition at line 289 of file SimulatorFrontend.hh.

Member Enumeration Documentation

◆ RuntimeErrorSeverity

The severities of runtime errors.

Enumerator
RES_MINOR 

Minor runtime error, no abort necessary.

RES_FATAL 

Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go on with the simulation.

Definition at line 92 of file SimulatorFrontend.hh.

92 {
93 RES_MINOR, ///< Minor runtime error, no abort necessary.
94 RES_FATAL ///< Fatal runtime error, there is a serious error in the
95 /// simulated program, thus it makes no sense to go on
96 /// with the simulation.
RuntimeErrorSeverity
The severities of runtime errors.
@ RES_FATAL
Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go ...
@ RES_MINOR
Minor runtime error, no abort necessary.

◆ SimulationType

Which type of simulation this SimulatorFrontend controls or connects to.

Enumerator
SIM_NORMAL 

Default, interpreted simulation (debugging engine).

SIM_COMPILED 

Compiled, faster simulation.

SIM_REMOTE 

Remote debugger, not a simulator at all.

SIM_CUSTOM 

User-implemented remote HW debugger.

SIM_OTA 

Simulation with operation-triggered implicit data transports.

Definition at line 100 of file SimulatorFrontend.hh.

100 {
101 SIM_NORMAL, ///< Default, interpreted simulation (debugging engine).
102 SIM_COMPILED, ///< Compiled, faster simulation.
103 SIM_REMOTE, ///< Remote debugger, not a simulator at all
104 SIM_CUSTOM, ///< User-implemented remote HW debugger
105 SIM_OTA ///< Simulation with operation-triggered implicit data
106 /// transports.
SimulationType
Which type of simulation this SimulatorFrontend controls or connects to.
@ SIM_REMOTE
Remote debugger, not a simulator at all.
@ SIM_CUSTOM
User-implemented remote HW debugger.
@ SIM_OTA
Simulation with operation-triggered implicit data transports.
@ SIM_COMPILED
Compiled, faster simulation.
@ SIM_NORMAL
Default, interpreted simulation (debugging engine).

Constructor & Destructor Documentation

◆ SimulatorFrontend()

SimulatorFrontend::SimulatorFrontend ( SimulationType  backendType = SIM_NORMAL)

Constructor.

Definition at line 120 of file SimulatorFrontend.cc.

120 :
121 currentMachine_(NULL), simCon_(NULL),
124 currentBackend_(backendType),
125 disassembler_(NULL), executionTracing_(false),
126 busTracing_(false),
129 stopPointManager_(NULL), tpef_(NULL),
136
137 if (backendType == SIM_COMPILED) {
139 setFUResourceConflictDetection(false); // disabled by default
141 } else {
143 }
144}
void setFUResourceConflictDetection(bool value)
TTASimulationController * simCon_
If simulation is initialized, this contains a pointer to the simulation controller.
POMDisassembler * disassembler_
The disassembler used to print out instructions. This is initialized on demand.
bool saveUtilizationData_
Is saving of utilization data to TraceDB enabled.
std::ostream * outputStream_
Default output stream.
bool traceFileNameSetByUser_
Flag that indicates is the trace file name set by user.
bool busTracing_
Is bus tracing, i.e., storing the values of buses in each clock cycle enabled.
bool printNextInstruction_
If true, the next simulated instructions is printed to stdout when simulation stops.
bool executionTracing_
Is execution tracing, i.e., storing the executed instruction addresses to the trace database,...
void setCompiledSimulation(bool value)
bool programOwnedByFrontend_
Is the program owned by SimulatorFrontend or by the client?
SimulationType currentBackend_
Type of "backend" this Frontend has.
double lastRunTime_
The wall clock time of the last non-interrupted simulation phase in seconds.
bool procedureTransferTracing_
Is procedure transfer access tracking enabled.
ClockCycleCount lastRunCycleCount_
The cycle count of the last non-interrupted simulation phase.
std::string programFileName_
The source file of the program to be simulated. Used to generate the file name of the trace data base...
bool staticCompilation_
True if the compiled simulation should use static compilation.
const TTAProgram::Program * currentProgram_
Program to be simulated.
const TTAMachine::Machine * currentMachine_
Machine to run simulation with.
bool saveProfileData_
Is saving of profile data to TraceDB enabled.
TPEF::Binary * tpef_
The source TPEF file.
bool zeroFillMemoriesOnReset_
Set to true in case the memories should be set to zero at reset.
bool memoryAccessTracking_
If this is enabled before initialization, memory access tracking is enabled. (slows down simulation)
StopPointManager * stopPointManager_
The breakpoint manager to be used to bookkeep breakpoints.
bool leaveCompiledDirty_
True in case the compilation simulation should not cleanup at destruction the engine source files.
std::size_t callHistoryLength_
The length of call history to store in memory for the commands that need it.
bool machineOwnedByFrontend_
Is the machine owned by SimulatorFrontend or by the client?
SimulationEventHandler * eventHandler_
Per simulation instance of SimulationEventHandler.
bool printSimulationTimeStatistics_
True if the simulation time statistics should be printed out.
bool fuResourceConflictDetection_
If this is enabled before initialization, FU resource conflicts are detected (slows down simulation).
unsigned int simulationTimeout_
Simulation timeout in seconds.
bool rfAccessTracing_
Is register file (concurrent) access tracking enabled.
static SimulatorTextGenerator & textGenerator()

References SimulatorTextGenerator::generateCompiledSimTexts(), setCompiledSimulation(), setFUResourceConflictDetection(), SIM_COMPILED, and SimulatorToolbox::textGenerator().

Here is the call graph for this function:

◆ ~SimulatorFrontend()

SimulatorFrontend::~SimulatorFrontend ( )
virtual

Destructor.

Definition at line 149 of file SimulatorFrontend.cc.

149 {
150
152
154 delete currentMachine_;
155 currentMachine_ = NULL;
156 }
157
159 delete currentProgram_;
160 currentProgram_ = NULL;
161 programFileName_ = "";
162 }
163
164 delete disassembler_;
165 disassembler_ = NULL;
166 delete simCon_;
167 simCon_ = NULL;
168 delete stopPointManager_;
169 stopPointManager_ = NULL;
170 delete tpef_;
171 tpef_ = NULL;
172 delete eventHandler_;
173 eventHandler_ = NULL;
174 delete simCon_;
175 simCon_ = NULL;
177
179
180}
static void deleteAllItems(SequenceType &aSequence)
std::vector< MemorySystem * > memorySystems_
The simulation models of the memories in the currently loaded machine for each core.

References clearProgramErrorReports(), currentMachine_, currentProgram_, SequenceTools::deleteAllItems(), disassembler_, eventHandler_, finishSimulation(), machineOwnedByFrontend_, memorySystems_, programFileName_, programOwnedByFrontend_, simCon_, stopPointManager_, and tpef_.

Here is the call graph for this function:

Member Function Documentation

◆ automaticFinishImpossible()

bool SimulatorFrontend::automaticFinishImpossible ( ) const

Returns true in case simulation with the currently loaded program cannot be finished automatically.

In order for this method to return false, it means that while loading the simulated program, 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.

Returns
True if it's not possible to end simulation automatically.

Definition at line 2230 of file SimulatorFrontend.cc.

2230 {
2231 return simCon_ != NULL && simCon_->automaticFinishImpossible();
2232}
virtual bool automaticFinishImpossible() const

References TTASimulationController::automaticFinishImpossible(), and simCon_.

Referenced by ProgCommand::execute().

Here is the call graph for this function:

◆ busTracing()

bool SimulatorFrontend::busTracing ( ) const

Returns true in case bus tracing is enabled.

Returns
True in case bus tracing is enabled.

Definition at line 1808 of file SimulatorFrontend.cc.

1808 {
1809 return busTracing_;
1810}

References busTracing_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ callHistoryLength()

std::size_t SimulatorFrontend::callHistoryLength ( ) const
inline

Definition at line 266 of file SimulatorFrontend.hh.

266{ return callHistoryLength_; }

References callHistoryLength_.

Referenced by BackTraceCommand::execute().

◆ callPathTracker()

const CallPathTracker & SimulatorFrontend::callPathTracker ( int  core = -1) const

Definition at line 2393 of file SimulatorFrontend.cc.

2393 {
2394 assert(callPathTrackers_.size() > 0);
2395 if (core == -1) {
2396 return *callPathTrackers_.at(selectedCore());
2397 } else {
2398 return *callPathTrackers_.at(core);
2399 }
2400}
#define assert(condition)
std::vector< CallPathTracker * > callPathTrackers_
The call path trackers for each core, in case tracking is enabled.

References assert, callPathTrackers_, and selectedCore().

Referenced by BackTraceCommand::execute().

Here is the call graph for this function:

◆ clearProgramErrorReports()

void SimulatorFrontend::clearProgramErrorReports ( )

Clears the runtime error report list.

Definition at line 2360 of file SimulatorFrontend.cc.

2360 {
2361 programErrorReports_.clear();
2362}
ProgramErrorDescriptionList programErrorReports_
Runtime error reports.

References programErrorReports_.

Referenced by RuntimeErrorReporter::handleEvent(), ProximRuntimeErrorHandler::handleEvent(), and ~SimulatorFrontend().

◆ compareState()

bool SimulatorFrontend::compareState ( SimulatorFrontend other,
std::ostream *  differences = NULL 
)

Compares the states of two simulator engines.

This is useful in debugging bugs in an simulator engine implementation. It assumes the engines have been stepped equal amount of instruction cycles and, thus, the TTA programmer visible context should be equal.

Parameters
otherA frontend to the other engine to compare this one to.
differencesAn optional output stream where to output information of the possible differences.
Returns
true in case the states are equal, false otherwise.

Definition at line 2415 of file SimulatorFrontend.cc.

2416 {
2417
2418 static InstructionAddress previousPC = 0;
2419
2420 if (programCounter() != other.programCounter()) {
2421 if (differences != NULL)
2422 *differences
2423 << "SIMULATION ERROR DETECTED (PCs DIFFER)" << std::endl
2424 << "--------------------------------------" << std::endl
2425 << " cycle: " << cycleCount() << std::endl
2426 << " other's PC: " << other.programCounter() << std::endl
2427 << " this' PC: " << programCounter() << std::endl;
2428 return false;
2429 }
2430
2431 bool errorLocationPrinted = false;
2432 bool equal = true;
2433
2436 for (int i = 0; i < rfNav.count(); ++i) {
2437 TTAMachine::RegisterFile& rf = *rfNav.item(i);
2438 for (int reg = 0; reg < rf.size(); ++reg) {
2439 std::string thisReg =
2440 registerFileValue(rf.name(), reg);
2441 std::string otherReg =
2442 other.registerFileValue(rf.name(), reg);
2443 if (thisReg != otherReg) {
2444 equal = false;
2445 if (!errorLocationPrinted && differences != NULL) {
2446 std::string procedureName =
2447 (dynamic_cast<TTAProgram::Procedure&>(
2449
2450 *differences
2451 << "DIFFERING REGISTER FILE VALUES" << std::endl
2452 << "------------------------------" << std::endl
2453 << " cycle: " << cycleCount() << std::endl
2454 << " PC: " << programCounter() << std::endl
2455 << "previous PC: " << previousPC << std::endl
2456 << " function: " << procedureName << std::endl
2457 << "disassembly around previous PC:" << std::endl;
2458 int start =
2459 std::max(0, (int)previousPC - 5);
2460 int end = previousPC + 5;
2461 for (int instr = start; instr <= end; ++instr) {
2462 if (instr == (int)previousPC)
2463 *differences << "==> ";
2464 *differences
2466 program().instructionAt(instr),
2467 true)
2468 << std::endl;
2469 }
2470 errorLocationPrinted = true;
2471 }
2472 if (differences != NULL)
2473 *differences
2474 << rf.name() << "." << reg << ": "
2475 << thisReg << " (this) vs. "
2476 << otherReg << " (other)" << std::endl;
2477 }
2478 }
2479 }
2480
2481 errorLocationPrinted = false;
2482
2485 for (int i = 0; i < fuNav.count(); ++i) {
2486 TTAMachine::FunctionUnit& fu = *fuNav.item(i);
2487
2488 for (int port = 0; port < fu.portCount(); ++port) {
2489 // skip output ports as compiled sim is not exact with them at BB boundaries
2490 if (fu.port(port)->isOutput())
2491 continue;
2492 std::string portName = fu.port(port)->name();
2493 DisassemblyFUPort portString(fu.name(), portName);
2494 SimValue thisReg =
2495 FUPortValue(fu.name(), portName);
2496 SimValue otherReg =
2497 other.FUPortValue(fu.name(), portName);
2498 if (thisReg.intValue() != otherReg.intValue()) {
2499 equal = false;
2500 if (!errorLocationPrinted && differences != NULL) {
2501 std::string procedureName =
2502 (dynamic_cast<TTAProgram::Procedure&>(
2504
2505 *differences
2506 << "DIFFERING FUNCTION UNIT PORT VALUES" << std::endl
2507 << "-----------------------------------" << std::endl
2508 << " cycle: " << cycleCount() << std::endl
2509 << " PC: " << programCounter() << std::endl
2510 << "previous PC: " << previousPC << std::endl
2511 << " function: " << procedureName << std::endl
2512 << "disassembly around previous PC:" << std::endl;
2513 int start =
2514 std::max(0, (int)previousPC - 5);
2515 int end = previousPC + 5;
2516 for (int instr = start; instr <= end; ++instr) {
2517 if (instr == (int)previousPC)
2518 *differences << "==> ";
2519 *differences
2521 program().instructionAt(instr), true)
2522 << std::endl;
2523 }
2524 errorLocationPrinted = true;
2525 }
2526 if (differences != NULL)
2527 *differences
2528 << portString.toString() << ": "
2529 << thisReg.intValue() << " (this) vs. "
2530 << otherReg.intValue() << " (other)" << std::endl;
2531 }
2532
2533 }
2534
2535
2536 }
2537
2538 previousPC = programCounter();
2539
2540 return equal;
2541}
UInt32 InstructionAddress
Definition BaseType.hh:175
static std::string disassemble(const TTAProgram::Move &move)
int intValue() const
Definition SimValue.cc:895
const TTAMachine::Machine & machine() const
virtual std::string registerFileValue(const std::string &rfName, int registerIndex=-1)
ClockCycleCount cycleCount() const
const TTAProgram::Program & program() const
virtual SimValue FUPortValue(const std::string &fuName, const std::string &portName)
InstructionAddress programCounter() const
virtual int size() const
virtual TCEString name() const
virtual BaseFUPort * port(const std::string &name) const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual bool isOutput() const
Definition Port.cc:308
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135
CodeSnippet & parent() const
Instruction & instructionAt(InstructionAddress address) const
Definition Program.cc:374

References TTAMachine::Machine::Navigator< ComponentType >::count(), cycleCount(), POMDisassembler::disassemble(), TTAMachine::Machine::functionUnitNavigator(), FUPortValue(), TTAProgram::Program::instructionAt(), SimValue::intValue(), TTAMachine::Port::isOutput(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), TTAMachine::Component::name(), TTAMachine::Port::name(), TTAProgram::Instruction::parent(), TTAMachine::FunctionUnit::port(), TTAMachine::Unit::portCount(), program(), programCounter(), TTAMachine::Machine::registerFileNavigator(), registerFileValue(), TTAMachine::BaseRegisterFile::size(), and DisassemblyFUPort::toString().

Referenced by tandemSimulate().

Here is the call graph for this function:

◆ currentProcedure()

const Procedure & SimulatorFrontend::currentProcedure ( ) const

Returns the current procedure.

The current procedure is expected to be the nearest procedure behind the program counter.

Returns
The current procedure.
Todo:
Throw exception if simulation is not initialized

Definition at line 1210 of file SimulatorFrontend.cc.

1210 {
1211 assert(simCon_ != NULL);
1212 assert(currentProgram_ != NULL);
1214 if (address > currentProgram_->lastInstruction().address().location()) {
1216 } else {
1217 return dynamic_cast<const Procedure&>(
1219 }
1220}
InstructionAddress location() const
Address address() const
Instruction & lastInstruction() const
Definition Program.cc:463
Procedure & lastProcedure() const
Definition Program.cc:230

References TTAProgram::Instruction::address(), assert, currentProgram_, TTAProgram::Program::instructionAt(), TTAProgram::Program::lastInstruction(), TTAProgram::Program::lastProcedure(), TTAProgram::Address::location(), TTAProgram::Instruction::parent(), programCounter(), and simCon_.

Referenced by DisassembleCommand::execute().

Here is the call graph for this function:

◆ cycleCount()

ClockCycleCount SimulatorFrontend::cycleCount ( ) const

◆ disassembleInstruction()

std::string SimulatorFrontend::disassembleInstruction ( UIntWord  instructionAddress) const

Returns the disassembly of instruction at given address.

Parameters
instructionAddressAddress (index) of the instruction wanted to disassemble.
Returns
Disassembly of an instruction.
Todo:
print all labels associated at address

Definition at line 1073 of file SimulatorFrontend.cc.

1073 {
1074
1075 const Instruction& theInstruction =
1076 currentProgram_->instructionAt(instructionAddress);
1077 const Procedure& currentProc = dynamic_cast<const Procedure&>(
1078 theInstruction.parent());
1079
1080 bool firstInstructionInProcedure =
1081 (currentProc.startAddress().location() == instructionAddress);
1082
1083 std::string disassembly = "";
1084
1085 /// @todo print all labels associated at address
1086
1087 if (firstInstructionInProcedure) {
1088 disassembly += "\n" + currentProc.name() + ":\n";
1089 }
1090
1092
1093 disassembly +=
1094 Conversion::toString(instructionAddress) + ":\t\t" +
1095 disassembler_->disassembleInstruction(theInstruction);
1096 return disassembly;
1097}
static std::string toString(const T &source)
virtual TCEString disassembleInstruction(const TTAProgram::Instruction &instruction, int addr=-1)
"Template methods" that can be overridden in the derived assemblers.
void initializeDisassembler() const
virtual Address startAddress() const
TCEString name() const
Definition Procedure.hh:66

References currentProgram_, POMDisassembler::disassembleInstruction(), disassembler_, initializeDisassembler(), TTAProgram::Program::instructionAt(), TTAProgram::Address::location(), TTAProgram::Procedure::name(), TTAProgram::Instruction::parent(), TTAProgram::CodeSnippet::startAddress(), and Conversion::toString().

Referenced by DisassembleCommand::execute().

Here is the call graph for this function:

◆ eventHandler()

SimulationEventHandler & SimulatorFrontend::eventHandler ( )

Returns the instance of SimulationEventHandler.

Returns
The instance of SimulationEventHandler.
Todo:
This should probably be an inline function as it used to be in the SimulatorToolbox class...

Definition at line 2260 of file SimulatorFrontend.cc.

2260 {
2261 if (eventHandler_ == NULL) {
2263 }
2264 return *eventHandler_;
2265}

References eventHandler_.

Referenced by BusTracker::BusTracker(), BusTracker::BusTracker(), CompiledSimulation::cycleEnd(), ExecutionTracker::ExecutionTracker(), initializeSimulation(), CompiledSimController::next(), SimulationController::next(), ProcedureTransferTracker::ProcedureTransferTracker(), ProcedureTransferTracker::ProcedureTransferTracker(), ProximRuntimeErrorHandler::ProximRuntimeErrorHandler(), MemoryProxy::read(), SimpleSimulatorFrontend::registerEventListener(), reportSimulatedProgramError(), RFAccessTracker::RFAccessTracker(), CompiledSimController::run(), SimulationController::run(), RuntimeErrorReporter::RuntimeErrorReporter(), CompiledSimController::runUntil(), SimulationController::runUntil(), OTASimulationController::simulateCycle(), SimulationController::simulateCycle(), CompiledSimController::step(), SimulationController::step(), SimpleSimulatorFrontend::unregisterEventListener(), MemoryProxy::write(), BusTracker::~BusTracker(), ExecutionTracker::~ExecutionTracker(), ProcedureTransferTracker::~ProcedureTransferTracker(), ProximRuntimeErrorHandler::~ProximRuntimeErrorHandler(), RFAccessTracker::~RFAccessTracker(), and RuntimeErrorReporter::~RuntimeErrorReporter().

◆ executableInstructionAt()

const ExecutableInstruction & SimulatorFrontend::executableInstructionAt ( InstructionAddress  address) const

Returns reference to the instruction at given address.

Returns
Instruction at the given address.

Definition at line 2208 of file SimulatorFrontend.cc.

2209 {
2210
2211 assert(simCon_ != NULL);
2212 const InstructionMemory& memory = dynamic_cast<SimulationController*>(
2213 simCon_)->instructionMemory();
2214 return memory.instructionAtConst(address);
2215}
const ExecutableInstruction & instructionAtConst(InstructionAddress address) const

References assert, InstructionMemory::instructionAtConst(), and simCon_.

Referenced by DisasmExecPercentageAttrProvider::moveCellAttr(), DisasmTopCountAttrProvider::moveCellAttr(), DesignSpaceExplorer::simulate(), and DisasmTopCountAttrProvider::updateTopCountTable().

Here is the call graph for this function:

◆ executionTracing()

bool SimulatorFrontend::executionTracing ( ) const

Returns true in case execution tracing is enabled.

Returns
True in case execution tracing is enabled.

Definition at line 1798 of file SimulatorFrontend.cc.

1798 {
1799 return executionTracing_;
1800}

References executionTracing_.

Referenced by SimulatorSettingsDialog::onOK(), CompiledSimController::reset(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ findBooleanRegister()

StateData & SimulatorFrontend::findBooleanRegister ( )

Finds the state connected to the boolean register.

Currently boolean register is expected to be the first register in a register file with only one register of width 1.

Todo:
Improve evaluation when the correct way is known.
Returns
State connected to the bool register.
Exceptions
InstanceNotFoundIf bool register cannot be found.

Definition at line 709 of file SimulatorFrontend.cc.

709 {
710 assert(currentMachine_ != NULL);
711
714
715 // go through all the register files in the machine
716 for (int i = 0; i < navigator.count(); ++i) {
717 RegisterFile* rf = navigator.item(i);
718 if (rf->width() == 1 && rf->numberOfRegisters() == 1) {
719 RegisterFileState& rfState =
721 return rfState.registerState(0);
722 }
723 }
724
725 throw InstanceNotFound(
726 __FILE__, __LINE__, __func__, "No boolean register found.");
727}
#define __func__
RegisterFileState & registerFileState(const std::string &name)
virtual RegisterState & registerState(int index)
MachineState & machineState(int core=-1)
virtual int numberOfRegisters() const
virtual int width() const

References __func__, assert, TTAMachine::Machine::Navigator< ComponentType >::count(), currentMachine_, TTAMachine::Machine::Navigator< ComponentType >::item(), machineState(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Machine::registerFileNavigator(), MachineState::registerFileState(), RegisterFileState::registerState(), and TTAMachine::BaseRegisterFile::width().

Referenced by state().

Here is the call graph for this function:

◆ findPort()

StateData & SimulatorFrontend::findPort ( const std::string &  fuName,
const std::string &  portName 
)

Finds the port using a search string.

The search string supported currently is of format {function unit name].{port name}.

Parameters
fuNameThe name of the operation or the function unit.
portNameThe name of the operand or the port.
Returns
State connected to the register.
Exceptions
InstanceNotFoundIf the register cannot be found.
Todo:
Get the list of control operations from GCU instead of hard coding like this

Definition at line 819 of file SimulatorFrontend.cc.

820 {
821 assert(currentMachine_ != NULL);
822
823 const std::string exceptionMessage =
824 std::string("No port ") + fuName + "." + portName + " found.";
825
826 // first try to fetch the port from GCU
827 PortState& foundState =
829 portName, currentMachine_->controlUnit()->name());
830
831 if (&foundState != &NullPortState::instance()) {
832 return foundState;
833 }
834
835 /// @todo Get the list of control operations from GCU instead of
836 /// hard coding like this
837 if (StringTools::ciEqual(fuName, "call") ||
838 StringTools::ciEqual(fuName, "jump")) {
839
840 // we'll try converting the port name to an operand number
841 int operandNumber = -1;
842 try {
843 operandNumber = Conversion::toInt(portName);
844 } catch (const NumberFormatException&) {
845 // portName was not a number, we cannot find it in the
846 // GCU for sure
847 throw InstanceNotFound(
848 __FILE__, __LINE__, __func__, exceptionMessage);
849 }
850
851 // it's a control flow operand, we should get the port from GCU
852 return machineState().portState(
854 operandNumber)->name(),
856 }
857
858 return machineState().portState(
861 throw InstanceNotFound(
862 __FILE__, __LINE__, __func__, exceptionMessage);
863}
static int toInt(const T &source)
PortState & portState(const std::string &portName, const std::string &fuName)
static NullPortState & instance()
Definition PortState.cc:96
static std::string stringToLower(const std::string &source)
static bool ciEqual(const std::string &a, const std::string &b)
virtual HWOperation * operation(const std::string &name) const
virtual FUPort * port(int operand) const
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References __func__, assert, StringTools::ciEqual(), TTAMachine::Machine::controlUnit(), currentMachine_, NullPortState::instance(), machineState(), TTAMachine::Component::name(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::HWOperation::port(), MachineState::portState(), StringTools::stringToLower(), and Conversion::toInt().

Referenced by state().

Here is the call graph for this function:

◆ findRegister()

StateData & SimulatorFrontend::findRegister ( const std::string &  rfName,
int  registerIndex 
)

Finds the state connected to a register.

Todo:
Improve evaluation when the parallel assembler syntax is known.
Parameters
rfNameThe name of the register file.
registerIndexIndex of the register in the register file.
Returns
State connected to the register.
Exceptions
InstanceNotFoundIf the register cannot be found.

Definition at line 785 of file SimulatorFrontend.cc.

785 {
786 assert(currentMachine_ != NULL);
787
790
791 std::string regFileName = rfName;
792 if (!navigator.hasItem(rfName)) {
793 throw InstanceNotFound(
794 __FILE__, __LINE__, __func__,
795 "Register file " + rfName + " not found.");
796 }
797 try {
799 regFileName).registerState(registerIndex);
800 } catch (const OutOfRange&) {
801 throw InstanceNotFound(
802 __FILE__, __LINE__, __func__,
803 "Register index out of range");
804 }
805}
bool hasItem(const std::string &name) const

References __func__, assert, currentMachine_, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), machineState(), TTAMachine::Machine::registerFileNavigator(), MachineState::registerFileState(), and RegisterFileState::registerState().

Referenced by SimulationController::registerFileValue().

Here is the call graph for this function:

◆ finishSimulation()

void SimulatorFrontend::finishSimulation ( )

Finishes the currently running simulation.

Flushes any simulation traces etc., but does not unload nor dealloacate the loaded machine and the program. This is to allow restarting the simulation without needing to reinitialize the machine and program.

Definition at line 1538 of file SimulatorFrontend.cc.

1538 {
1539
1540 if (simCon_ == NULL)
1541 return;
1542
1544 if (traceDBs_.size() == 0)
1545 return;
1546
1547 for (int core = 0; core < 1; ++core) {
1548 // flush the concurrent RF access trace data
1549 ExecutionTrace* traceDB = traceDBs_.at(core);
1550 if (rfAccessTracing_) {
1552 assert(rfAccessTracker != NULL);
1555 for (RFAccessTracker::ConcurrentRFAccessIndex::const_iterator i =
1556 accesses.begin(); i != accesses.end(); ++i) {
1557 const RFAccessTracker::ConcurrentRFAccess& access = (*i).first;
1558 const std::string& rfName = access.get<0>();
1559 const std::size_t& reads = access.get<2>();
1560 const std::size_t& writes = access.get<1>();
1561 const ClockCycleCount& count = (*i).second;
1563 rfName, reads, writes, count);
1564 }
1565 }
1566
1568 const UtilizationStats& stats = utilizationStatistics(core);
1569 // save the function unit operation execution counts
1572 for (int i = 0; i <= fuNav.count(); ++i) {
1573 TTAMachine::FunctionUnit* fu = NULL;
1574 if (i < fuNav.count())
1575 fu = fuNav.item(i);
1576 else
1577 fu = machine().controlUnit();
1578 assert(fu != NULL);
1579 const ClockCycleCount totalTriggersOfFU =
1580 stats.triggerCount(fu->name());
1581
1582 if (totalTriggersOfFU == 0)
1583 continue;
1584
1585 for (int j = 0; j < fu->operationCount(); ++j) {
1586 const TTAMachine::HWOperation* op = fu->operation(j);
1587 assert(op != NULL);
1588 const std::string operationUpper =
1590
1591 const ClockCycleCount executions =
1592 stats.operationExecutions(fu->name(), operationUpper);
1593
1594 if (executions == 0)
1595 continue;
1596
1598 fu->name(), operationUpper, executions);
1599 }
1600 }
1601
1602
1603 // save the socket write counts
1604 const TTAMachine::Machine::SocketNavigator& socketNav =
1606 for (int i = 0; i < socketNav.count(); ++i) {
1607
1608 TTAMachine::Socket* socket = socketNav.item(i);
1609 assert(socket != NULL);
1610 const ClockCycleCount writes =
1611 stats.socketWrites(socket->name());
1612
1613 traceDB->addSocketWriteCount(socket->name(), writes);
1614 }
1615
1616 // save the bus write counts
1617 const TTAMachine::Machine::BusNavigator& busNav =
1619 for (int i = 0; i < busNav.count(); ++i) {
1620 TTAMachine::Bus* bus = busNav.item(i);
1621 assert(bus != NULL);
1622 const ClockCycleCount writes = stats.busWrites(bus->name());
1623
1624 traceDB->addBusWriteCount(bus->name(), writes);
1625 }
1626
1627 // save the register access stats
1630 for (int i = 0; i < rfNav.count(); ++i) {
1631 TTAMachine::RegisterFile* rf = rfNav.item(i);
1632 assert(rf != NULL);
1633
1634 int maxRegs = 0;
1635 maxRegs = rf->numberOfRegisters();
1636 for (int reg = 0; reg < maxRegs; ++reg) {
1637 ClockCycleCount reads =
1638 stats.registerReads(rf->name(), reg);
1639 ClockCycleCount writes =
1640 stats.registerWrites(rf->name(), reg);
1641 traceDB->addRegisterAccessCount(
1642 rf->name(), reg, reads, writes);
1643 }
1644 }
1645
1646 }
1647
1648 if (saveProfileData_) {
1649
1650 // save the instruction execution counts (profile data)
1651 const InstructionMemory& instructions =
1652 dynamic_cast<SimulationController*>(simCon_)->
1653 instructionMemory(core);
1654
1655 InstructionAddress firstAddress =
1657 InstructionAddress lastAddress =
1660
1661 for (InstructionAddress a = firstAddress; a <= lastAddress; ++a) {
1663 a, instructions.instructionAtConst(a).executionCount());
1664 }
1665 }
1666
1668 // save the start addresses of procedures in order to provide
1669 // possibility for more readable query outputs with traces
1670 // that include procedure data in them
1671 for (int i = 0; i < currentProgram_->procedureCount(); ++i) {
1672 const Procedure& procedure = currentProgram_->procedure(i);
1673 traceDB->addProcedureAddressRange(
1674 procedure.startAddress().location(),
1675 procedure.endAddress().location() - 1, procedure.name());
1676 }
1677 }
1678
1680
1681 if (traceDBOwned_[core]) {
1682 delete traceDBs_[core];
1683 traceDBs_[core]=NULL;
1684 }
1685 }
1686
1692}
CycleCount ClockCycleCount
Alias for ClockCycleCount.
ClockCycleCount executionCount() const
void addFunctionUnitOperationTriggerCount(FunctionUnitID functionUnit, OperationID operation, OperationTriggerCount count)
void addConcurrentRegisterFileAccessCount(RegisterFileID registerFile, RegisterAccessCount reads, RegisterAccessCount writes, ClockCycleCount count)
void addProcedureAddressRange(InstructionAddress firstAddress, InstructionAddress lastAddress, const std::string &procedureName)
void addBusWriteCount(BusID socket, ClockCycleCount count)
void addInstructionExecutionCount(InstructionAddress address, ClockCycleCount count)
void addRegisterAccessCount(RegisterFileID registerFile, RegisterID registerIndex, ClockCycleCount reads, ClockCycleCount writes)
void setSimulatedCycleCount(ClockCycleCount count)
void addSocketWriteCount(SocketID socket, ClockCycleCount)
boost::tuple< std::string, std::size_t, std::size_t > ConcurrentRFAccess
type to be used as a key for storing concurrent access info
const ConcurrentRFAccessIndex & accessDataBase() const
std::map< ConcurrentRFAccess, ClockCycleCount > ConcurrentRFAccessIndex
concurrent accesses and their counts
const UtilizationStats & utilizationStatistics(int core=-1)
std::vector< UtilizationStats * > utilizationStats_
Processor utilization statistics.
std::vector< ExecutionTrace * > traceDBs_
The database to use for execution trace data.
const RFAccessTracker & rfAccessTracker() const
std::vector< bool > traceDBOwned_
Whether traceDB at index is owned by simulator (or taken away by client using lastTraceDB())
std::vector< BusTracker * > busTrackers_
The tracker for saving bus trace.
std::vector< ProcedureTransferTracker * > procedureTransferTrackers_
The procedure transfer tracker.
std::vector< ExecutionTracker * > executionTrackers_
The simple execution tracker for storing trace of executed instructions.
std::vector< RFAccessTracker * > rfAccessTrackers_
The register file access tracker.
static std::string stringToUpper(const std::string &source)
virtual int operationCount() const
const std::string & name() const
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
virtual Address endAddress() const
Procedure & procedure(int index) const
Definition Program.cc:622
Address startAddress() const
Definition Program.cc:286
int procedureCount() const
Definition Program.cc:610
ClockCycleCount busWrites(const std::string &busName) const
ClockCycleCount operationExecutions(const std::string &operationName) const
ClockCycleCount triggerCount(const std::string &fuName) const
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
ClockCycleCount socketWrites(const std::string &socketName) const

References RFAccessTracker::accessDataBase(), ExecutionTrace::addBusWriteCount(), ExecutionTrace::addConcurrentRegisterFileAccessCount(), ExecutionTrace::addFunctionUnitOperationTriggerCount(), ExecutionTrace::addInstructionExecutionCount(), ExecutionTrace::addProcedureAddressRange(), ExecutionTrace::addRegisterAccessCount(), TTAProgram::Instruction::address(), ExecutionTrace::addSocketWriteCount(), assert, TTAMachine::Machine::busNavigator(), busTrackers_, UtilizationStats::busWrites(), callPathTrackers_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), currentProgram_, cycleCount(), SequenceTools::deleteAllItems(), TTAProgram::CodeSnippet::endAddress(), ExecutableInstruction::executionCount(), executionTrackers_, TTAMachine::Machine::functionUnitNavigator(), InstructionMemory::instructionAtConst(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAProgram::Program::lastInstruction(), TTAProgram::Address::location(), machine(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAProgram::Procedure::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), UtilizationStats::operationExecutions(), TTAProgram::Program::procedure(), TTAProgram::Program::procedureCount(), procedureTransferTracing_, procedureTransferTrackers_, TTAMachine::Machine::registerFileNavigator(), UtilizationStats::registerReads(), UtilizationStats::registerWrites(), rfAccessTracing_, rfAccessTracker(), rfAccessTrackers_, saveProfileData_, saveUtilizationData_, ExecutionTrace::setSimulatedCycleCount(), simCon_, TTAMachine::Machine::socketNavigator(), UtilizationStats::socketWrites(), TTAProgram::CodeSnippet::startAddress(), TTAProgram::Program::startAddress(), StringTools::stringToUpper(), traceDBOwned_, traceDBs_, UtilizationStats::triggerCount(), utilizationStatistics(), and utilizationStats_.

Referenced by ProximSimulationThread::finishSimulation(), killSimulation(), loadMachine(), loadMachine(), and ~SimulatorFrontend().

Here is the call graph for this function:

◆ forceTraceDBFileName()

void SimulatorFrontend::forceTraceDBFileName ( const std::string &  fileName)
inline

Definition at line 177 of file SimulatorFrontend.hh.

177 {
178 forcedTraceDBFileName_ = fileName;
179 }
std::string forcedTraceDBFileName_
If set, forces the SQLite filename of trace DB to this name.

References forcedTraceDBFileName_.

Referenced by DesignSpaceExplorer::simulate().

◆ FUPortValue()

SimValue SimulatorFrontend::FUPortValue ( const std::string &  fuName,
const std::string &  portName 
)
virtual

Returns the current value of a FU port

Parameters
fuNamename of the function unit
portNamename of the FU port
Returns
Current value of a FU port

Definition at line 767 of file SimulatorFrontend.cc.

768 {
769 assert(currentMachine_ != NULL);
770
771 return simCon_->FUPortValue(fuName, portName);
772}
virtual SimValue FUPortValue(const std::string &fuName, const std::string &portName)=0

References assert, currentMachine_, TTASimulationController::FUPortValue(), and simCon_.

Referenced by compareState(), and InfoPortsCommand::execute().

Here is the call graph for this function:

◆ fuResourceConflictDetection()

bool SimulatorFrontend::fuResourceConflictDetection ( ) const

Returns true if FU resource conflict detection is on, false if not.

Returns
Returns current fu conflict detection setting.

Definition at line 2032 of file SimulatorFrontend.cc.

2032 {
2034}

References fuResourceConflictDetection_.

Referenced by SimulatorSettingsDialog::onOK(), CompiledSimController::reset(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ hasSimulationEnded()

bool SimulatorFrontend::hasSimulationEnded ( ) const

Returns true if the simulation has ended, that is, the last instruction have been executed.

Returns
True if simulation has ended.

Definition at line 1283 of file SimulatorFrontend.cc.

1283 {
1284 return (simCon_ != NULL &&
1286}
virtual SimulationStatus state() const
@ STA_FINISHED
Simulation ended after executing the last instruction.

References simCon_, TTASimulationController::STA_FINISHED, and TTASimulationController::state().

Referenced by ProximKillCmd::isEnabled(), SimpleSimulatorFrontend::isFinished(), programLocationDescription(), ProximBreakpointWindow::ProximBreakpointWindow(), ProximPortWindow::ProximPortWindow(), ProximRegisterWindow::ProximRegisterWindow(), ProximBreakpointWindow::refreshStopPoints(), SimpleSimulatorFrontend::step(), tandemSimulate(), and ProximMainFrame::updateSimulationStatus().

Here is the call graph for this function:

◆ hasStopReason()

bool SimulatorFrontend::hasStopReason ( StopReason  reason) const
protected

Helper function which tells whether simulation has stopped because of the given reason.

Returns
True if the given reason was one of the reasons the simulation was stopped.

Definition at line 1369 of file SimulatorFrontend.cc.

1369 {
1370
1371 if (simCon_ == NULL) {
1372 return false;
1373 }
1374
1375 for (size_t i = 0; i < stopReasonCount(); ++i) {
1376 if (stopReason(i) == reason) {
1377 return true;
1378 }
1379 }
1380 return false;
1381}
unsigned int stopReasonCount() const
StopReason stopReason(unsigned int index) const

References simCon_, stopReason(), and stopReasonCount().

Referenced by stoppedByUser().

Here is the call graph for this function:

◆ immediateUnitRegisterValue()

SimValue SimulatorFrontend::immediateUnitRegisterValue ( const std::string &  iuName,
int  index = -1 
)
virtual

Returns the current value of a IU register

Parameters
iuNamename of the immediate unit
indexindex of the register
Returns
Current value of a IU register

Definition at line 752 of file SimulatorFrontend.cc.

753 {
754 assert(currentMachine_ != NULL);
755
756 return simCon_->immediateUnitRegisterValue(iuName, index);
757}
virtual SimValue immediateUnitRegisterValue(const std::string &iuName, int index=-1)=0

References assert, currentMachine_, TTASimulationController::immediateUnitRegisterValue(), and simCon_.

Here is the call graph for this function:

◆ initializeDataMemories()

void SimulatorFrontend::initializeDataMemories ( const TTAMachine::AddressSpace onlyOne = NULL)

Resets and writes initial data to the memory system stored in simulation controller from loaded TPEF.

Parameters
onlyOneinitialize the data memory of the given address space only. If onlyOne is NULL, tries to intialize all data memories.

Definition at line 440 of file SimulatorFrontend.cc.

441 {
442
443 // we need tpef to get the initialization data and simcon to fetch
444 // the memory system from
445 if (currentProgram_ == NULL || simCon_ == NULL)
446 return;
447
451
452 const int dataSections = currentProgram_->dataMemoryCount();
453
454 if (dataSections < 0)
455 return;
456
457 for (int core = 0; core < 1; ++core) {
458 // data memory initialization
459 for (int i = 0; i < dataSections; ++i) {
460
461 // initialize the data memory
462 const DataMemory& data = currentProgram_->dataMemory(i);
463 const std::string addressSpaceName =
464 data.addressSpace().name();
465
466 try {
467 MemorySystem::MemoryPtr dataMemory =
468 simCon_->memorySystem(core).memory(addressSpaceName);
469
470 const AddressSpace& addressSpace =
472 addressSpaceName);
473
474 if ((onlyOne != NULL && &addressSpace != onlyOne) ||
475 (addressSpace.isShared() && core != 0)) continue;
476
477 for (int d = 0; d < data.dataDefinitionCount(); ++d) {
478 const DataDefinition& def = data.dataDefinition(d);
479 if (!def.isInitialized()) {
480 continue;
481 }
482
483 Address startAddress = def.startAddress();
484 // Check that the defined data is inside the address
485 // space.
486 if (def.startAddress().space().name() !=
487 addressSpaceName ||
488 startAddress.location() < addressSpace.start() ||
489 (startAddress.location() + def.size() - 1)
490 > addressSpace.end()) {
491
492 throw IllegalProgram(
493 __FILE__, __LINE__, __func__,
494 std::string("Initialization data for ") +
495 addressSpace.name() +
496 " is out of address space bounds.");
497 }
498 for (int m = 0; m < def.size(); m++) {
499 dataMemory->write(
500 startAddress.location() + m, def.MAU(m));
501 }
502 }
503
504 } catch (const InstanceNotFound& inf) {
505 std::string errorMsg =
508 if (inf.errorMessage() != "")
509 errorMsg += " Reason: " + inf.errorMessage();
510 delete tpef_;
511 tpef_ = NULL;
512 delete simCon_;
513 simCon_ = NULL;
514 throw IllegalProgram(
515 __FILE__, __LINE__, __func__, errorMsg);
516 }
517 }
518 }
519}
std::string errorMessage() const
Definition Exception.cc:123
MemoryPtr memory(const TTAMachine::AddressSpace &as)
void fillAllMemoriesWithZero()
boost::shared_ptr< Memory > MemoryPtr
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
void resetAllMemories()
MemorySystem & memorySystem(int coreId=-1)
virtual ULongWord end() const
virtual bool isShared() const
virtual ULongWord start() const
const TTAMachine::AddressSpace & space() const
virtual Address startAddress() const
virtual bool isInitialized() const
virtual MinimumAddressableUnit MAU(int index) const
DataDefinition & dataDefinition(Address address) const
Definition DataMemory.cc:79
int dataDefinitionCount() const
const TTAMachine::AddressSpace & addressSpace() const
DataMemory & dataMemory(int index) const
Definition Program.cc:967
int dataMemoryCount() const
Definition Program.cc:942
virtual MemorySystem & memorySystem(int coreId=-1)
virtual boost::format text(int textId)
@ TXT_ILLEGAL_INPUT_FILE

References __func__, TTAProgram::DataMemory::addressSpace(), MemorySystem::addressSpace(), currentProgram_, TTAProgram::DataMemory::dataDefinition(), TTAProgram::DataMemory::dataDefinitionCount(), TTAProgram::Program::dataMemory(), TTAProgram::Program::dataMemoryCount(), TTAMachine::AddressSpace::end(), Exception::errorMessage(), MemorySystem::fillAllMemoriesWithZero(), TTAProgram::DataDefinition::isInitialized(), TTAMachine::AddressSpace::isShared(), TTAProgram::Address::location(), TTAProgram::DataDefinition::MAU(), MemorySystem::memory(), memorySystem(), TTASimulationController::memorySystem(), TTAMachine::Component::name(), MemorySystem::resetAllMemories(), simCon_, TTAProgram::DataDefinition::size(), TTAProgram::Address::space(), TTAMachine::AddressSpace::start(), TTAProgram::DataDefinition::startAddress(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), tpef_, Texts::TXT_ILLEGAL_INPUT_FILE, and zeroFillMemoriesOnReset_.

Referenced by SimpleSimulatorFrontend::initializeDataMemories(), killSimulation(), loadProgram(), and loadProgram().

Here is the call graph for this function:

◆ initializeDisassembler()

void SimulatorFrontend::initializeDisassembler ( ) const
protected

Initializes the disassembler.

Creates a new POMDisassembler for the loaded program if it was not loaded already.

Definition at line 1152 of file SimulatorFrontend.cc.

1152 {
1153
1154 if (disassembler_ != NULL || currentProgram_ == NULL) {
1155 // already initialized or no program to disassemble
1156 return;
1157 }
1160}
static POMDisassembler * disassembler(const TTAMachine::Machine &mach, const TTAProgram::Program &program)

References currentMachine_, currentProgram_, POMDisassembler::disassembler(), and disassembler_.

Referenced by disassembleInstruction(), and programLocationDescription().

Here is the call graph for this function:

◆ initializeMemorySystem()

void SimulatorFrontend::initializeMemorySystem ( )
protected

Initializes the memory system according to the address spaces in the loaded machine.

Definition at line 1699 of file SimulatorFrontend.cc.

1699 {
1700
1701 assert (currentMachine_ != NULL);
1703 MemorySystem* firstMemorySystem = NULL;
1704
1705 for (int core = 0; core < 1; ++core) {
1706
1707 MemorySystem* memorySystem_ = new MemorySystem(machine);
1708
1709 // create a memory system for the loaded machine by going
1710 // through all address spaces in the machine and create a memory model
1711 // for each of them, except for the one of GCU's
1713
1714 std::string controlUnitASName = "";
1715 if (machine.controlUnit() != NULL &&
1717 controlUnitASName = machine.controlUnit()->addressSpace()->name();
1718 }
1719
1720 for (int i = 0; i < nav.count(); ++i) {
1721 const AddressSpace& space = *nav.item(i);
1722
1723 if (space.name() == controlUnitASName)
1724 continue;
1725
1726 const bool shared = space.isShared();
1727
1729
1730 if (shared && firstMemorySystem != NULL) {
1731 // the memory model should have been created previously
1732 // because all cores share the same memory
1733 mem = firstMemorySystem->memory(space.name());
1734 assert(mem != NULL);
1735 } else {
1736 switch (currentBackend_) {
1737 case SIM_COMPILED:
1740 space.start(), space.end(), space.width(), machine.isLittleEndian()));
1741 break;
1742 case SIM_OTA:
1743 case SIM_NORMAL:
1745 new IdealSRAM(
1746 space.start(), space.end(), space.width(), machine.isLittleEndian()));
1747 break;
1748 case SIM_REMOTE:
1749 case SIM_CUSTOM:
1751 new RemoteMemory( space, machine.isLittleEndian()));
1752
1753 break;
1754 default:
1755 throw Exception(
1756 __FILE__, __LINE__, __func__,
1757 "Internal error: memory model not specified");
1758 }
1759 // If memory tracking is enabled, memories are wrapped by
1760 // a proxy that tracks memory access.
1763 new MemoryProxy(*this, mem.get()));
1764 }
1765 }
1766 memorySystem_->addAddressSpace(space, mem, shared);
1767 }
1768 memorySystems_.push_back(memorySystem_);
1769 if (firstMemorySystem == NULL)
1770 firstMemorySystem = memorySystem_;
1771 }
1772}
void addAddressSpace(const TTAMachine::AddressSpace &as, MemoryPtr mem, bool shared=true)
virtual int width() const
virtual AddressSpace * addressSpace() const
virtual bool hasAddressSpace() const
bool isLittleEndian() const
Definition Machine.hh:258
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

References __func__, MemorySystem::addAddressSpace(), TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::addressSpaceNavigator(), assert, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), currentBackend_, currentMachine_, TTAMachine::AddressSpace::end(), TTAMachine::FunctionUnit::hasAddressSpace(), TTAMachine::Machine::isLittleEndian(), TTAMachine::AddressSpace::isShared(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), MemorySystem::memory(), memoryAccessTracking_, memorySystems_, TTAMachine::Component::name(), SIM_COMPILED, SIM_CUSTOM, SIM_NORMAL, SIM_OTA, SIM_REMOTE, TTAMachine::AddressSpace::start(), and TTAMachine::AddressSpace::width().

Referenced by loadMachine(), and loadMachine().

Here is the call graph for this function:

◆ initializeSimulation()

void SimulatorFrontend::initializeSimulation ( )
protectedvirtual

Initializes a new simulation.

Creates the SimulationController and initializes the program counter to point to the first executed instruction. Assumes the simulation is not running and the possible old simulation data is freed.

Exceptions
ExceptionThere can be several types of exceptions thrown when building the simulation machine model or the preprocessed program.

Definition at line 657 of file SimulatorFrontend.cc.

657 {
658
659 delete simCon_;
660 simCon_ = NULL;
661 switch(currentBackend_) {
662 case SIM_REMOTE:
663 simCon_ =
664 new TCEDBGController(
667 break;
668 case SIM_CUSTOM:
669 simCon_ =
673 break;
674 case SIM_COMPILED:
675 simCon_ =
679 break;
680 case SIM_OTA:
681 simCon_ =
684 break;
685 case SIM_NORMAL:
686 default:
687 simCon_ =
691 }
692
693 delete stopPointManager_;
695}
SimulationEventHandler & eventHandler()
bool detailedSimulation_
Set to true in case should build a detailed model which simulates FU stages, possibly with an externa...
void setControllerForMemories(RemoteController *con)

References currentBackend_, currentMachine_, currentProgram_, detailedSimulation_, eventHandler(), fuResourceConflictDetection_, leaveCompiledDirty_, setControllerForMemories(), SIM_COMPILED, SIM_CUSTOM, SIM_NORMAL, SIM_OTA, SIM_REMOTE, simCon_, and stopPointManager_.

Referenced by loadProgram(), and loadProgram().

Here is the call graph for this function:

◆ initializeTracing()

void SimulatorFrontend::initializeTracing ( )
protected

Initializes the trace database(s).

In case no traces are enabled, this method does nothing. Making multiple calls to this method is not harmful.

Exceptions
IOExceptionIn case trace database file could not be accessed.
Note
May throw IOException.

Definition at line 1414 of file SimulatorFrontend.cc.

1414 {
1418
1419 int coreCount = 1;
1420
1421 traceDBs_.resize(coreCount, NULL);
1422 traceDBOwned_.resize(coreCount, true);
1423 executionTrackers_.resize(coreCount, NULL);
1424 rfAccessTrackers_.resize(coreCount, NULL);
1425 procedureTransferTrackers_.resize(coreCount, NULL);
1426 busTrackers_.resize(coreCount, NULL);
1427 for (int core = 0; core < 1; ++core) {
1428
1429 ExecutionTrace* traceDB = traceDBs_.at(core);
1430 // initialize the data base for each core
1431 if (traceDB == NULL) {
1432 TCEString traceFileName;
1433 if (forcedTraceDBFileName_ == "") {
1434 // generate the file name
1435
1436 TCEString coreMarker = "";
1437 if (coreCount > 1) {
1438 coreMarker << ".core";
1439 coreMarker << core;
1440 }
1442 if (coreCount > 1) {
1443 fname << ".core";
1444 fname << core;
1445 }
1446 fname << ".trace";
1447
1448 int runningNumber = 1;
1449 while (FileSystem::fileExists(fname)) {
1450 // append ".n" where n is a running number, in case the
1451 // file exists
1452 fname = programFileName_;
1453 if (coreCount > 1) {
1454 fname << ".core";
1455 fname << core;
1456 }
1457 fname << ".trace";
1458 fname << "." << runningNumber;
1459 ++runningNumber;
1460 }
1461 traceFileName = fname;
1462 } else {
1463 traceFileName = forcedTraceDBFileName_;
1464 }
1465
1466 /// @note May throw IOException.
1467 traceDB = ExecutionTrace::open(traceFileName);
1468 traceDBs_[core] = traceDB;
1469 traceDBOwned_[core] = true;
1470 }
1471
1472 ExecutionTracker* executionTracker = executionTrackers_.at(core);
1473 if (executionTracing_ && executionTracker == NULL) {
1474 executionTracker =
1475 new ExecutionTracker(*simCon_, *traceDB);
1476 executionTrackers_[core] = executionTracker;
1477 }
1478
1479 if (rfAccessTracing_) {
1480 rfAccessTrackers_[core] =
1481 new RFAccessTracker(
1482 *this,
1483 dynamic_cast<SimulationController*>(
1484 simCon_)->instructionMemory(core));
1485 }
1488 new ProcedureTransferTracker(*this, *traceDB);
1489 }
1490
1491 if (busTracing_) {
1492 // generate the file name
1493 TCEString busTraceFileName = programFileName_;
1494 if (coreCount > 1)
1495 busTraceFileName << ".core" << core;
1496
1497 busTraceFileName << ".bustrace";
1498
1499 int runningNumber = 1;
1500 while (FileSystem::fileExists(busTraceFileName)) {
1501 // append ".n" where n is a running number, in case the
1502 // file exists
1503
1504 busTraceFileName = programFileName_;
1505 if (coreCount > 1)
1506 busTraceFileName << ".core" << core;
1507
1508 busTraceFileName << ".bustrace";
1509 busTraceFileName << "." << runningNumber;
1510 ++runningNumber;
1511 }
1512
1513 std::ostream* busTraceStream =
1514 new std::ofstream(busTraceFileName.c_str(), std::ios::out);
1515 if (!busTraceStream) {
1516 std::string errorMessage =
1517 "Unable to open bus trace file " + busTraceFileName +
1518 " for writing.";
1519 throw IOException(
1520 __FILE__, __LINE__, __func__, errorMessage);
1521 }
1522 busTrackers_[core] =
1523 new BusTracker(*this, busTraceStream);
1524 }
1525 }
1526 }
1528}
static bool fileExists(const std::string fileName)

References __func__, busTracing_, busTrackers_, executionTracing_, executionTrackers_, FileSystem::fileExists(), forcedTraceDBFileName_, ExecutionTrace::open(), procedureTransferTracing_, procedureTransferTrackers_, programFileName_, rfAccessTracing_, rfAccessTrackers_, saveProfileData_, saveUtilizationData_, setupCallHistoryTracking(), simCon_, traceDBOwned_, and traceDBs_.

Referenced by killSimulation(), loadProgram(), and loadProgram().

Here is the call graph for this function:

◆ isCompiledSimulation()

bool SimulatorFrontend::isCompiledSimulation ( ) const

Returns true if the current simulation engine uses compiled simulation

Returns
true if the current simulation engine uses compiled simulation

Definition at line 1295 of file SimulatorFrontend.cc.

1295 {
1296 return currentBackend_ == SIM_COMPILED;
1297}

References currentBackend_, and SIM_COMPILED.

Referenced by loadMachine(), loadMachine(), loadProgram(), SimulatorCLI::SimulatorCLI(), and utilizationStatistics().

◆ isCustomDebugger()

bool SimulatorFrontend::isCustomDebugger ( ) const

Check if we are currently using a custom debugger. This returns true if we are attached to a FPGA or an ASIC with on-circuit debug hardware.

Returns
true if we are using a custom debugger target.

Definition at line 1317 of file SimulatorFrontend.cc.

1317 {
1318 return currentBackend_ == SIM_CUSTOM;
1319}

References currentBackend_, and SIM_CUSTOM.

◆ isMachineLoaded()

bool SimulatorFrontend::isMachineLoaded ( ) const

Returns true if a machine has been loaded for the simulation

Returns
True if machine has been loaded.

Definition at line 1250 of file SimulatorFrontend.cc.

1250 {
1251 return (currentMachine_ != NULL);
1252}

References currentMachine_.

Referenced by setupCallHistoryTracking().

◆ isProgramLoaded()

bool SimulatorFrontend::isProgramLoaded ( ) const

Returns true if the simulation has been initialized with a program successfully.

Returns
True if simulation has been initialized.

Definition at line 1240 of file SimulatorFrontend.cc.

1240 {
1241 return (simCon_ != NULL && currentProgram_ != NULL);
1242}

References currentProgram_, and simCon_.

Referenced by DisasmExecPercentageAttrProvider::moveCellAttr().

◆ isSimulationInitialized()

bool SimulatorFrontend::isSimulationInitialized ( ) const

◆ isSimulationRunning()

bool SimulatorFrontend::isSimulationRunning ( ) const

◆ isSimulationStopped()

bool SimulatorFrontend::isSimulationStopped ( ) const

◆ isTCEDebugger()

bool SimulatorFrontend::isTCEDebugger ( ) const

Check if we are currently using a TCE built-in debugger. This returns true if we are attached to a FPGA or an ASIC with on-circuit debug hardware.

Returns
true if we are using a TCE debug target.

Definition at line 1306 of file SimulatorFrontend.cc.

1306 {
1307 return currentBackend_ == SIM_REMOTE;
1308}

References currentBackend_, and SIM_REMOTE.

◆ killSimulation()

void SimulatorFrontend::killSimulation ( )
virtual

Kills the currently running simulation.

Allows restarting the simulation with the loaded machine and program. Flushes data collected during simulation to the trace file, if tracing is enabled, and reinitializes everything that needs to be reinitialized, such as the data memory initial values.

Reimplemented in TracedSimulatorFrontend.

Definition at line 1784 of file SimulatorFrontend.cc.

1784 {
1786 simCon_->reset();
1790}
void initializeDataMemories(const TTAMachine::AddressSpace *onlyOne=NULL)
virtual void reset()=0

References finishSimulation(), initializeDataMemories(), initializeTracing(), lastRunCycleCount_, TTASimulationController::reset(), and simCon_.

Referenced by KillCommand::execute(), TracedSimulatorFrontend::killSimulation(), and DesignSpaceExplorer::simulate().

Here is the call graph for this function:

◆ lastExecInstruction()

const ExecutableInstruction & SimulatorFrontend::lastExecInstruction ( ) const

Returns a reference to the last executed instruction.

Returns
Last instruction executed.

Definition at line 2194 of file SimulatorFrontend.cc.

2194 {
2195 assert(simCon_ != NULL);
2196 const InstructionMemory& memory = dynamic_cast<SimulationController*>(
2197 simCon_)->instructionMemory();
2199}
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const

References assert, InstructionMemory::instructionAtConst(), lastExecutedInstruction(), and simCon_.

Referenced by ProximMachineStateWindow::addMoves().

Here is the call graph for this function:

◆ lastExecutedInstruction()

InstructionAddress SimulatorFrontend::lastExecutedInstruction ( int  coreId = -1) const
virtual

Returns the address of the last executed instruction.

Parameters
coreIdLook at the given processor core. If -1, the currently selected core will be used.
Returns
Address of the last executed instruction.

Definition at line 1182 of file SimulatorFrontend.cc.

1182 {
1183 assert(simCon_ != NULL);
1184 return simCon_->lastExecutedInstruction(coreId);
1185}
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const

References assert, TTASimulationController::lastExecutedInstruction(), and simCon_.

Referenced by ProximMachineStateWindow::addMoves(), ProcedureTransferTracker::handleEvent(), RuntimeErrorReporter::handleEvent(), RFAccessTracker::handleEvent(), and lastExecInstruction().

Here is the call graph for this function:

◆ lastRunCycleCount()

CycleCount SimulatorFrontend::lastRunCycleCount ( ) const

Returns the count of cycles simulated in the last simulation run.

For example, if run was executed and then interrupted by the user or a breakpoint, returns how long the run was in simulation cycles.

Returns
The cycle count.

Definition at line 2276 of file SimulatorFrontend.cc.

2276 {
2277 return lastRunCycleCount_;
2278}

References lastRunCycleCount_.

Referenced by SimControlLanguageCommand::printSimulationTime().

◆ lastRunTime()

double SimulatorFrontend::lastRunTime ( ) const

Returns the runtime of the last simulation session in seconds.

For example, if run was executed and then interrupted by the user or a breakpoint, returns how long the run was in wall clock time.

Returns
Simulation wall clock time in seconds.

Definition at line 2289 of file SimulatorFrontend.cc.

2289 {
2290 return lastRunTime_;
2291}

References lastRunTime_.

Referenced by SimControlLanguageCommand::printSimulationTime().

◆ lastTraceDB()

ExecutionTrace * SimulatorFrontend::lastTraceDB ( int  core = -1)

Returns the last produced execution trace database.

The ownership of the TraceDB is transferred to the caller. That is, it should delete it after use.

Returns
The traceDB instance.

Definition at line 2243 of file SimulatorFrontend.cc.

2243 {
2244 if (core == -1)
2245 core = selectedCore();
2246
2247 ExecutionTrace* last = traceDBs_[core];
2248 traceDBOwned_[core] = false;
2249 return last;
2250}

References selectedCore(), traceDBOwned_, and traceDBs_.

Referenced by DesignSpaceExplorer::simulate().

Here is the call graph for this function:

◆ loadMachine() [1/2]

void SimulatorFrontend::loadMachine ( const std::string &  fileName)
virtual

Loads a new machine to be simulated from an ADF file.

The loaded machine will be owned by SimulatorFrontend and will be deleted by it when not needed anymore.

Parameters
fileNameThe name of the ADF file to be loaded.
Exceptions
FileNotFoundIf the file cannot be found.
SimulationStillRunningIf an old simulation is still running.
IllegalMachineIf the ADF was erroneus.

Reimplemented in TracedSimulatorFrontend.

Definition at line 534 of file SimulatorFrontend.cc.

534 {
536
537 if (!FileSystem::fileExists(fileName)) {
538 throw FileNotFound(
539 __FILE__, __LINE__, __func__,
540 (textGen.text(Texts::TXT_FILE_X_NOT_FOUND) % fileName).str());
541 }
542
543 if (!FileSystem::fileIsReadable(fileName)) {
544 throw IOException(__FILE__, __LINE__, __func__, "File not readable.");
545 }
546
547 ADFSerializer serializer;
548 serializer.setSourceFile(fileName);
549
550 const Machine* oldMachine = currentMachine_;
551 try {
552 currentMachine_ = serializer.readMachine();
553 } catch (const Exception& e) {
554 IllegalMachine ime(
555 __FILE__, __LINE__, __func__,
556 textGen.text(Texts::TXT_ILLEGAL_ADF_FILE).str());
557 ime.setCause(e);
558 throw ime;
559 }
561 delete oldMachine;
562 oldMachine = NULL;
563 }
565
568 delete currentProgram_;
569 currentProgram_ = NULL;
570 }
571 delete simCon_;
572 simCon_ = NULL;
573
574 // compiled sim does not handle long guard latencies correctly.
575 // remove when fixed.
576 if (isCompiledSimulation() &&
580 // TODO: warn about this, when the warning can be ignored
581 // by tests.
582 }
585}
TTAMachine::Machine * readMachine()
static bool fileIsReadable(const std::string fileName)
bool isCompiledSimulation() const
int globalGuardLatency() const
bool is64bit() const
Definition Machine.hh:260
void setSourceFile(const std::string &fileName)
@ TXT_FILE_X_NOT_FOUND

References __func__, TTAMachine::Machine::controlUnit(), currentMachine_, currentProgram_, SequenceTools::deleteAllItems(), FileSystem::fileExists(), FileSystem::fileIsReadable(), finishSimulation(), TTAMachine::ControlUnit::globalGuardLatency(), initializeMemorySystem(), TTAMachine::Machine::is64bit(), isCompiledSimulation(), machineOwnedByFrontend_, memorySystems_, programOwnedByFrontend_, ADFSerializer::readMachine(), Exception::setCause(), setCompiledSimulation(), XMLSerializer::setSourceFile(), simCon_, Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_FILE_X_NOT_FOUND, and Texts::TXT_ILLEGAL_ADF_FILE.

Referenced by MachCommand::execute(), TracedSimulatorFrontend::loadMachine(), loadProcessorConfiguration(), SimpleSimulatorFrontend::SimpleSimulatorFrontend(), SimpleSimulatorFrontend::SimpleSimulatorFrontend(), SimpleSimulatorFrontend::SimpleSimulatorFrontend(), DesignSpaceExplorer::simulate(), and tandemSimulate().

Here is the call graph for this function:

◆ loadMachine() [2/2]

void SimulatorFrontend::loadMachine ( const TTAMachine::Machine machine)

Loads a new machine to be simulated.

The loaded machine is not owned by SimulatorFrontend and thus won't be deleted by it when not needed anymore.

Parameters
programThe machine to be loaded.

Definition at line 227 of file SimulatorFrontend.cc.

227 {
229 delete currentMachine_;
230 currentMachine_ = NULL;
231 }
234
237 delete currentProgram_;
238 currentProgram_ = NULL;
239 }
240 delete simCon_;
241 simCon_ = NULL;
242
243 // compiled sim does not handle long guard latencies nor 64 bits correctly
244 // remove when fixed.
245 if (isCompiledSimulation() &&
247 machine.is64bit())) {
249 // TODO: warn about this, when the warning can be ignored
250 // by tests.
251 }
254}

References TTAMachine::Machine::controlUnit(), currentMachine_, currentProgram_, SequenceTools::deleteAllItems(), finishSimulation(), TTAMachine::ControlUnit::globalGuardLatency(), initializeMemorySystem(), TTAMachine::Machine::is64bit(), isCompiledSimulation(), machine(), machineOwnedByFrontend_, memorySystems_, programOwnedByFrontend_, setCompiledSimulation(), and simCon_.

Here is the call graph for this function:

◆ loadProcessorConfiguration()

void SimulatorFrontend::loadProcessorConfiguration ( const std::string &  fileName)

Loads a new machine to be simulated from a processor configuration file.

The loaded machine will be owned by SimulatorFrontend and thus be deleted by it when not needed anymore.

Parameters
fileNameThe name of the PCF to be loaded.
Exceptions
FileNotFoundIf the file cannot be found.
SimulationStillRunningIf an old simulation is still running.
IllegalMachineIf the ADF was erroneus.

Definition at line 600 of file SimulatorFrontend.cc.

600 {
602
603 if (!FileSystem::fileExists(fileName)) {
604 throw FileNotFound(
605 __FILE__, __LINE__, __func__,
606 textGen.text(Texts::TXT_FILE_NOT_FOUND).str());
607 }
608
609 if (!FileSystem::fileIsReadable(fileName)) {
610 throw IOException(__FILE__, __LINE__, __func__, "File not readable.");
611 }
612
613 std::ifstream inputFile(fileName.c_str());
614 ProcessorConfigurationFile pcf(inputFile);
615 pcf.setPCFDirectory(FileSystem::directoryOfPath(fileName));
616
617 std::string adfName = "";
618 try {
619 adfName = pcf.architectureName();
620 } catch (const KeyNotFound&) {
621 throw FileNotFound(
622 __FILE__, __LINE__, __func__,
624 }
625
626 loadMachine(adfName);
627}
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
virtual void loadMachine(const std::string &fileName)
@ TXT_FILE_NOT_FOUND

References __func__, ProcessorConfigurationFile::architectureName(), FileSystem::directoryOfPath(), FileSystem::fileExists(), FileSystem::fileIsReadable(), loadMachine(), ProcessorConfigurationFile::setPCFDirectory(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_FILE_NOT_FOUND, and Texts::TXT_NO_ADF_DEFINED_IN_PCF.

Referenced by ConfCommand::execute().

Here is the call graph for this function:

◆ loadProgram() [1/2]

void SimulatorFrontend::loadProgram ( const std::string &  fileName)
virtual

Loads a new program to be simulated from a TPEF file.

The loaded program will be owned by SimulatorFrontend and thus be deleted by it when not needed anymore.

Parameters
fileNameThe name of the TPEF file to be loaded.
Exceptions
FileNotFoundIf the file cannot be found.
SimulationStillRunningIf an old simulation is still running.
IllegalProgramIf the TPEF was erroneus or the program invalid.
ExceptionAny exception thrown while building the simulation models are passed on.
Todo:

Implement after Program builder is done.

Throw when machine is not loaded.

Implement checking for already running simulation.

Reimplemented in TracedSimulatorFrontend.

Definition at line 299 of file SimulatorFrontend.cc.

299 {
300
301 if (currentMachine_ == NULL)
302 throw Exception(
303 __FILE__, __LINE__, __func__,
304 "Cannot load a program without loading a machine first.");
305
307
308 if (!FileSystem::fileExists(fileName)) {
309 throw FileNotFound(
310 __FILE__, __LINE__, __func__,
311 textGen.text(Texts::TXT_FILE_NOT_FOUND).str());
312 }
313
314 if (!FileSystem::fileIsReadable(fileName)) {
315 throw IOException(__FILE__, __LINE__, __func__, "File not readable.");
316 }
317
318 BinaryStream binaryStream(fileName);
319
320 const Program* oldProgram = currentProgram_;
321
322 try {
323 // read to TPEF Handler Module
324 tpef_ = BinaryReader::readBinary(binaryStream);
325
326 assert(tpef_ != NULL);
327 assert(currentMachine_ != NULL);
328
329 // convert the loaded TPEF to POM
331 TTAProgram::Program* program = factory.build();
332 program->finalize();
334 } catch (const Exception& e) {
335 delete tpef_;
336 tpef_ = NULL;
337 delete simCon_;
338 simCon_ = NULL;
339 std::string errorMsg = textGen.text(
341
342 if (e.errorMessage() != "")
343 errorMsg += " " + e.errorMessage();
344
345 IllegalProgram illegp(__FILE__, __LINE__, __func__, errorMsg);
346 illegp.setCause(e);
347 throw illegp;
348 }
349
350 // Validate the program against the current machine using POMValidator.
351 // TODO: this should be refactored -- the loadProgram(Program) is not
352 // checking these?
353 POMValidator validator(*currentProgram_);
354 std::set<POMValidator::ErrorCode> checks;
358
359 if (isCompiledSimulation()) {
361 }
362
363#if (!defined(HAVE_CXX11) && !defined(HAVE_CXX0X))
364 std::auto_ptr<POMValidatorResults> results(validator.validate(checks));
365#else
366 std::unique_ptr<POMValidatorResults> results(validator.validate(checks));
367#endif
368
369 if (results->errorCount() > 0) {
370 std::string errorMsg = textGen.text(
372
373 for (int i = 0; i < results->errorCount(); i++) {
374 errorMsg += "\n" + results->error(i).second;
375 }
376
377 if (isCompiledSimulation()) {
378 // Attempt without compiled simulator
381 results.reset(validator.validate(checks));
382 }
383
384 if (results->errorCount() > 0) {
385 delete tpef_;
386 tpef_ = NULL;
387 delete simCon_;
388 simCon_ = NULL;
389
390 for (int i = 0; i < results->errorCount(); i++) {
391 errorMsg += "\n" + results->error(i).second;
392 }
393
394 throw IllegalProgram(__FILE__, __LINE__, __func__, errorMsg);
395 } else {
397 << errorMsg << std::endl
398 << "Warning! Reverting to interpretive simulation engine."
399 << std::endl;
400 }
401 }
402
404 delete oldProgram;
405 oldProgram = NULL;
406 }
407
408 delete disassembler_;
409 disassembler_ = NULL;
410
412
415
416 // Dump simulation traces in the same directory as loaded program file
417 // or user-defined directory
418 std::string traceDir = Environment::simTraceDirPath();
419 if (traceDir == "") {
420 programFileName_ = fileName;
421 } else {
424 FileSystem::fileOfPath(fileName);
425 }
426
427 // tracing can't be enabled before loading program so try to initialize
428 // the tracing after program is loaded
430}
static std::string simTraceDirPath()
static const std::string DIRECTORY_SEPARATOR
static std::string fileOfPath(const std::string pathName)
@ CONNECTION_MISSING
Connection required for a move is missing.
@ LONG_IMMEDIATE_NOT_SUPPORTED
Instruction template missing for a long immediate.
@ SIMULATION_NOT_POSSIBLE
Program contains operations with unknown behaviour.
@ COMPILED_SIMULATION_NOT_POSSIBLE
Compiled simulation is not possible.
virtual void initializeSimulation()
std::ostream & outputStream()
static Binary * readBinary(BinaryStream &stream)

References __func__, assert, TTAProgram::TPEFProgramFactory::build(), POMValidator::COMPILED_SIMULATION_NOT_POSSIBLE, POMValidator::CONNECTION_MISSING, currentMachine_, currentProgram_, FileSystem::DIRECTORY_SEPARATOR, disassembler_, Exception::errorMessage(), FileSystem::fileExists(), FileSystem::fileIsReadable(), FileSystem::fileOfPath(), TTAProgram::Program::finalize(), initializeDataMemories(), initializeSimulation(), initializeTracing(), isCompiledSimulation(), POMValidator::LONG_IMMEDIATE_NOT_SUPPORTED, outputStream(), program(), programFileName_, programOwnedByFrontend_, TPEF::BinaryReader::readBinary(), Exception::setCause(), setCompiledSimulation(), simCon_, Environment::simTraceDirPath(), POMValidator::SIMULATION_NOT_POSSIBLE, Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), tpef_, Texts::TXT_FILE_NOT_FOUND, Texts::TXT_UNABLE_TO_LOAD_PROGRAM, and POMValidator::validate().

Referenced by ProgCommand::execute(), SimpleSimulatorFrontend::loadProgram(), TracedSimulatorFrontend::loadProgram(), SimpleSimulatorFrontend::SimpleSimulatorFrontend(), SimpleSimulatorFrontend::SimpleSimulatorFrontend(), DesignSpaceExplorer::simulate(), and tandemSimulate().

Here is the call graph for this function:

◆ loadProgram() [2/2]

void SimulatorFrontend::loadProgram ( const TTAProgram::Program program)

Loads a new program to be simulated.

The loaded program is not owned by SimulatorFrontend and thus won't be deleted by it when not needed anymore. Simulation is initialized using the previously loaded machine. This function assumes that machine is loaded before calling it. Program is aborted otherwise.

Parameters
programThe program to be loaded.
Exceptions
IOExceptionIf tracing is enabled and could not be initialized.
ExceptionAny exception thrown while building the simulation models are passed on.
Todo:

Throw when machine is not loaded.

Implement checking for already running simulation.

Definition at line 198 of file SimulatorFrontend.cc.

198 {
199
200 if (currentMachine_ == NULL)
201 throw Exception(
202 __FILE__, __LINE__, __func__,
203 "Cannot load a program without loading a machine first.");
204
206 delete currentProgram_;
207 currentProgram_ = NULL;
208 }
209
212
216}

References __func__, currentMachine_, currentProgram_, initializeDataMemories(), initializeSimulation(), initializeTracing(), program(), and programOwnedByFrontend_.

Here is the call graph for this function:

◆ machine()

const Machine & SimulatorFrontend::machine ( ) const

◆ machineState()

MachineState & SimulatorFrontend::machineState ( int  core = -1)

Returns a reference to the state model of the currently loaded machine.

Note
: This should be called only for interpretive simulation which uses the SimulationController engine. Asserts if another engine (compiled) is used.
Returns
State model of the simulated machine.

Definition at line 2138 of file SimulatorFrontend.cc.

2138 {
2139 SimulationController* simCon =
2140 dynamic_cast<SimulationController*>(simCon_);
2141 assert(simCon != NULL && "Wrong TTASimulationController implementation.");
2142 return simCon->machineState(core);
2143}
virtual MachineState & machineState(int core=-1)

References assert, SimulationController::machineState(), and simCon_.

Referenced by ProximBusDetailsCmd::Do(), ProximFUDetailsCmd::Do(), ProximFUPortDetailsCmd::Do(), ProximIUDetailsCmd::Do(), ProximRFDetailsCmd::Do(), InfoSegmentsCommand::execute(), findBooleanRegister(), findPort(), findRegister(), BusTracker::handleEvent(), ProximRegisterWindow::loadImmediateUnit(), ProximRegisterWindow::loadRegisterFile(), SimpleSimulatorFrontend::setOperationSimulator(), and ProximPortWindow::update().

Here is the call graph for this function:

◆ memoryAccessTracking()

bool SimulatorFrontend::memoryAccessTracking ( ) const

Returns true if memory access tracking is enabled.

Returns
Returns current memory access tracking setting.

Definition at line 2057 of file SimulatorFrontend.cc.

2057 {
2058 return memoryAccessTracking_;
2059}

References memoryAccessTracking_.

◆ memorySystem()

MemorySystem & SimulatorFrontend::memorySystem ( int  coreId = -1)

◆ next()

void SimulatorFrontend::next ( int  count = 1)
virtual

Advance simulation by a given amout of steps and skip procedure calls.

Parameters
countThe number of steps the simulation is advanced.
Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.
Todo:
Throw exception if simulation is not initialized.

Reimplemented in TracedSimulatorFrontend.

Definition at line 1052 of file SimulatorFrontend.cc.

1052 {
1053 assert(simCon_ != NULL);
1054
1055 startTimer();
1056 boost::thread timeout(boost::bind(timeoutThread,
1057 simulationTimeout_, this));
1058 simCon_->next(count);
1059 stopTimer();
1060
1061 // invalidate utilization statistics (they are not fresh anymore)
1063}
friend void timeoutThread(unsigned int timeout, SimulatorFrontend *simFE)
virtual void next(int count=1)=0

References assert, SequenceTools::deleteAllItems(), TTASimulationController::next(), simCon_, simulationTimeout_, startTimer(), stopTimer(), timeoutThread, and utilizationStats_.

Referenced by NextiCommand::execute(), and TracedSimulatorFrontend::next().

Here is the call graph for this function:

◆ nextInstructionPrinting()

bool SimulatorFrontend::nextInstructionPrinting ( ) const

Returns true if the next simulated instruction will be printed to the simulator console at simulation stop.

Returns
True if the instruction should be printed.

Definition at line 2080 of file SimulatorFrontend.cc.

2080 {
2081 return printNextInstruction_;
2082}

References printNextInstruction_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ outputStream()

std::ostream & SimulatorFrontend::outputStream ( )

Returns the output stream

Returns
the output stream

Definition at line 1987 of file SimulatorFrontend.cc.

1987 {
1988 assert(outputStream_ != 0);
1989 return *outputStream_;
1990}

References assert, and outputStream_.

Referenced by loadProgram().

◆ prepareToStop()

void SimulatorFrontend::prepareToStop ( StopReason  reason)

Signals the simulator engine to stop simulation after the current simulated clock cycle.

Does nothing if simulation is not initialized or simulation is not running.

Parameters
reasonThe reason for stopping.

Definition at line 1331 of file SimulatorFrontend.cc.

1331 {
1332 if (simCon_ == NULL || !isSimulationRunning()) {
1333 return;
1334 }
1335 simCon_->prepareToStop(reason);
1336}
bool isSimulationRunning() const
virtual void prepareToStop(StopReason reason)

References isSimulationRunning(), TTASimulationController::prepareToStop(), and simCon_.

Referenced by SigINTHandler::execute(), SigSegvHandler::execute(), SigFPEHandler::execute(), ProximSimulationThread::finishSimulation(), RuntimeErrorReporter::handleEvent(), ProximRuntimeErrorHandler::handleEvent(), ProximSimulationThread::killSimulation(), ProximStopDialog::onClose(), ProximStopDialog::onStop(), ProximSimulationThread::requestStop(), and SimpleSimulatorFrontend::stop().

Here is the call graph for this function:

◆ procedureTransferTracing()

bool SimulatorFrontend::procedureTransferTracing ( ) const

Returns true in case procedure transfer tracing is enabled.

Returns
True in case procedure transfer tracing is enabled.

Definition at line 1827 of file SimulatorFrontend.cc.

1827 {
1829}

References procedureTransferTracing_.

Referenced by SimulatorSettingsDialog::onOK(), CompiledSimController::reset(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ profileDataSaving()

bool SimulatorFrontend::profileDataSaving ( ) const

Returns true in case profile data saving is enabled.

Returns
True in case profile data saving is enabled.

Definition at line 1837 of file SimulatorFrontend.cc.

1837 {
1838 return saveProfileData_;
1839}

References saveProfileData_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ program()

const Program & SimulatorFrontend::program ( ) const

◆ programCounter()

InstructionAddress SimulatorFrontend::programCounter ( ) const

Returns the program counter value.

Returns
Program counter value.
Todo:
Throw exception if simulation is not initialized

Definition at line 1169 of file SimulatorFrontend.cc.

1169 {
1170 assert(simCon_ != NULL);
1171 return simCon_->programCounter();
1172}
virtual InstructionAddress programCounter() const =0

References assert, TTASimulationController::programCounter(), and simCon_.

Referenced by compareState(), currentProcedure(), InfoProgramCommand::execute(), RuntimeErrorReporter::handleEvent(), Breakpoint::isTriggered(), SimControlLanguageCommand::parseInstructionAddressExpression(), and programLocationDescription().

Here is the call graph for this function:

◆ programErrorReport()

std::string SimulatorFrontend::programErrorReport ( RuntimeErrorSeverity  severity,
std::size_t  index 
)

Returns a program error report with given severity and index.

Parameters
severitySeverity.
indexIndex.
Returns
The error report text.

Definition at line 2321 of file SimulatorFrontend.cc.

2322 {
2323
2324 size_t count = 0;
2325 for (ProgramErrorDescriptionList::iterator i =
2326 programErrorReports_.begin(); i != programErrorReports_.end();
2327 ++i) {
2328 if ((*i).first == severity) {
2329 if (count == index)
2330 return (*i).second;
2331 ++count;
2332 }
2333 }
2334 return "";
2335}

References programErrorReports_.

Referenced by RuntimeErrorReporter::handleEvent(), and ProximRuntimeErrorHandler::handleEvent().

◆ programErrorReportCount()

std::size_t SimulatorFrontend::programErrorReportCount ( RuntimeErrorSeverity  severity)

Returns the count of program error reports with given severity.

Parameters
severityThe error report severity interested in.
Returns
The count of error reports.

Definition at line 2344 of file SimulatorFrontend.cc.

2345 {
2346 size_t count = 0;
2347 for (ProgramErrorDescriptionList::iterator i =
2348 programErrorReports_.begin(); i != programErrorReports_.end();
2349 ++i) {
2350 if ((*i).first == severity)
2351 ++count;
2352 }
2353 return count;
2354}

References programErrorReports_.

Referenced by RuntimeErrorReporter::handleEvent(), and ProximRuntimeErrorHandler::handleEvent().

◆ programLocationDescription()

std::string SimulatorFrontend::programLocationDescription ( ) const

Returns a string describing the current location of simulation in the simulated program.

If simulation has ended, returns an empty string.

Returns
A description as defined in Simulator specs.

Definition at line 1108 of file SimulatorFrontend.cc.

1108 {
1109
1110 if (hasSimulationEnded()) {
1111 return "";
1112 }
1113
1114 InstructionAddress instructionAddress = programCounter();
1115
1116 const InstructionAddress programLastAddress =
1118
1119 if (instructionAddress >= programLastAddress) {
1120 return "";
1121 }
1122
1123 const Instruction& theInstruction =
1124 currentProgram_->instructionAt(instructionAddress);
1125 const Procedure& currentProc =
1126 dynamic_cast<const Procedure&>(theInstruction.parent());
1127
1128 InstructionAddress distanceFromStart =
1129 instructionAddress - currentProc.startAddress().location();
1130
1132
1133 std::stringstream tempStream;
1134
1135 tempStream << std::setw(7) << std::right << instructionAddress << " ";
1136 tempStream
1137 << std::setw(30) << std::right <<
1138 std::string("<") + currentProc.name() + "+" +
1139 Conversion::toString(distanceFromStart) + ">" << ": "
1140 << disassembler_->disassembleInstruction(theInstruction);
1141
1142 return tempStream.str();
1143}
bool hasSimulationEnded() const

References currentProgram_, POMDisassembler::disassembleInstruction(), disassembler_, TTAProgram::CodeSnippet::endAddress(), hasSimulationEnded(), initializeDisassembler(), TTAProgram::Program::instructionAt(), TTAProgram::Program::lastProcedure(), TTAProgram::Address::location(), TTAProgram::Procedure::name(), TTAProgram::Instruction::parent(), programCounter(), TTAProgram::CodeSnippet::startAddress(), and Conversion::toString().

Referenced by SimControlLanguageCommand::printNextInstruction().

Here is the call graph for this function:

◆ registerFileValue()

std::string SimulatorFrontend::registerFileValue ( const std::string &  rfName,
int  registerIndex = -1 
)
virtual

Returns a string containing the value(s) of the register file

Parameters
rfNamename of the register file to search for
registerIndexindex of the register. if -1, all registers are listed
Returns
A string containing the value(s) of the register file
Exceptions
InstanceNotFoundIf the register cannot be found.

Definition at line 738 of file SimulatorFrontend.cc.

739 {
740
741 return simCon_->registerFileValue(rfName, registerIndex);
742}
virtual std::string registerFileValue(const std::string &rfName, int registerIndex=-1)=0

References TTASimulationController::registerFileValue(), and simCon_.

Referenced by compareState().

Here is the call graph for this function:

◆ reportSimulatedProgramError()

void SimulatorFrontend::reportSimulatedProgramError ( RuntimeErrorSeverity  severity,
const std::string &  description 
)

This method is used to report a runtime error detected in the simulated program.

An SE_RUNTIME_ERROR event is announced after storing the report.

Parameters
eventHandlerSimulation event handler for the error
severitySeverity classification of the runtime error.
descriptionTextual description of the error.

Definition at line 2304 of file SimulatorFrontend.cc.

2305 {
2307 report.first = severity;
2308 report.second = description;
2309 programErrorReports_.push_back(report);
2311}
void handleEvent(int event)
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
std::pair< RuntimeErrorSeverity, std::string > ProgramErrorDescription
A type for storing a program error description.

References eventHandler(), Informer::handleEvent(), programErrorReports_, and SimulationEventHandler::SE_RUNTIME_ERROR.

Referenced by SigSegvHandler::execute(), SigFPEHandler::execute(), OTASimulationController::simulateCycle(), and SimulationController::simulateCycle().

Here is the call graph for this function:

◆ rfAccessTracing()

bool SimulatorFrontend::rfAccessTracing ( ) const

Returns true in case register file access tracing is enabled.

Returns
True in case RF access tracing is enabled.

Definition at line 1818 of file SimulatorFrontend.cc.

1818 {
1819 return rfAccessTracing_;
1820}

References rfAccessTracing_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ rfAccessTracker()

const RFAccessTracker & SimulatorFrontend::rfAccessTracker ( ) const

Returns the register file access tracker.

Returns
The register file access tracker.
Exceptions
InstanceNotFoundIf RF access tracking is not enabled.

Definition at line 1869 of file SimulatorFrontend.cc.

1869 {
1870 if (rfAccessTrackers_.size() == 0) {
1871 throw InstanceNotFound(
1872 __FILE__, __LINE__, __func__, "RF access tracing is disabled.");
1873 }
1874 return *rfAccessTrackers_.at(0);
1875}

References __func__, and rfAccessTrackers_.

Referenced by InfoProcCommand::execute(), and finishSimulation().

◆ run()

void SimulatorFrontend::run ( )
virtual

Run simulation until it's stopped for some reason.

Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.
Todo:
Throw exception if simulation is not initialized.

Reimplemented in TracedSimulatorFrontend.

Definition at line 997 of file SimulatorFrontend.cc.

997 {
998 startTimer();
999 boost::thread timeout(
1000 boost::bind(timeoutThread, simulationTimeout_, this));
1001 simCon_->run();
1002 stopTimer();
1004}
virtual void run()=0

References SequenceTools::deleteAllItems(), TTASimulationController::run(), simCon_, simulationTimeout_, startTimer(), stopTimer(), timeoutThread, and utilizationStats_.

Referenced by ResumeCommand::execute(), RunCommand::execute(), SimpleSimulatorFrontend::run(), TracedSimulatorFrontend::run(), and DesignSpaceExplorer::simulate().

Here is the call graph for this function:

◆ runUntil()

void SimulatorFrontend::runUntil ( UIntWord  address)
virtual

Run simulation until given address.

Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.
Todo:
Throw exception if simulation is not initialized.

Reimplemented in TracedSimulatorFrontend.

Definition at line 1014 of file SimulatorFrontend.cc.

1014 {
1015 startTimer();
1016 boost::thread timeout(boost::bind(timeoutThread,
1017 simulationTimeout_, this));
1018 simCon_->runUntil(address);
1019 stopTimer();
1020 // invalidate utilization statistics (they are not fresh anymore)
1022}
virtual void runUntil(UIntWord address)=0

References SequenceTools::deleteAllItems(), TTASimulationController::runUntil(), simCon_, simulationTimeout_, startTimer(), stopTimer(), timeoutThread, and utilizationStats_.

Referenced by UntilCommand::execute(), and TracedSimulatorFrontend::runUntil().

Here is the call graph for this function:

◆ selectCore()

void SimulatorFrontend::selectCore ( int  core)
inline

Definition at line 259 of file SimulatorFrontend.hh.

259 {
260 if (core != 0) {
261 abortWithError("WiP.");
262 }
263 }
#define abortWithError(message)

References abortWithError.

Referenced by SimulationController::simulateCycle(), and SimulationController::SimulationController().

◆ selectedCore()

int SimulatorFrontend::selectedCore ( ) const
inline

◆ setBusTracing()

void SimulatorFrontend::setBusTracing ( bool  value)

Sets the bus tracing on or off.

Parameters
valueIs bus tracing enabled or not.

Definition at line 1910 of file SimulatorFrontend.cc.

1910 {
1911 busTracing_ = value;
1912}

References busTracing_.

Referenced by SetBusTrace::execute().

◆ setCallHistoryLength()

void SimulatorFrontend::setCallHistoryLength ( std::size_t  length)

Sets the length of the call history stored in memory to be used for the simulator's debugging commands that need it.

Setting this to 0 disables the call history tracking thus speeding up simulation. It's disabled by default.

Definition at line 2372 of file SimulatorFrontend.cc.

2372 {
2373 callHistoryLength_ = length;
2375}

References callHistoryLength_, and setupCallHistoryTracking().

Referenced by SetCallHistoryLength::execute().

Here is the call graph for this function:

◆ setCompiledSimulation()

void SimulatorFrontend::setCompiledSimulation ( bool  value)

Sets compiled simulation on or off

Parameters
valueIs compiled simulation enabled or not.

Definition at line 1883 of file SimulatorFrontend.cc.

1883 {
1884 // This legacy function assumes we use a simulator engine, not a
1885 // remote target.
1886 if (currentBackend_ == SIM_REMOTE) return;
1887 if (currentBackend_ == SIM_CUSTOM) return;
1888 if (value)
1890 else
1892}

References currentBackend_, SIM_COMPILED, SIM_CUSTOM, SIM_NORMAL, and SIM_REMOTE.

Referenced by loadMachine(), loadMachine(), loadProgram(), and SimulatorFrontend().

◆ setCompiledSimulationLeaveDirty()

void SimulatorFrontend::setCompiledSimulationLeaveDirty ( bool  dirty)
inline

Definition at line 156 of file SimulatorFrontend.hh.

156 {
157 leaveCompiledDirty_ = dirty;
158 }

References leaveCompiledDirty_.

Referenced by tandemSimulate().

◆ setControllerForMemories()

void SimulatorFrontend::setControllerForMemories ( RemoteController con)
protected

Definition at line 634 of file SimulatorFrontend.cc.

634 {
635
636 int num_mems = memorySystem(0).memoryCount();
637 for (int i = 0; i < num_mems; i++) {
639 boost::shared_ptr<RemoteMemory> rmem =
640 boost::static_pointer_cast<RemoteMemory>(memptr);
641 assert(rmem != NULL && "not a RemoteMemory!");
642 rmem->setController(con);
643 }
644}
unsigned int memoryCount() const

References assert, MemorySystem::memory(), MemorySystem::memoryCount(), and memorySystem().

Referenced by initializeSimulation().

Here is the call graph for this function:

◆ setDetailedSimulation()

void SimulatorFrontend::setDetailedSimulation ( bool  val)
inline

Definition at line 237 of file SimulatorFrontend.hh.

238 { detailedSimulation_ = val; }

References detailedSimulation_.

Referenced by SimpleSimulatorFrontend::SimpleSimulatorFrontend().

◆ setExecutionTracing()

void SimulatorFrontend::setExecutionTracing ( bool  value)

Sets the execution tracing on or off.

Parameters
valueIs execution tracing enabled or not.

Definition at line 1900 of file SimulatorFrontend.cc.

1900 {
1901 executionTracing_ = value;
1902}

References executionTracing_.

Referenced by SetExecutionTrace::execute(), and DesignSpaceExplorer::simulate().

◆ setFUResourceConflictDetection()

void SimulatorFrontend::setFUResourceConflictDetection ( bool  value)

Sets the FU resource conflict detection on or off.

NOTE: this affects future simulations only. That is, if a simulation is already initialized (program loaded), the old setting is used for that simulation.

Parameters
valueShould the resource conflict detection be used.

Definition at line 2022 of file SimulatorFrontend.cc.

2022 {
2024}

References fuResourceConflictDetection_.

Referenced by CompiledSimSetFUConflictDetection::execute(), SetFUConflictDetection::execute(), and SimulatorFrontend().

◆ setMemoryAccessTracking()

void SimulatorFrontend::setMemoryAccessTracking ( bool  value)

Sets the memory access tracking on or off.

NOTE: this affects future simulations only. That is, if a simulation is already initialized (program loaded), the old setting is used for that simulation.

Parameters
valueShould the memory access tracking be used.

Definition at line 2047 of file SimulatorFrontend.cc.

2047 {
2048 memoryAccessTracking_ = value;
2049}

References memoryAccessTracking_.

Referenced by SetMemoryAccessTracking::execute().

◆ setNextInstructionPrinting()

void SimulatorFrontend::setNextInstructionPrinting ( bool  value)

Sets the printing of the next simulated instruction to the console.

The instruction is printed when stopping simulation.

Parameters
valueTrue if the instruction should be printed.

Definition at line 2069 of file SimulatorFrontend.cc.

2069 {
2070 printNextInstruction_ = value;
2071}

References printNextInstruction_.

Referenced by SetNextInstructionPrinting::execute().

◆ setOutputStream()

void SimulatorFrontend::setOutputStream ( std::ostream &  stream)

Sets the default output stream

Parameters
streamthe output stream

Definition at line 1998 of file SimulatorFrontend.cc.

1998 {
1999 outputStream_ = &stream;
2000}

References outputStream_.

◆ setProcedureTransferTracing()

void SimulatorFrontend::setProcedureTransferTracing ( bool  value)

Sets the procedure transfer tracing on or off.

Parameters
valueIs procedure transfer tracing on or off.

Definition at line 1930 of file SimulatorFrontend.cc.

1930 {
1932}

References procedureTransferTracing_.

Referenced by SetProcedureTransferTracing::execute().

◆ setProfileDataSaving()

void SimulatorFrontend::setProfileDataSaving ( bool  value)

Sets the profile saving on or off.

Parameters
valueIs profile saving on or off.

Definition at line 1940 of file SimulatorFrontend.cc.

1940 {
1941 saveProfileData_ = value;
1942}

References saveProfileData_.

Referenced by SetProfileSaving::execute().

◆ setRFAccessTracing()

void SimulatorFrontend::setRFAccessTracing ( bool  value)

Sets the register file access tracing on or off.

Parameters
valueIs register file access tracing enabled or not.

Definition at line 1920 of file SimulatorFrontend.cc.

1920 {
1921 rfAccessTracing_ = value;
1922}

References rfAccessTracing_.

Referenced by SetRFTracking::execute(), and DesignSpaceExplorer::simulate().

◆ setSimulationTimeStatistics()

void SimulatorFrontend::setSimulationTimeStatistics ( bool  value)

Sets the printing of simulation time statistics

Parameters
valueTrue if the statistics should be printed out

Definition at line 2088 of file SimulatorFrontend.cc.

2088 {
2090}

References printSimulationTimeStatistics_.

Referenced by SetSimulationTimeStatistics::execute().

◆ setStaticCompilation()

void SimulatorFrontend::setStaticCompilation ( bool  value)

Sets the compiled simulator to use static or dynamic compilation.

Has no effect when running interpretive simulation.

Parameters
valuenew value to be set

Definition at line 1977 of file SimulatorFrontend.cc.

1977 {
1978 staticCompilation_ = value;
1979}

References staticCompilation_.

Referenced by SetStaticCompilation::execute(), and tandemSimulate().

◆ setTimeout()

void SimulatorFrontend::setTimeout ( unsigned int  value)

Sets the simulation timeout in seconds. Use zero for no timeout.

Parameters
valueSimulation timeout in seconds.

Definition at line 1965 of file SimulatorFrontend.cc.

1965 {
1966 simulationTimeout_ = value;
1967}

References simulationTimeout_.

Referenced by SetSimulationTimeout::execute(), and DesignSpaceExplorer::simulate().

◆ setupCallHistoryTracking()

void SimulatorFrontend::setupCallHistoryTracking ( )
protected

Definition at line 2378 of file SimulatorFrontend.cc.

2378 {
2379 if (callHistoryLength_ == 0 || !isMachineLoaded()) {
2381 return;
2382 } else {
2383 for (int core = 0; core < 1;
2384 ++core) {
2385 CallPathTracker* tracker =
2386 new CallPathTracker(*this, core, callHistoryLength_);
2387 callPathTrackers_.push_back(tracker);
2388 }
2389 }
2390}

References callHistoryLength_, callPathTrackers_, SequenceTools::deleteAllItems(), and isMachineLoaded().

Referenced by initializeTracing(), and setCallHistoryLength().

Here is the call graph for this function:

◆ setUtilizationDataSaving()

void SimulatorFrontend::setUtilizationDataSaving ( bool  value)

Sets the utilization data saving on or off.

Parameters
valueIs utilization data saving on or off.

Definition at line 2008 of file SimulatorFrontend.cc.

2008 {
2009 saveUtilizationData_ = value;
2010}

References saveUtilizationData_.

Referenced by SetUtilizationSaving::execute(), and DesignSpaceExplorer::simulate().

◆ setZeroFillMemoriesOnReset()

void SimulatorFrontend::setZeroFillMemoriesOnReset ( bool  val)
inline

◆ simulationTimeStatistics()

bool SimulatorFrontend::simulationTimeStatistics ( ) const

Returns true if the time statistics are to be printed after a command

Returns
True, if the time statistics are to be printed after a command

Definition at line 2097 of file SimulatorFrontend.cc.

2097 {
2099}

References printSimulationTimeStatistics_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ startTimer()

void SimulatorFrontend::startTimer ( )
protected

Starts the wall-clock timer.

Definition at line 928 of file SimulatorFrontend.cc.

928 {
930 startTime_ = time(NULL);
931}
CycleCount startCycleCount_
The cycle count when the latest simulation was started. Used to compute simulation speed.
std::time_t startTime_
The time of the last simulation start. Used to compute simulation speed.

References cycleCount(), startCycleCount_, and startTime_.

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

Here is the call graph for this function:

◆ state()

StateData & SimulatorFrontend::state ( std::string  searchString)

Tries to locate a readable machine state part using a search string.

See stateValue() for further comment.

Parameters
searchStringThe string to use in search, e.g., (alu.p3 or add.3).
Returns
The StateData object.
Exceptions
InstanceNotFoundIn case state couldn't be found using the search string.
Todo:
Parallel fu port access (syntax?)

Definition at line 894 of file SimulatorFrontend.cc.

894 {
895 if (currentMachine_ == NULL)
896 throw InstanceNotFound(
897 __FILE__, __LINE__, __func__, "State not found.");
898
899 boost::smatch parsed;
900
901 if (StringTools::ciEqual(searchString, "bool") ||
902 StringTools::ciEqual(searchString, "boolean")) {
903 return findBooleanRegister();
904 } else
905 if (StringTools::ciEqual(searchString, "ra") ||
906 StringTools::ciEqual(searchString, "return-address")) {
907 return findPort(
910 } else
911 if (regex_match(
912 searchString, parsed,
914 /// @todo Parallel fu port access (syntax?)
915 return findPort(parsed[1], parsed[2]);
916 }
917
918 throw InstanceNotFound(
919 __FILE__, __LINE__, __func__,
920 std::string("No state found with the search string '") +
921 std::string(searchString) + "'.");
922}
StateData & findPort(const std::string &fuName, const std::string &portName)
StateData & findBooleanRegister()
static boost::regex fuPortRegex()
SpecialRegisterPort * returnAddressPort() const

References __func__, StringTools::ciEqual(), TTAMachine::Machine::controlUnit(), currentMachine_, findBooleanRegister(), findPort(), SimulatorToolbox::fuPortRegex(), TTAMachine::Component::name(), TTAMachine::Port::name(), and TTAMachine::ControlUnit::returnAddressPort().

Referenced by InfoRegistersCommand::execute(), and stateValue().

Here is the call graph for this function:

◆ stateValue()

const SimValue & SimulatorFrontend::stateValue ( std::string  searchString)

Tries to locate a readable machine state part using a search string.

For a syntax of valid search strings, consult the TCE TTA assembler syntax description. All valid sources and destinations except immediate sources are valid search strings.

Parameters
searchStringThe string to use in search, e.g., (alu.p3).
Returns
Current value of the state (read-only).
Exceptions
InstanceNotFoundIn case state couldn't be found using the search string.

Definition at line 878 of file SimulatorFrontend.cc.

878 {
879 return state(searchString).value();
880}
virtual const SimValue & value() const =0
StateData & state(std::string searchString)

References state(), and ReadableState::value().

Here is the call graph for this function:

◆ staticCompilation()

bool SimulatorFrontend::staticCompilation ( ) const

Returns true if the compiled simulation uses static compilation

Returns
true if the compiled simulation uses static compilation

Definition at line 1857 of file SimulatorFrontend.cc.

1857 {
1858 return staticCompilation_;
1859}

References staticCompilation_.

Referenced by CompiledSimController::reset().

◆ step()

void SimulatorFrontend::step ( double  count = 1)
virtual

Advance simulation by a given amout of cycles.

Note
Does not create a timeout thread. Does not make sense here as the step() always finishes.
Exceptions
SimulationExecutionErrorIf a runtime error occurs in the simulated program.
Todo:
Throw exception if simulation is not initialized.

Reimplemented in TracedSimulatorFrontend.

Definition at line 1034 of file SimulatorFrontend.cc.

1034 {
1035 assert(simCon_ != NULL);
1036
1037 simCon_->step(count);
1038 // invalidate utilization statistics (they are not fresh anymore)
1040}
virtual void step(double count=1)=0

References assert, SequenceTools::deleteAllItems(), simCon_, TTASimulationController::step(), and utilizationStats_.

Referenced by StepiCommand::execute(), SimpleSimulatorFrontend::step(), TracedSimulatorFrontend::step(), and tandemSimulate().

Here is the call graph for this function:

◆ stoppedByUser()

bool SimulatorFrontend::stoppedByUser ( ) const

Returns true if simulation is stopped because of user set reason, i.e., breakpoint, watchpoint, memory write watchpoint, explicit (ctrl-c) stop, etc.

Also returns true if a runtime error was the reason for stopping, to avoid infinite loops.

Parameters
trueIf simulation stopped because of user set stop point.

Definition at line 1394 of file SimulatorFrontend.cc.

1394 {
1395
1396 if (simCon_ == NULL) {
1397 return false;
1398 }
1399
1400 return
1403}
@ SRE_BREAKPOINT
Stopped because of at least one breakpoint.
@ SRE_USER_REQUESTED
User requested the simulation to stop explicitly, e.g., by pressing ctrl-c in the CLI.
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
bool hasStopReason(StopReason reason) const

References hasStopReason(), simCon_, SRE_BREAKPOINT, SRE_RUNTIME_ERROR, and SRE_USER_REQUESTED.

Here is the call graph for this function:

◆ stopPointManager()

StopPointManager & SimulatorFrontend::stopPointManager ( )

◆ stopReason()

StopReason SimulatorFrontend::stopReason ( unsigned int  index) const

Returns the stop reason with the given index.

Parameters
indexThe wanted index.
Returns
The stop reason at the given index.
Exceptions
OutOfRangeIf the given index is out of range.

Definition at line 1356 of file SimulatorFrontend.cc.

1356 {
1357 assert(simCon_ != NULL);
1358 return simCon_->stopReason(index);
1359}
virtual StopReason stopReason(unsigned int index) const

References assert, simCon_, and TTASimulationController::stopReason().

Referenced by SimpleSimulatorFrontend::hadRuntimeError(), hasStopReason(), SimControlLanguageCommand::printStopReasons(), and tandemSimulate().

Here is the call graph for this function:

◆ stopReasonCount()

unsigned int SimulatorFrontend::stopReasonCount ( ) const

Returns the count of stop reasons.

Returns
The count of stop reasons.

Definition at line 1344 of file SimulatorFrontend.cc.

1344 {
1345 return (simCon_ != NULL && simCon_->stopReasonCount());
1346}
virtual unsigned int stopReasonCount() const

References simCon_, and TTASimulationController::stopReasonCount().

Referenced by SimpleSimulatorFrontend::hadRuntimeError(), hasStopReason(), SimControlLanguageCommand::printStopReasons(), and tandemSimulate().

Here is the call graph for this function:

◆ stopTimer()

void SimulatorFrontend::stopTimer ( )
protected

Saves the value of the wall-clock timer initialized with startTimer() to lastRunTime_ and the count of simulated cycles after startTimer() to lastRunCycleCount_.

Definition at line 938 of file SimulatorFrontend.cc.

938 {
939 std::time_t now = time(NULL);
940 lastRunTime_ = now - startTime_;
941 CycleCount cycles = cycleCount();
943}
long long CycleCount
Type for storing simulation cycle counts.
Definition BaseType.hh:187

References cycleCount(), lastRunCycleCount_, lastRunTime_, startCycleCount_, and startTime_.

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

Here is the call graph for this function:

◆ utilizationDataSaving()

bool SimulatorFrontend::utilizationDataSaving ( ) const

Returns true in case utilization data saving is enabled.

Returns
True in case utilization data saving is enabled.

Definition at line 1847 of file SimulatorFrontend.cc.

1847 {
1848 return saveUtilizationData_;
1849}

References saveUtilizationData_.

Referenced by SimulatorSettingsDialog::onOK(), and SimulatorSettingsDialog::TransferDataToWindow().

◆ utilizationStatistics()

const UtilizationStats & SimulatorFrontend::utilizationStatistics ( int  core = -1)

Returns the current utilization statistics of the processor.

Recalculates the statistics in case they are old, that is, simulation has been continued or restarted since it was calculated. Should not be called in case simulation is not initialized!

Todo:
: unimplemented for remote debuggers

Definition at line 2155 of file SimulatorFrontend.cc.

2155 {
2156 if (core == -1)
2157 core = selectedCore();
2158
2159 utilizationStats_.resize(1);
2160
2161 UtilizationStats* utilizationStats = utilizationStats_.at(core);
2162
2163 if (utilizationStats == NULL) {
2164 // stats calculation differs slightly for compiled & interpretive sims.
2165 if (!isCompiledSimulation()) {
2166 utilizationStats = new UtilizationStats();
2169 dynamic_cast<SimulationController*>(
2170 simCon_)->instructionMemory(core));
2171 stats.addStatistics(*utilizationStats);
2172 stats.calculate();
2173 } else {
2174 CompiledSimUtilizationStats* compiledSimUtilizationStats =
2176 CompiledSimController& compiledSimCon =
2177 dynamic_cast<CompiledSimController&>(*simCon_);
2178 compiledSimUtilizationStats->calculate(program(),
2179 *compiledSimCon.compiledSimulation());
2180 utilizationStats = compiledSimUtilizationStats;
2181 }
2182 utilizationStats_[core] = utilizationStats;
2183 }
2184 return *utilizationStats;
2185}
virtual boost::shared_ptr< CompiledSimulation > compiledSimulation()
virtual void calculate(const TTAProgram::Program &program, const CompiledSimulation &compiledSim)

References SimulationStatistics::addStatistics(), SimulationStatistics::calculate(), CompiledSimUtilizationStats::calculate(), CompiledSimController::compiledSimulation(), currentProgram_, isCompiledSimulation(), program(), selectedCore(), simCon_, and utilizationStats_.

Referenced by ProximBusDetailsCmd::Do(), ProximFUDetailsCmd::Do(), ProximIUDetailsCmd::Do(), ProximRFDetailsCmd::Do(), ProximSocketDetailsCmd::Do(), InfoProcCommand::execute(), InfoStatsCommand::execute(), finishSimulation(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ timeoutThread

void timeoutThread ( unsigned int  timeout,
SimulatorFrontend simFE 
)
friend

A thread function for handling simulation timeout

Parameters
timeouttimeout in seconds

Definition at line 951 of file SimulatorFrontend.cc.

951 {
952 if (timeout == 0) {
953 return;
954 }
955
956 TTASimulationController* simCon = simFE->simCon_;
957 boost::xtime xt;
958 boost::xtime xtPoll;
959#if BOOST_VERSION < 105000
960 boost::xtime_get(&xt, boost::TIME_UTC);
961#else
962 /* TIME_UTC was replaced by TIME_UTC_ in boost 1.50, to avoid
963 * clashing with a similarly named C11 macro. */
964 boost::xtime_get(&xt, boost::TIME_UTC_);
965#endif
966 unsigned int pollTime = 5; // poll time in seconds
967 xtPoll = xt;
968 xt.sec += timeout;
969
970 xtPoll.sec += pollTime;
971 while (xt.sec > xtPoll.sec) {
972 boost::thread::sleep(xtPoll);
973 xtPoll.sec += pollTime;
974 if (simCon != simFE->simCon_) {
975 return;
976 }
977 }
978 boost::thread::sleep(xt);
979
980 if (simCon != simFE->simCon_) {
981 return;
982 }
983
984 if (!simFE->hasSimulationEnded()) {
986 }
987}
@ SRE_AFTER_TIMEOUT
Stopped after simulation timeout instruction.
void prepareToStop(StopReason reason)

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

Member Data Documentation

◆ busTracing_

bool SimulatorFrontend::busTracing_
protected

Is bus tracing, i.e., storing the values of buses in each clock cycle enabled.

Definition at line 315 of file SimulatorFrontend.hh.

Referenced by busTracing(), initializeTracing(), and setBusTracing().

◆ busTrackers_

std::vector<BusTracker*> SimulatorFrontend::busTrackers_
protected

The tracker for saving bus trace.

Definition at line 335 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), and initializeTracing().

◆ callHistoryLength_

std::size_t SimulatorFrontend::callHistoryLength_
protected

The length of call history to store in memory for the commands that need it.

Definition at line 390 of file SimulatorFrontend.hh.

Referenced by callHistoryLength(), setCallHistoryLength(), and setupCallHistoryTracking().

◆ callPathTrackers_

std::vector<CallPathTracker*> SimulatorFrontend::callPathTrackers_
protected

The call path trackers for each core, in case tracking is enabled.

Definition at line 392 of file SimulatorFrontend.hh.

Referenced by callPathTracker(), finishSimulation(), and setupCallHistoryTracking().

◆ currentBackend_

SimulationType SimulatorFrontend::currentBackend_
protected

Type of "backend" this Frontend has.

Definition at line 306 of file SimulatorFrontend.hh.

Referenced by initializeMemorySystem(), initializeSimulation(), isCompiledSimulation(), isCustomDebugger(), isTCEDebugger(), and setCompiledSimulation().

◆ currentMachine_

const TTAMachine::Machine* SimulatorFrontend::currentMachine_
protected

◆ currentProgram_

const TTAProgram::Program* SimulatorFrontend::currentProgram_
protected

◆ detailedSimulation_

bool SimulatorFrontend::detailedSimulation_
protected

Set to true in case should build a detailed model which simulates FU stages, possibly with an external system-level model.

Definition at line 402 of file SimulatorFrontend.hh.

Referenced by initializeSimulation(), and setDetailedSimulation().

◆ disassembler_

POMDisassembler* SimulatorFrontend::disassembler_
mutableprotected

The disassembler used to print out instructions. This is initialized on demand.

Definition at line 309 of file SimulatorFrontend.hh.

Referenced by disassembleInstruction(), initializeDisassembler(), loadProgram(), programLocationDescription(), and ~SimulatorFrontend().

◆ eventHandler_

SimulationEventHandler* SimulatorFrontend::eventHandler_
protected

Per simulation instance of SimulationEventHandler.

Definition at line 370 of file SimulatorFrontend.hh.

Referenced by eventHandler(), and ~SimulatorFrontend().

◆ executionTracing_

bool SimulatorFrontend::executionTracing_
protected

Is execution tracing, i.e., storing the executed instruction addresses to the trace database, enabled.

Definition at line 312 of file SimulatorFrontend.hh.

Referenced by executionTracing(), initializeTracing(), and setExecutionTracing().

◆ executionTrackers_

std::vector<ExecutionTracker*> SimulatorFrontend::executionTrackers_
protected

The simple execution tracker for storing trace of executed instructions.

Definition at line 332 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), and initializeTracing().

◆ forcedTraceDBFileName_

std::string SimulatorFrontend::forcedTraceDBFileName_
protected

If set, forces the SQLite filename of trace DB to this name.

Definition at line 394 of file SimulatorFrontend.hh.

Referenced by forceTraceDBFileName(), and initializeTracing().

◆ fuResourceConflictDetection_

bool SimulatorFrontend::fuResourceConflictDetection_
protected

If this is enabled before initialization, FU resource conflicts are detected (slows down simulation).

Definition at line 353 of file SimulatorFrontend.hh.

Referenced by fuResourceConflictDetection(), initializeSimulation(), and setFUResourceConflictDetection().

◆ lastRunCycleCount_

ClockCycleCount SimulatorFrontend::lastRunCycleCount_
protected

The cycle count of the last non-interrupted simulation phase.

Definition at line 372 of file SimulatorFrontend.hh.

Referenced by killSimulation(), lastRunCycleCount(), and stopTimer().

◆ lastRunTime_

double SimulatorFrontend::lastRunTime_
protected

The wall clock time of the last non-interrupted simulation phase in seconds.

Definition at line 375 of file SimulatorFrontend.hh.

Referenced by lastRunTime(), and stopTimer().

◆ leaveCompiledDirty_

bool SimulatorFrontend::leaveCompiledDirty_
protected

True in case the compilation simulation should not cleanup at destruction the engine source files.

Definition at line 387 of file SimulatorFrontend.hh.

Referenced by initializeSimulation(), and setCompiledSimulationLeaveDirty().

◆ machineOwnedByFrontend_

bool SimulatorFrontend::machineOwnedByFrontend_
protected

Is the machine owned by SimulatorFrontend or by the client?

Definition at line 297 of file SimulatorFrontend.hh.

Referenced by loadMachine(), loadMachine(), and ~SimulatorFrontend().

◆ memoryAccessTracking_

bool SimulatorFrontend::memoryAccessTracking_
protected

If this is enabled before initialization, memory access tracking is enabled. (slows down simulation)

Definition at line 368 of file SimulatorFrontend.hh.

Referenced by initializeMemorySystem(), memoryAccessTracking(), and setMemoryAccessTracking().

◆ memorySystems_

std::vector<MemorySystem*> SimulatorFrontend::memorySystems_
protected

The simulation models of the memories in the currently loaded machine for each core.

Definition at line 397 of file SimulatorFrontend.hh.

Referenced by initializeMemorySystem(), loadMachine(), loadMachine(), memorySystem(), and ~SimulatorFrontend().

◆ outputStream_

std::ostream* SimulatorFrontend::outputStream_
protected

Default output stream.

Definition at line 364 of file SimulatorFrontend.hh.

Referenced by outputStream(), and setOutputStream().

◆ printNextInstruction_

bool SimulatorFrontend::printNextInstruction_
protected

If true, the next simulated instructions is printed to stdout when simulation stops.

Definition at line 356 of file SimulatorFrontend.hh.

Referenced by nextInstructionPrinting(), and setNextInstructionPrinting().

◆ printSimulationTimeStatistics_

bool SimulatorFrontend::printSimulationTimeStatistics_
protected

True if the simulation time statistics should be printed out.

Definition at line 358 of file SimulatorFrontend.hh.

Referenced by setSimulationTimeStatistics(), and simulationTimeStatistics().

◆ procedureTransferTracing_

bool SimulatorFrontend::procedureTransferTracing_
protected

Is procedure transfer access tracking enabled.

Definition at line 319 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), procedureTransferTracing(), and setProcedureTransferTracing().

◆ procedureTransferTrackers_

std::vector<ProcedureTransferTracker*> SimulatorFrontend::procedureTransferTrackers_
protected

The procedure transfer tracker.

Definition at line 341 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), and initializeTracing().

◆ programErrorReports_

ProgramErrorDescriptionList SimulatorFrontend::programErrorReports_
protected

◆ programFileName_

std::string SimulatorFrontend::programFileName_
protected

The source file of the program to be simulated. Used to generate the file name of the trace data base.

Definition at line 302 of file SimulatorFrontend.hh.

Referenced by initializeTracing(), loadProgram(), and ~SimulatorFrontend().

◆ programOwnedByFrontend_

bool SimulatorFrontend::programOwnedByFrontend_
protected

Is the program owned by SimulatorFrontend or by the client?

Definition at line 304 of file SimulatorFrontend.hh.

Referenced by loadMachine(), loadMachine(), loadProgram(), loadProgram(), and ~SimulatorFrontend().

◆ rfAccessTracing_

bool SimulatorFrontend::rfAccessTracing_
protected

Is register file (concurrent) access tracking enabled.

Definition at line 317 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), rfAccessTracing(), and setRFAccessTracing().

◆ rfAccessTrackers_

std::vector<RFAccessTracker*> SimulatorFrontend::rfAccessTrackers_
protected

The register file access tracker.

Definition at line 338 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), and rfAccessTracker().

◆ saveProfileData_

bool SimulatorFrontend::saveProfileData_
protected

Is saving of profile data to TraceDB enabled.

Definition at line 321 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), profileDataSaving(), and setProfileDataSaving().

◆ saveUtilizationData_

bool SimulatorFrontend::saveUtilizationData_
protected

Is saving of utilization data to TraceDB enabled.

Definition at line 323 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), setUtilizationDataSaving(), and utilizationDataSaving().

◆ simCon_

TTASimulationController* SimulatorFrontend::simCon_
protected

◆ simulationTimeout_

unsigned int SimulatorFrontend::simulationTimeout_
protected

Simulation timeout in seconds.

Definition at line 382 of file SimulatorFrontend.hh.

Referenced by next(), run(), runUntil(), and setTimeout().

◆ startCycleCount_

CycleCount SimulatorFrontend::startCycleCount_
protected

The cycle count when the latest simulation was started. Used to compute simulation speed.

Definition at line 380 of file SimulatorFrontend.hh.

Referenced by startTimer(), and stopTimer().

◆ startTime_

std::time_t SimulatorFrontend::startTime_
protected

The time of the last simulation start. Used to compute simulation speed.

Definition at line 377 of file SimulatorFrontend.hh.

Referenced by startTimer(), and stopTimer().

◆ staticCompilation_

bool SimulatorFrontend::staticCompilation_
protected

True if the compiled simulation should use static compilation.

Definition at line 360 of file SimulatorFrontend.hh.

Referenced by setStaticCompilation(), and staticCompilation().

◆ stopPointManager_

StopPointManager* SimulatorFrontend::stopPointManager_
protected

The breakpoint manager to be used to bookkeep breakpoints.

Definition at line 344 of file SimulatorFrontend.hh.

Referenced by initializeSimulation(), stopPointManager(), and ~SimulatorFrontend().

◆ tpef_

TPEF::Binary* SimulatorFrontend::tpef_
protected

The source TPEF file.

Definition at line 350 of file SimulatorFrontend.hh.

Referenced by initializeDataMemories(), loadProgram(), and ~SimulatorFrontend().

◆ traceDBOwned_

std::vector<bool> SimulatorFrontend::traceDBOwned_
protected

Whether traceDB at index is owned by simulator (or taken away by client using lastTraceDB())

Definition at line 328 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), and lastTraceDB().

◆ traceDBs_

std::vector<ExecutionTrace*> SimulatorFrontend::traceDBs_
protected

The database to use for execution trace data.

Definition at line 325 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), initializeTracing(), and lastTraceDB().

◆ traceFileNameSetByUser_

bool SimulatorFrontend::traceFileNameSetByUser_
protected

Flag that indicates is the trace file name set by user.

Definition at line 362 of file SimulatorFrontend.hh.

◆ utilizationStats_

std::vector<UtilizationStats*> SimulatorFrontend::utilizationStats_
protected

Processor utilization statistics.

Definition at line 347 of file SimulatorFrontend.hh.

Referenced by finishSimulation(), next(), run(), runUntil(), step(), and utilizationStatistics().

◆ zeroFillMemoriesOnReset_

bool SimulatorFrontend::zeroFillMemoriesOnReset_
protected

Set to true in case the memories should be set to zero at reset.

Definition at line 399 of file SimulatorFrontend.hh.

Referenced by initializeDataMemories(), and setZeroFillMemoriesOnReset().


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