OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
SimpleSimulatorFrontend Class Reference

#include <SimpleSimulatorFrontend.hh>

Inheritance diagram for SimpleSimulatorFrontend:
Inheritance graph
Collaboration diagram for SimpleSimulatorFrontend:
Collaboration graph

Public Member Functions

 SimpleSimulatorFrontend (TCEString machineFile, bool useCompiledSimulation=false)
 
 SimpleSimulatorFrontend (TCEString machineFile, TCEString programFile, bool useCompiledSimulation=false, bool useDetailedSimulation=false)
 
 SimpleSimulatorFrontend (const TTAMachine::Machine &machine, const TTAProgram::Program &program)
 
virtual ~SimpleSimulatorFrontend ()
 
void step ()
 
void run ()
 
void stop ()
 
uint64_t cycleCount () const
 
bool isInitialized () const
 
bool isStopped () const
 
bool isRunning () const
 
bool isFinished () const
 
bool hadRuntimeError () const
 
virtual void setOperationSimulator (const TCEString &fuName, DetailedOperationSimulator &sim)
 
MemorySystemmemorySystem ()
 
void initializeDataMemories (const TTAMachine::AddressSpace *onlyOne=NULL)
 
void loadProgram (const std::string &fileName)
 
const TTAMachine::Machinemachine () const
 
const TTAProgram::Programprogram () const
 
SimulatorFrontendfrontend ()
 
virtual bool registerEventListener (int event, Listener *listener)
 
virtual bool unregisterEventListener (int event, Listener *listener)
 

Private Attributes

SimulatorFrontendsimFront_
 

Detailed Description

Simplified simulator frontend e.g. for calling from system level simulators without needing to include the huge SimulatorFrontend.hh with lots of include deps.

Definition at line 58 of file SimpleSimulatorFrontend.hh.

Constructor & Destructor Documentation

◆ SimpleSimulatorFrontend() [1/3]

SimpleSimulatorFrontend::SimpleSimulatorFrontend ( TCEString  machineFile,
bool  useCompiledSimulation = false 
)

Definition at line 38 of file SimpleSimulatorFrontend.cc.

39  {
40  simFront_ =
42  useCompiledSimulation ?
46  try {
47  simFront_->loadMachine(machineFile);
48  } catch (Exception& e) {
49  std::cerr
50  << e.errorMessage() + " in " +
51  e.fileName() + ":" +
52  e.procedureName() + ":"
53  << e.lineNum() << std::endl;
54  abort();
55  }
56 }

References Exception::errorMessage(), Exception::fileName(), Exception::lineNum(), SimulatorFrontend::loadMachine(), Exception::procedureName(), SimulatorFrontend::setZeroFillMemoriesOnReset(), SimulatorFrontend::SIM_COMPILED, SimulatorFrontend::SIM_NORMAL, and simFront_.

Here is the call graph for this function:

◆ SimpleSimulatorFrontend() [2/3]

SimpleSimulatorFrontend::SimpleSimulatorFrontend ( TCEString  machineFile,
TCEString  programFile,
bool  useCompiledSimulation = false,
bool  useDetailedSimulation = false 
)

Definition at line 58 of file SimpleSimulatorFrontend.cc.

60  {
61  simFront_ =
63  useCompiledSimulation ?
67  simFront_->setDetailedSimulation(useDetailedSimulation);
68  try {
69  simFront_->loadMachine(machineFile);
70  simFront_->loadProgram(programFile);
71  } catch (Exception& e) {
72  std::cerr
73  << e.errorMessage() + " in " +
74  e.fileName() + ":" +
75  e.procedureName() + ":"
76  << e.lineNum() << std::endl;
77  abort();
78  }
79 }

References Exception::errorMessage(), Exception::fileName(), Exception::lineNum(), SimulatorFrontend::loadMachine(), SimulatorFrontend::loadProgram(), Exception::procedureName(), SimulatorFrontend::setDetailedSimulation(), SimulatorFrontend::setZeroFillMemoriesOnReset(), SimulatorFrontend::SIM_COMPILED, SimulatorFrontend::SIM_NORMAL, and simFront_.

