OpenASIP 2.2
Loading...
Searching...
No Matches
SimulatorCmdLineOptions.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file SimulatorCmdLineOptions.cc
26 *
27 * Declaration of SimulatorCmdLineOptions.
28 *
29 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30 * @author Viljami Korhonen 2007 (viljami.korhonen-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include <iostream>
35
36#include "SimulatorToolbox.hh"
38#include "SimulatorConstants.hh"
39#include "CmdLineOptions.hh"
41
42/// Long switch string for setting the debug mode.
43const std::string SWL_DEBUG_MODE = "debugmode";
44/// Short switch string for setting the debug mode.
45const std::string SWS_DEBUG_MODE = "d";
46
47/// Long switch string for giving a script to be executed.
48const std::string SWL_EXECUTE_SCRIPT = "execute-script";
49/// Short switch string for giving a script to be executed.
50const std::string SWS_EXECUTE_SCRIPT= "e";
51
52/// Long switch string for giving a machine file.
53const std::string SWL_MACHINE_TO_LOAD = "adf";
54/// Short switch string for giving a machine file.
55const std::string SWS_MACHINE_TO_LOAD= "a";
56
57/// Long switch string for giving the program file
58const std::string SWL_PROGRAM_TO_LOAD = "program";
59/// Short switch string for giving the program file
60const std::string SWS_PROGRAM_TO_LOAD= "p";
61
62/// Long switch string for the fast simulation
63const std::string SWL_FAST_SIM = "quick";
64/// Short switch string for the fast simulation
65const std::string SWS_FAST_SIM= "q";
66
67/// Long switch string for the custom remote debugger target
68const std::string SWL_CUSTOM_DBG = "custom";
69/// Short switch string for the custom remote debugger target
70const std::string SWS_CUSTOM_DBG = "c";
71
72/// Long switch string for the TCE builtin remote debugger target
73const std::string SWL_REMOTE_DBG = "remote";
74/// Short switch string for the TCE builtin remote debugger target
75const std::string SWS_REMOTE_DBG = "r";
76
77/**
78 * Constructor.
79 *
80 * @todo Use textgenerator in the help texts.
81 */
85 SWL_DEBUG_MODE, "starts simulator in debugging mode (default), "
86 "use --no-debugmode to disable",
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
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.",
114
115 addOption(
117 SWL_CUSTOM_DBG, "connect to a custom remote debugger (if implemented).",
119}
120
121/**
122 * Destructor.
123 */
126
127/**
128 * Prints the version of the program.
129 */
130void
132 std::cout << SIM_CLI_TITLE << " " << Application::TCEVersionString()
133 << std::endl;
134}
135
136/**
137 * Prints the help menu of the program.
138 *
139 * @todo Implement using SimulatorTextGenerator.
140 */
141void
143 printVersion();
144 std::cout << std::endl << SimulatorToolbox::textGenerator().text(
145 Texts::TXT_CMD_LINE_HELP).str() << std::endl;
147}
148
149
150/**
151 * Returns true if Simulator should be started in debugging mode.
152 *
153 * If no value is given in the parsed command line, default one is returned.
154 *
155 * @return True if Simulator should be started in debugging mode.
156 */
157bool
160 return true;
161 }
163}
164
165/**
166 * Returns the script to be executed in the interpreter.
167 *
168 * Returns an empty string, if none defined.
169 *
170 * @return Script string.
171 */
172std::string
179
180/**
181 * Returns the filename of the given machine (.adf)
182 *
183 * @return the filename of the given machine (.adf)
184 */
185std::string
189
190/**
191 * Returns the filename of the given program
192 *
193 * @return the filename of the given program
194 */
195std::string
199
200/**
201 * Check what sort of simulation user asked for on the command line.
202 *
203 * If no value is given in the parsed command line the "normal" simulation,
204 * i.e. the interpreted, non-compiled, version is returned.
205 *
206 * @return type of TTA backend user wants
207 */
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}
232
const std::string SWL_CUSTOM_DBG
Long switch string for the custom remote debugger target.
const std::string SWS_CUSTOM_DBG
Short switch string for the custom remote debugger target.
const std::string SWS_DEBUG_MODE
Short switch string for setting the debug mode.
const std::string SWL_DEBUG_MODE
Long switch string for setting the debug mode.
const std::string SWS_PROGRAM_TO_LOAD
Short switch string for giving the program file.
const std::string SWL_PROGRAM_TO_LOAD
Long switch string for giving the program file.
const std::string SWS_REMOTE_DBG
Short switch string for the TCE builtin remote debugger target.
const std::string SWS_MACHINE_TO_LOAD
Short switch string for giving a machine file.
const std::string SWL_REMOTE_DBG
Long switch string for the TCE builtin remote debugger target.
const std::string SWL_EXECUTE_SCRIPT
Long switch string for giving a script to be executed.
const std::string SWL_MACHINE_TO_LOAD
Long switch string for giving a machine file.
const std::string SWS_EXECUTE_SCRIPT
Short switch string for giving a script to be executed.
const std::string SWS_FAST_SIM
Short switch string for the fast simulation.
const std::string SWL_FAST_SIM
Long switch string for the fast simulation.
#define SIM_CLI_TITLE
The full title name of the CLI application.
static std::string TCEVersionString()
virtual bool isFlagOn() const
virtual std::string String(int index=0) const
bool optionGiven(std::string key) const
virtual void printHelp() const
CmdLineOptionParser * findOption(std::string name) const
void addOption(CmdLineOptionParser *opt)
SimulatorFrontend::SimulationType backendType()
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_COMPILED
Compiled, faster simulation.
@ SIM_NORMAL
Default, interpreted simulation (debugging engine).
static SimulatorTextGenerator & textGenerator()
virtual boost::format text(int textId)