OpenASIP 2.2
Loading...
Searching...
No Matches
PIGCmdLineOptions.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2011 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 PIGCmdLineOptions.cc
26 *
27 * Implementation of PIGCmdLineOptions class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @author Otto Esko 2008 (otto.esko-no.spam-tut.fi)
31 * @author Pekka Jääskeläinen 2011
32 * @note rating: red
33 */
34
35#include <iostream>
36
37#include "PIGCmdLineOptions.hh"
39
40using std::string;
41
42const std::string PIGCmdLineOptions::BEM_PARAM_NAME = "bem";
43const std::string PIGCmdLineOptions::TPEF_PARAM_NAME = "program";
44const std::string PIGCmdLineOptions::PI_FORMAT_PARAM_NAME = "piformat";
45const std::string PIGCmdLineOptions::DI_FORMAT_PARAM_NAME = "diformat";
46const std::string PIGCmdLineOptions::COMPRESSOR_PARAM_NAME = "compressor";
47const std::string PIGCmdLineOptions::DATA_IMG_PARAM_NAME = "dataimages";
48const std::string PIGCmdLineOptions::GEN_DECOMP_PARAM_NAME = "decompressor";
50 "dmemwidthinmaus";
52 "compressor param";
54 "showcompressors";
55const std::string PIGCmdLineOptions::HDL_OUTPUT_DIR = "hdl-dir";
56const std::string PIGCmdLineOptions::DATA_START = "data-start";
57const string ENTITY_NAME = "entity-name";
58
59/**
60 * The constructor.
61 */
63
66 TPEF_PARAM_NAME, "The TPEF program file(s)", "p");
68
70 BEM_PARAM_NAME, "The BEM file", "b");
72
75 "The output format of program image(s) ('ascii', 'array', 'mif', "
76 "'coe', 'vhdl', 'hex', 'binary' or 'bin2n'). Default is 'ascii'.",
77 "f");
78 addOption(piOutputMode);
79
81 DI_FORMAT_PARAM_NAME, "The output format of data image(s) "
82 "('ascii', 'array', 'mif', 'coe', 'vhdl', 'hex', 'bin2n' or 'binary'). Default "
83 "is 'ascii'.", "o");
84 addOption(diOutputMode);
85
87 COMPRESSOR_PARAM_NAME, "Name of the code compressor plugin file.",
88 "c");
89 addOption(pluginFile);
90
93 "Create data images.",
94 "d");
95 addOption(createDataImages);
96
97 BoolCmdLineOptionParser* createDecompressor =
99 GEN_DECOMP_PARAM_NAME, "Generate decompressor block.", "g");
100 addOption(createDecompressor);
101
102 IntegerCmdLineOptionParser* dmemMAUsPerLine =
105 "Width of data memory in MAUs. Default is 1.", "w");
106 addOption(dmemMAUsPerLine);
107
108 StringListCmdLineOptionParser* compressorParams =
111 "Parameter to the code compressor in form 'name=value'.", "u");
112 addOption(compressorParams);
113
115 SHOW_COMPRESSORS_PARAM_NAME, "Show compressor plugin descriptions.",
116 "s");
118
119 string hdlDirDesc("Directory root where ProGe generated HDL files. "
120 "Generatebits will write imem_mau_pkg and "
121 "decompressor, if it is needed, under the given "
122 "directory. Otherwise they are written to cwd.");
123
125 HDL_OUTPUT_DIR, hdlDirDesc, "x");
126 addOption(hdlDir);
127
128 string dataStartDesc(
129 "Data-start option is used "
130 "to set the global data start address for the address spaces. "
131 "The default is the first address of the address space. "
132 "data-start option must either be just the start "
133 "of the default address space (a single unsigned integer), "
134 "or a list consisting of pairs: "
135 "<Address-Space Name>,<Address-Space Start>");
137 new StringListCmdLineOptionParser(DATA_START, dataStartDesc);
139
143 "String to use to make the generated VHDL entities unique. This "
144 "should be the same which was given to ProGe when the processor "
145 "was generated (default is 'tta0').", "e");
147}
148
149
150/**
151 * The destructor.
152 */
155
156
157/**
158 * Returns the name of the BEM file given as command line parameter.
159 *
160 * @return The name of the BEM file.
161 */
162std::string
166
167
168/**
169 * Returns the number of TPEF files given.
170 *
171 * @return The number of TPEF files.
172 */
173int
177
178
179/**
180 * Returns the name of the TPEF file given as command line parameter.
181 *
182 * @return The name of the TPEF file.
183 */
184std::string
187 if (index < 0 || index >= tpefFileCount()) {
188 throw OutOfRange(__FILE__, __LINE__, __func__);
189 }
190
191 return option->String(index + 1);
192}
193
194/**
195 * Returns the program image output format given as command line parameter.
196 *
197 * @return The output format.
198 */
199std::string
203
204
205/**
206 * Returns the data image output format given as command line parameter.
207 *
208 * @return The output format.
209 */
210std::string
214
215
216/**
217 * Returns the code compressor plugin file name.
218 *
219 * @return The plugin file.
220 */
221std::string
225
226
227/**
228 * Returns the given width of data memory in MAUs.
229 *
230 * @return The width.
231 */
232int
236 if (option->isDefined()) {
237 return option->integer();
238 } else {
239 return 1;
240 }
241}
242
243
244/**
245 * Tells whether to create data images or not.
246 */
247bool
251
252
253/**
254 * Tells whether to generate decompressor block or not.
255 */
256bool
260
261
262/**
263 * Returns the number of parameters given to compressor.
264 *
265 * @return The number of parameters.
266 */
267int
271
272
273/**
274 * By the given index, returns a parameter given to code compressor.
275 *
276 * @param index The index.
277 * @exception OutOfRange If the given index is negative or not smaller than
278 * the number of parameters given to compressor.
279 */
280std::string
282 if (index < 0 || index >= compressorParameterCount()) {
283 throw OutOfRange(__FILE__, __LINE__, __func__);
284 }
285
287}
288
289/**
290 * Tells whether to show code compressor descriptions or not.
291 */
292bool
296
297/**
298 * Returns the proge output directory. Empty if not given
299 *
300 * @return proge output directory
301 */
302std::string
306
311
312std::string
316
317
318/**
319 * Prints the version of the user interface.
320 */
321void
323 PIGCLITextGenerator textGenerator;
324 std::cerr <<
325 textGenerator.text(PIGCLITextGenerator::TXT_CLI_TITLE).str()
326 << " "
328 str() << std::endl;
329}
330
331
332/**
333 * Prints the help menu of the program.
334 */
335void
341
342
343/**
344 * Prints the usage of the CLI.
345 */
346void
348 PIGCLITextGenerator textGen;
349 std::cerr << textGen.text(PIGCLITextGenerator::TXT_CLI_USAGE).str()
350 << std::endl;
351}
#define __func__
const string ENTITY_NAME
virtual int integer(int index=0) const
virtual int listSize() const
virtual bool isFlagOn() const
virtual std::string String(int index=0) const
virtual void printHelp() const
CmdLineOptionParser * findOption(std::string name) const
void addOption(CmdLineOptionParser *opt)
virtual void printHelp() const
std::string programImageOutputFormat() const
std::string compressorPlugin() const
std::string dataImageOutputFormat() const
int dataMemoryWidthInMAUs() const
static const std::string DI_FORMAT_PARAM_NAME
Long name of the data image output format parameter.
std::string entityName() const
std::string tpefFile(int index) const
bool showCompressors() const
bool generateDataImages() const
bool generateDecompressor() const
static const std::string COMPRESSOR_PARAMS_PARAM_NAME
Long name of parameter passed to code compressor plugin.
static const std::string PI_FORMAT_PARAM_NAME
Long name of the program image output format parameter.
std::string compressorParameter(int index) const
static const std::string GEN_DECOMP_PARAM_NAME
Long name of the parameter that tells whether to generate decompressor or not.
static const std::string TPEF_PARAM_NAME
Long name of the TPEF file parameter.
static const std::string COMPRESSOR_PARAM_NAME
Long name of the plugin file parameter.
int compressorParameterCount() const
static const std::string DMEM_WIDTH_IN_MAUS_PARAM_NAME
Long name of the parameter that tells the width of data mem in MAUs.
static const std::string HDL_OUTPUT_DIR
Long name of the parameter which tells the proge-output dir.
CmdLineOptionParser * dataStart() const
static const std::string DATA_IMG_PARAM_NAME
Long name of the parameter that defines whether to create data images.
static const std::string BEM_PARAM_NAME
Long name of the BEM file parameter.
std::string progeOutputDirectory() const
virtual void printVersion() const
std::string bemFile() const
static const std::string DATA_START
static const std::string SHOW_COMPRESSORS_PARAM_NAME
Long name of the parameter that tells whether to show compressors.
virtual boost::format text(int textId)