Here is the call graph for this function:

◆ SimpleSimulatorFrontend() [3/3]

SimpleSimulatorFrontend::SimpleSimulatorFrontend ( const TTAMachine::Machine machine,
const TTAProgram::Program program 
)

Definition at line 81 of file SimpleSimulatorFrontend.cc.

83  {
86  try {
89  } catch (Exception& e) {
90  std::cerr
91  << e.errorMessage() + " in " +
92  e.fileName() + ":" +
93  e.procedureName() + ":"
94  << e.lineNum() << std::endl;
95  abort();
96  }
97 
98 }

References Exception::errorMessage(), Exception::fileName(), Exception::lineNum(), SimulatorFrontend::loadMachine(), SimulatorFrontend::loadProgram(), machine(), Exception::procedureName(), program(), SimulatorFrontend::setZeroFillMemoriesOnReset(), and simFront_.

Here is the call graph for this function:

◆ ~SimpleSimulatorFrontend()

SimpleSimulatorFrontend::~SimpleSimulatorFrontend ( )
virtual

Definition at line 100 of file SimpleSimulatorFrontend.cc.

100  {
101  delete simFront_;
102 }

References simFront_.

Member Function Documentation

◆ cycleCount()

uint64_t SimpleSimulatorFrontend::cycleCount ( ) const

Definition at line 212 of file SimpleSimulatorFrontend.cc.

212  {
213  return simFront_->cycleCount();
214 }

References SimulatorFrontend::cycleCount(), and simFront_.

Here is the call graph for this function:

◆ frontend()

SimulatorFrontend& SimpleSimulatorFrontend::frontend ( )
inline

Definition at line 93 of file SimpleSimulatorFrontend.hh.

93 { return *simFront_; }

References simFront_.

◆ hadRuntimeError()

bool SimpleSimulatorFrontend::hadRuntimeError ( ) const

Definition at line 160 of file SimpleSimulatorFrontend.cc.

160  {
161  return simFront_->stopReasonCount() >= 1 &&
163 }

References simFront_, SRE_RUNTIME_ERROR, SimulatorFrontend::stopReason(), and SimulatorFrontend::stopReasonCount().

Here is the call graph for this function:

◆ initializeDataMemories()

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

Definition at line 217 of file SimpleSimulatorFrontend.cc.

218  {
220 }

References SimulatorFrontend::initializeDataMemories(), and simFront_.

Here is the call graph for this function:

◆ isFinished()

bool SimpleSimulatorFrontend::isFinished ( ) const

Definition at line 155 of file SimpleSimulatorFrontend.cc.

155  {
156  return simFront_->hasSimulationEnded();
157 }

References SimulatorFrontend::hasSimulationEnded(), and simFront_.

Here is the call graph for this function:

◆ isInitialized()

bool SimpleSimulatorFrontend::isInitialized ( ) const

Returns true in case the engine has the machine and the program loaded and is ready to execute, but has not been executed yet.

Definition at line 136 of file SimpleSimulatorFrontend.cc.

136  {
138 }

References SimulatorFrontend::isSimulationInitialized(), and simFront_.

Here is the call graph for this function:

◆ isRunning()

bool SimpleSimulatorFrontend::isRunning ( ) const

Definition at line 150 of file SimpleSimulatorFrontend.cc.

150  {
151  return simFront_->isSimulationRunning();
152 }

References SimulatorFrontend::isSimulationRunning(), and simFront_.

Here is the call graph for this function:

◆ isStopped()

bool SimpleSimulatorFrontend::isStopped ( ) const

Retruns true in case the engine has been initialized and is ready to be stepped.

Definition at line 145 of file SimpleSimulatorFrontend.cc.

145  {
146  return simFront_->isSimulationStopped();
147 }

References SimulatorFrontend::isSimulationStopped(), and simFront_.

