OpenASIP 2.2
Loading...
Searching...
No Matches
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 ?
44 SimulatorFrontend::SIM_NORMAL);
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}
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
std::string procedureName() const
int lineNum() const
@ SIM_COMPILED
Compiled, faster simulation.
virtual void loadMachine(const std::string &fileName)
void setZeroFillMemoriesOnReset(bool val)

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 ?
65 SimulatorFrontend::SIM_NORMAL);
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}
void setDetailedSimulation(bool val)
virtual void loadProgram(const std::string &fileName)

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}
const TTAMachine::Machine & machine() const
const TTAProgram::Program & program() const

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}
ClockCycleCount cycleCount() const

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}
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
unsigned int stopReasonCount() const
StopReason stopReason(unsigned int index) const

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}
void initializeDataMemories(const TTAMachine::AddressSpace *onlyOne=NULL)

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 {
157}
bool hasSimulationEnded() const

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}
bool isSimulationInitialized() const

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 {
152}
bool isSimulationRunning() const

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 {
147}
bool isSimulationStopped() const

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}
const TTAMachine::Machine & machine() const

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}
MemorySystem & memorySystem(int coreId=-1)

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}
const TTAProgram::Program & program() const

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}
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
SimulationEventHandler & eventHandler()

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}
FUState & fuState(const std::string &name)
virtual void setOperationSimulator(const TCEString &fuName, DetailedOperationSimulator &sim)
MachineState & machineState(int core=-1)

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

Referenced by setOperationSimulator().

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}
virtual void step(double count=1)

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}
@ SRE_USER_REQUESTED
User requested the simulation to stop explicitly, e.g., by pressing ctrl-c in the CLI.
void prepareToStop(StopReason reason)

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}
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104

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: