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

#include <SimulatorCmdLineOptions.hh>

Inheritance diagram for SimulatorCmdLineOptions:
Inheritance graph
Collaboration diagram for SimulatorCmdLineOptions:
Collaboration graph

Public Member Functions

 SimulatorCmdLineOptions ()
 
virtual ~SimulatorCmdLineOptions ()
 
virtual void printVersion () const
 
virtual void printHelp () const
 
bool debugMode ()
 
std::string scriptString ()
 
std::string machineFile ()
 
std::string programFile ()
 
SimulatorFrontend::SimulationType backendType ()
 
- Public Member Functions inherited from CmdLineOptions
 CmdLineOptions (std::string description, std::string version="")
 
virtual ~CmdLineOptions ()
 
void parse (char *argv[], int argc)
 
void parse (std::string argv[], int argc)
 
void parse (std::vector< std::string > argv)
 
virtual bool isVerboseSwitchDefined () const
 
virtual bool isVerboseSpamSwitchDefined () const
 
- Public Member Functions inherited from CmdLineParser
 CmdLineParser (std::string description)
 
virtual ~CmdLineParser ()
 
virtual void storeOptions (Options &options)
 
virtual int numberOfArguments () const
 
virtual std::string argument (int index) const
 

Private Member Functions

 SimulatorCmdLineOptions (const SimulatorCmdLineOptions &)
 Copying not allowed. More...
 
SimulatorCmdLineOptionsoperator= (const SimulatorCmdLineOptions &)
 Assignment not allowed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CmdLineOptions
bool optionGiven (std::string key) const
 
- Protected Member Functions inherited from CmdLineParser
void addOption (CmdLineOptionParser *opt)
 
CmdLineOptionParserfindOption (std::string name) const
 
bool parseOption (std::string option, std::string &name, std::string &arguments, std::string &prefix, bool &hasArgument) const
 
bool readPrefix (std::string &option, std::string &prefix, bool &longOption) const
 
bool isPrefix (std::string name) const
 
- Protected Attributes inherited from CmdLineParser
std::map< std::string, CmdLineOptionParser * > optionLongNames_
 Database for holding options with their long names as a key. More...
 
std::map< std::string, CmdLineOptionParser * > optionShortNames_
 Database for holding options with their short names as a key. More...
 
std::vector< std::string > commandLine_
 Command line is stored here. More...
 
std::vector< std::string > arguments_
 Command line arguments are stored here. More...
 
std::vector< std::string > prefixes_
 Legal prefixes are stored here. More...
 

Detailed Description

Command line option class for Simulator.

Definition at line 45 of file SimulatorCmdLineOptions.hh.

Constructor & Destructor Documentation

◆ SimulatorCmdLineOptions() [1/2]

SimulatorCmdLineOptions::SimulatorCmdLineOptions ( )

Constructor.

Todo:
Use textgenerator in the help texts.

Definition at line 82 of file SimulatorCmdLineOptions.cc.

82  : CmdLineOptions("") {
83  addOption(
85  SWL_DEBUG_MODE, "starts simulator in debugging mode (default), "
86  "use --no-debugmode to disable",
88  addOption(
90  SWL_EXECUTE_SCRIPT, "executes the given string as a script in the "
91  "simulator control language script interpreter, "
92  "e.g. -e \"stepi 10000\" executes simulation for 10000 cycles",
94 
95  addOption(
97  SWL_MACHINE_TO_LOAD, "sets the machine file (.adf) to be loaded.",
99 
100  addOption(
102  SWL_PROGRAM_TO_LOAD, "sets the program file to be loaded.",
104 
105  addOption(
107  SWL_FAST_SIM, "uses the fast simulation engine.",
108  SWS_FAST_SIM));
109 
110  addOption(
112  SWL_REMOTE_DBG, "connect to a remote debugging interface on an FPGA or ASIC.",
113  SWS_REMOTE_DBG));
114 
115  addOption(
117  SWL_CUSTOM_DBG, "connect to a custom remote debugger (if implemented).",
118  SWS_CUSTOM_DBG));
119 }

References CmdLineParser::addOption(), SWL_CUSTOM_DBG, SWL_DEBUG_MODE, SWL_EXECUTE_SCRIPT, SWL_FAST_SIM, SWL_MACHINE_TO_LOAD, SWL_PROGRAM_TO_LOAD, SWL_REMOTE_DBG, SWS_CUSTOM_DBG, SWS_DEBUG_MODE, SWS_EXECUTE_SCRIPT, SWS_FAST_SIM, SWS_MACHINE_TO_LOAD, SWS_PROGRAM_TO_LOAD, and SWS_REMOTE_DBG.

Here is the call graph for this function:

◆ ~SimulatorCmdLineOptions()

SimulatorCmdLineOptions::~SimulatorCmdLineOptions ( )
virtual

Destructor.

Definition at line 124 of file SimulatorCmdLineOptions.cc.

124  {
125 }

◆ SimulatorCmdLineOptions() [2/2]

SimulatorCmdLineOptions::SimulatorCmdLineOptions ( const SimulatorCmdLineOptions )
private

Copying not allowed.

Member Function Documentation

◆ backendType()

SimulatorFrontend::SimulationType SimulatorCmdLineOptions::backendType ( )

Check what sort of simulation user asked for on the command line.

If no value is given in the parsed command line the "normal" simulation, i.e. the interpreted, non-compiled, version is returned.

Returns
type of TTA backend user wants

Definition at line 209 of file SimulatorCmdLineOptions.cc.

209  {
210 
211  bool wantCompiled = false;
212  bool wantRemote = false;
213  bool wantCustom = false;
214 
215  wantCompiled |= optionGiven(SWL_FAST_SIM);
216  wantCompiled &= findOption(SWL_FAST_SIM)->isFlagOn();
217 
218  wantRemote |= optionGiven(SWL_REMOTE_DBG);
219  wantRemote &= findOption(SWL_REMOTE_DBG)->isFlagOn();
220 
221  wantCustom |= optionGiven(SWL_CUSTOM_DBG);
222  wantCustom &= findOption(SWL_CUSTOM_DBG)->isFlagOn();
223 
224  // TODO: no check for if user requests simultaneously several
225  // versions of TTA backend. Start with the most picky one,
226  // user probably notices it erroring out.
227  if (wantCustom) return SimulatorFrontend::SIM_CUSTOM;
228  if (wantRemote) return SimulatorFrontend::SIM_REMOTE;
229  if (wantCompiled) return SimulatorFrontend::SIM_COMPILED;
231 }

References CmdLineParser::findOption(), CmdLineOptionParser::isFlagOn(), CmdLineOptions::optionGiven(), SimulatorFrontend::SIM_COMPILED, SimulatorFrontend::SIM_CUSTOM, SimulatorFrontend::SIM_NORMAL, SimulatorFrontend::SIM_REMOTE, SWL_CUSTOM_DBG, SWL_FAST_SIM, and SWL_REMOTE_DBG.

Here is the call graph for this function:

◆ debugMode()

bool SimulatorCmdLineOptions::debugMode ( )

Returns true if Simulator should be started in debugging mode.

If no value is given in the parsed command line, default one is returned.

Returns
True if Simulator should be started in debugging mode.

Definition at line 158 of file SimulatorCmdLineOptions.cc.

158  {
159  if (!optionGiven(SWL_DEBUG_MODE)) {
160  return true;
161  }
163 }

References CmdLineParser::findOption(), CmdLineOptionParser::isFlagOn(), CmdLineOptions::optionGiven(), and SWL_DEBUG_MODE.

Here is the call graph for this function:

◆ machineFile()

std::string SimulatorCmdLineOptions::machineFile ( )

Returns the filename of the given machine (.adf)

Returns
the filename of the given machine (.adf)

Definition at line 186 of file SimulatorCmdLineOptions.cc.

186  {
188 }

References CmdLineParser::findOption(), CmdLineOptionParser::String(), and SWS_MACHINE_TO_LOAD.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ printHelp()

void SimulatorCmdLineOptions::printHelp ( ) const
virtual

Prints the help menu of the program.

Todo:
Implement using SimulatorTextGenerator.

Reimplemented from CmdLineOptions.

Definition at line 142 of file SimulatorCmdLineOptions.cc.

142  {
143  printVersion();
144  std::cout << std::endl << SimulatorToolbox::textGenerator().text(
145  Texts::TXT_CMD_LINE_HELP).str() << std::endl;
147 }

References CmdLineOptions::printHelp(), printVersion(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), and Texts::TXT_CMD_LINE_HELP.

Here is the call graph for this function:

◆ printVersion()

void SimulatorCmdLineOptions::printVersion ( ) const
virtual

Prints the version of the program.

Implements CmdLineOptions.

Definition at line 131 of file SimulatorCmdLineOptions.cc.

131  {
132  std::cout << SIM_CLI_TITLE << " " << Application::TCEVersionString()
133  << std::endl;
134 }

References SIM_CLI_TITLE, and Application::TCEVersionString().

Referenced by printHelp().

Here is the call graph for this function:

◆ programFile()

std::string SimulatorCmdLineOptions::programFile ( )

Returns the filename of the given program

Returns
the filename of the given program

Definition at line 196 of file SimulatorCmdLineOptions.cc.

196  {
198 }

References CmdLineParser::findOption(), CmdLineOptionParser::String(), and SWS_PROGRAM_TO_LOAD.

Here is the call graph for this function:

◆ scriptString()

std::string SimulatorCmdLineOptions::scriptString ( )

Returns the script to be executed in the interpreter.

Returns an empty string, if none defined.

Returns
Script string.

Definition at line 173 of file SimulatorCmdLineOptions.cc.

173  {
175  return "";
176  }
178 }