Here is the call graph for this function:

◆ loadProgram()

void SimpleSimulatorFrontend::loadProgram ( const std::string &  fileName)

Definition at line 127 of file SimpleSimulatorFrontend.cc.

127  {
128  simFront_->loadProgram(fileName);
129 }

References SimulatorFrontend::loadProgram(), and simFront_.

Here is the call graph for this function:

◆ machine()

const TTAMachine::Machine & SimpleSimulatorFrontend::machine ( ) const

Definition at line 166 of file SimpleSimulatorFrontend.cc.

166  {
167  return simFront_->machine();
168 }

References SimulatorFrontend::machine(), and simFront_.

Referenced by SimpleSimulatorFrontend().

Here is the call graph for this function:

◆ memorySystem()

MemorySystem & SimpleSimulatorFrontend::memorySystem ( )

Definition at line 176 of file SimpleSimulatorFrontend.cc.

176  {
177  return simFront_->memorySystem();
178 }

References SimulatorFrontend::memorySystem(), and simFront_.

Here is the call graph for this function:

◆ program()

const TTAProgram::Program & SimpleSimulatorFrontend::program ( ) const

Definition at line 171 of file SimpleSimulatorFrontend.cc.

171  {
172  return simFront_->program();
173 }

References SimulatorFrontend::program(), and simFront_.

Referenced by SimpleSimulatorFrontend().

Here is the call graph for this function:

◆ registerEventListener()

bool SimpleSimulatorFrontend::registerEventListener ( int  event,
Listener listener 
)
virtual

Definition at line 201 of file SimpleSimulatorFrontend.cc.

201  {
202  return simFront_->eventHandler().registerListener(event, listener);
203 }

References SimulatorFrontend::eventHandler(), Informer::registerListener(), and simFront_.

Here is the call graph for this function:

◆ run()

void SimpleSimulatorFrontend::run ( )

Definition at line 111 of file SimpleSimulatorFrontend.cc.

111  {
112  simFront_->run();
113 }

References SimulatorFrontend::run(), and simFront_.

Here is the call graph for this function:

◆ setOperationSimulator()

void SimpleSimulatorFrontend::setOperationSimulator ( const TCEString fuName,
DetailedOperationSimulator sim 
)
virtual

Replaces all operation executors in the given FU with the given one.

Definition at line 185 of file SimpleSimulatorFrontend.cc.

186  {
187  try {
188  simFront_->machineState().fuState(fuName).
190  } catch (Exception& e) {
191  std::cerr
192  << e.errorMessage() + " in " +
193  e.fileName() + ":" +
194  e.procedureName() + ":"
195  << e.lineNum() << std::endl;
196  abort();
197  }
198 }

References Exception::errorMessage(), Exception::fileName(), MachineState::fuState(), Exception::lineNum(), SimulatorFrontend::machineState(), Exception::procedureName(), and simFront_.

Here is the call graph for this function:

◆ step()

void SimpleSimulatorFrontend::step ( )

Definition at line 105 of file SimpleSimulatorFrontend.cc.

105  {
107  simFront_->step();
108 }

References SimulatorFrontend::hasSimulationEnded(), simFront_, and SimulatorFrontend::step().

Referenced by TTACore::step().

Here is the call graph for this function:

◆ stop()

void SimpleSimulatorFrontend::stop ( )

Stops the current simulation.

This produces the same kind of stop as if the user pressed ctrl-c in the ttasim.

Definition at line 122 of file SimpleSimulatorFrontend.cc.

122  {
124 }

References SimulatorFrontend::prepareToStop(), simFront_, and SRE_USER_REQUESTED.

Here is the call graph for this function:

◆ unregisterEventListener()

bool SimpleSimulatorFrontend::unregisterEventListener ( int  event,
Listener listener 
)
virtual

Definition at line 206 of file SimpleSimulatorFrontend.cc.

207  {
208  return simFront_->eventHandler().unregisterListener(event, listener);
209 }

References SimulatorFrontend::eventHandler(), simFront_, and Informer::unregisterListener().

Here is the call graph for this function:

Member Data Documentation

◆ simFront_

SimulatorFrontend* SimpleSimulatorFrontend::simFront_
private

The documentation for this class was generated from the following files:
Exception::procedureName
std::string procedureName() const
Exception::lineNum
int lineNum() const
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
SimulatorFrontend::SIM_COMPILED
@ SIM_COMPILED
Compiled, faster simulation.
Definition: SimulatorFrontend.hh:103
SRE_USER_REQUESTED
@ SRE_USER_REQUESTED
User requested the simulation to stop explicitly, e.g., by pressing ctrl-c in the CLI.
Definition: SimulatorConstants.hh:66
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
SimulatorFrontend::initializeDataMemories
void initializeDataMemories(const TTAMachine::AddressSpace *onlyOne=NULL)
Definition: SimulatorFrontend.cc:440
SimulatorFrontend::run
virtual void run()
Definition: SimulatorFrontend.cc:997
SimpleSimulatorFrontend::simFront_
SimulatorFrontend * simFront_
Definition: SimpleSimulatorFrontend.hh:99
SimulatorFrontend::stopReasonCount
unsigned int stopReasonCount() const
Definition: SimulatorFrontend.cc:1344
Exception::fileName
std::string fileName() const
SimulatorFrontend::loadMachine
virtual void loadMachine(const std::string &fileName)
Definition: SimulatorFrontend.cc:534
SimpleSimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimpleSimulatorFrontend.cc:166
Informer::unregisterListener
virtual bool unregisterListener(int event, Listener *listener)
Definition: Informer.cc:104
Informer::registerListener
virtual bool registerListener(int event, Listener *listener)
Definition: Informer.cc:87
SimulatorFrontend::loadProgram
virtual void loadProgram(const std::string &fileName)
Definition: SimulatorFrontend.cc:299
SRE_RUNTIME_ERROR
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
Definition: SimulatorConstants.hh:68
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
SimulatorFrontend::isSimulationRunning
bool isSimulationRunning() const
Definition: SimulatorFrontend.cc:1260
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
SimulatorFrontend::step
virtual void step(double count=1)
Definition: SimulatorFrontend.cc:1034
SimulatorFrontend::memorySystem
MemorySystem & memorySystem(int coreId=-1)
Definition: SimulatorFrontend.cc:2121
SimulatorFrontend::eventHandler
SimulationEventHandler & eventHandler()
Definition: SimulatorFrontend.cc:2260
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
MachineState::fuState
FUState & fuState(const std::string &name)
Definition: MachineState.cc:133
SimulatorFrontend::setZeroFillMemoriesOnReset
void setZeroFillMemoriesOnReset(bool val)
Definition: SimulatorFrontend.hh:235
SimulatorFrontend::setDetailedSimulation
void setDetailedSimulation(bool val)
Definition: SimulatorFrontend.hh:238
SimulatorFrontend::stopReason
StopReason stopReason(unsigned int index) const
Definition: SimulatorFrontend.cc:1356
SimulatorFrontend::hasSimulationEnded
bool hasSimulationEnded() const
Definition: SimulatorFrontend.cc:1283
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
SimpleSimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimpleSimulatorFrontend.cc:171
SimulatorFrontend::isSimulationInitialized
bool isSimulationInitialized() const
Definition: SimulatorFrontend.cc:1228
SimpleSimulatorFrontend::setOperationSimulator
virtual void setOperationSimulator(const TCEString &fuName, DetailedOperationSimulator &sim)
Definition: SimpleSimulatorFrontend.cc:185
SimulatorFrontend::prepareToStop
void prepareToStop(StopReason reason)
Definition: SimulatorFrontend.cc:1331
SimulatorFrontend::SIM_NORMAL
@ SIM_NORMAL
Default, interpreted simulation (debugging engine).
Definition: SimulatorFrontend.hh:102