References CmdLineParser::findOption(), CmdLineOptions::optionGiven(), CmdLineOptionParser::String(), and SWL_EXECUTE_SCRIPT.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
SWL_EXECUTE_SCRIPT
const std::string SWL_EXECUTE_SCRIPT
Long switch string for giving a script to be executed.
Definition: SimulatorCmdLineOptions.cc:48
SimulatorFrontend::SIM_REMOTE
@ SIM_REMOTE
Remote debugger, not a simulator at all.
Definition: SimulatorFrontend.hh:104
SimulatorFrontend::SIM_COMPILED
@ SIM_COMPILED
Compiled, faster simulation.
Definition: SimulatorFrontend.hh:103
SWS_PROGRAM_TO_LOAD
const std::string SWS_PROGRAM_TO_LOAD
Short switch string for giving the program file.
Definition: SimulatorCmdLineOptions.cc:60
SWL_CUSTOM_DBG
const std::string SWL_CUSTOM_DBG
Long switch string for the custom remote debugger target.
Definition: SimulatorCmdLineOptions.cc:68
SWL_MACHINE_TO_LOAD
const std::string SWL_MACHINE_TO_LOAD
Long switch string for giving a machine file.
Definition: SimulatorCmdLineOptions.cc:53
SWS_MACHINE_TO_LOAD
const std::string SWS_MACHINE_TO_LOAD
Short switch string for giving a machine file.
Definition: SimulatorCmdLineOptions.cc:55
Texts::TXT_CMD_LINE_HELP
@ TXT_CMD_LINE_HELP
Definition: SimulatorTextGenerator.hh:111
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimulatorCmdLineOptions::printVersion
virtual void printVersion() const
Definition: SimulatorCmdLineOptions.cc:131
SIM_CLI_TITLE
#define SIM_CLI_TITLE
The full title name of the CLI application.
Definition: SimulatorConstants.hh:54
SWL_FAST_SIM
const std::string SWL_FAST_SIM
Long switch string for the fast simulation.
Definition: SimulatorCmdLineOptions.cc:63
CmdLineOptionParser::isFlagOn
virtual bool isFlagOn() const
Definition: CmdLineOptionParser.cc:126
SWS_REMOTE_DBG
const std::string SWS_REMOTE_DBG
Short switch string for the TCE builtin remote debugger target.
Definition: SimulatorCmdLineOptions.cc:75
CmdLineOptions::optionGiven
bool optionGiven(std::string key) const
Definition: CmdLineOptions.cc:320
SWL_DEBUG_MODE
const std::string SWL_DEBUG_MODE
Long switch string for setting the debug mode.
Definition: SimulatorCmdLineOptions.cc:43
CmdLineParser::addOption
void addOption(CmdLineOptionParser *opt)
CmdLineOptions::CmdLineOptions
CmdLineOptions(std::string description, std::string version="")
Definition: CmdLineOptions.cc:73
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
BoolCmdLineOptionParser
Definition: CmdLineOptionParser.hh:278
CmdLineOptions::printHelp
virtual void printHelp() const
Definition: CmdLineOptions.cc:262
SimulatorFrontend::SIM_CUSTOM
@ SIM_CUSTOM
User-implemented remote HW debugger.
Definition: SimulatorFrontend.hh:105
CmdLineOptionParser::String
virtual std::string String(int index=0) const
Definition: CmdLineOptionParser.cc:102
SWS_FAST_SIM
const std::string SWS_FAST_SIM
Short switch string for the fast simulation.
Definition: SimulatorCmdLineOptions.cc:65
SWS_EXECUTE_SCRIPT
const std::string SWS_EXECUTE_SCRIPT
Short switch string for giving a script to be executed.
Definition: SimulatorCmdLineOptions.cc:50
SWL_PROGRAM_TO_LOAD
const std::string SWL_PROGRAM_TO_LOAD
Long switch string for giving the program file.
Definition: SimulatorCmdLineOptions.cc:58
CmdLineParser::findOption
CmdLineOptionParser * findOption(std::string name) const
Definition: CmdLineParser.cc:160
SWS_CUSTOM_DBG
const std::string SWS_CUSTOM_DBG
Short switch string for the custom remote debugger target.
Definition: SimulatorCmdLineOptions.cc:70
Application::TCEVersionString
static std::string TCEVersionString()
Definition: Application.cc:510
StringCmdLineOptionParser
Definition: CmdLineOptionParser.hh:180
SWS_DEBUG_MODE
const std::string SWS_DEBUG_MODE
Short switch string for setting the debug mode.
Definition: SimulatorCmdLineOptions.cc:45
SWL_REMOTE_DBG
const std::string SWL_REMOTE_DBG
Long switch string for the TCE builtin remote debugger target.
Definition: SimulatorCmdLineOptions.cc:73
SimulatorFrontend::SIM_NORMAL
@ SIM_NORMAL
Default, interpreted simulation (debugging engine).
Definition: SimulatorFrontend.hh:102