OpenASIP 2.2
Loading...
Searching...
No Matches
ProGeCmdLineOptions.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 ProGeCmdLineOptions.cc
26 *
27 * Implementation of ProGeCmdLineOptions 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 * @note rating: red
32 */
33
34#include <iostream>
35#include <sstream>
37#include "tce_config.h"
38
39using std::string;
40using std::cout;
41using std::endl;
42
43const string BEM_PARAM_NAME = "bem";
44const string IDF_PARAM_NAME = "idf";
45const string ICDECODER_PARAM_NAME = "gen";
46const string HDL_PARAM_NAME = "hdl";
47const string OUTPUTDIR_PARAM_NAME = "output";
48const string SHARED_OUTPUTDIR_PARAM_NAME = "shared-files-dir";
49const string PLUGIN_PARAMETERS_PARAM_NAME = "pluginparameters";
50const string INTEGRATOR_NAME = "integrator";
51const string IMEM_TYPE = "imem";
52const string DMEM_TYPE = "dmem";
53const string CLK_FREQUENCY = "clock-frequency";
54const string TPEF_NAME = "program";
55const string ENTITY_NAME = "entity-name";
56const string USE_ABSOLUTE_PATHS = "absolute-paths";
57const string LIST_INTEGRATORS = "list-integrators";
58const string DEVICE_FAMILY = "device-family";
59const string DEVICE_NAME = "device-name";
60const string GENERATE_TESTBENCH = "generate-testbench";
61const string SIMULATION_RUNTIME = "sim-runtime";
62const string FORCE_OUTPUT = "force-output";
63const string FU_ICGATE_LIST = "fu-ic-gate";
64const string SYNC_RESET = "sync-reset";
65const string HDB_LIST = "hdb-list";
66const string ICD_ARG_LIST = "icd-arg-list";
67const string PREFER_GEN = "prefer-generation";
68const string RF_ICGATE_LIST = "rf-ic-gate";
69const string DONT_RESET_ALL = "dont-reset-all";
70const string FU_BACKREGISTER_LIST = "fu-back-register";
71const string FU_FRONTREGISTER_LIST = "fu-front-register";
72const string FU_MIDDLEREGISTER_LIST = "fu-middle-register";
73
74/**
75 * The constructor.
76 */
78 CmdLineOptions("") {
79
81 BEM_PARAM_NAME, "The BEM file", "b");
83
85 IDF_PARAM_NAME, "The IDF file", "i");
87
89 HDL_PARAM_NAME, "The HDL to generate. 'vhdl' = VHDL", "l");
90 addOption(hdlParam);
91
94 OUTPUTDIR_PARAM_NAME, "The output directory", "o");
96
100 "The directory for HDL files that are potentially shared between "
101 "multiple generated processors.", "s");
103
104 StringCmdLineOptionParser* pluginParameters =
106 PLUGIN_PARAMETERS_PARAM_NAME, "List plugin parameters for an "
107 "IC/Decoder generator plugin file.", "u");
108 addOption(pluginParameters);
109
112 INTEGRATOR_NAME, "Select the target for platform integration.",
113 "g");
115
117 IMEM_TYPE,
118 "Instruction memory type. Available types depends on "
119 "the platform integrator. Types are 'vhdl_array', 'onchip', "
120 "'sram', 'dram' and 'none'.",
121 "f");
123
126 DMEM_TYPE, "Data memory type. Available types depends on the "
127 "platform integrator. Types are 'vhdl_array', 'onchip', 'sram',"
128 " 'dram' and 'none'", "d");
130
133 CLK_FREQUENCY, "Defines the target clock frequency.", "c");
134 addOption(fmax);
135
136 StringCmdLineOptionParser* programName =
138 TPEF_NAME, "Name of tpef program.", "p");
139 addOption(programName);
140
143 "String to use to make the generated VHDL entities unique. This "
144 "is also used in the name of the top level entity platform "
145 "integrator creates. Default is 'tta0' for the core, thus "
146 "'tta0_toplevel' for the platform integrator top level "
147 "component.",
148 "e");
150
153 USE_ABSOLUTE_PATHS, "Use absolute paths in generated platform "
154 "integrator files.", "a");
156
159 GENERATE_TESTBENCH, "Generate testbench.", "t");
161
162 BoolCmdLineOptionParser* listIntegrators =
164 LIST_INTEGRATORS, "List available integrators and information "
165 "about them.", "n");
166 addOption(listIntegrators);
167
171 "Set FPGA device family for integration. Stand-alone integrators "
172 "may ignore this parameter. Example: \"Stratix II\" or "
173 "Stratix\\ II", "m");
175
178 "Set FPGA device family for integration. Stand-alone integrators "
179 "may ignore this parameter. Example: \"xc7z020clg400-1\"");
181
184 "The runtime of the simulation in nanoseconds. Default: 52390 ns",
185 "r");
186 addOption(simTime);
187
189 FORCE_OUTPUT, "Forces output writing into existing directory.", "F");
190 addOption(forceOutput);
191
193 SYNC_RESET, "Generate Synchronous reset (default async).");
195
197 HDB_LIST, "Comma separated list of HDBs for automated generation.",
198 "h");
200
203 "Comma separated list of IC decoder plugin arguments "
204 "for automated generation.");
206
209 "Prefer HDL generation over existing HDB implementations.");
210 addOption(preferGen);
211
214 "Doesn't reset unnecessary registers (default false).");
215 addOption(resetAll);
216
218 RF_ICGATE_LIST, "Comma separated list of RFs to IC-Gate.");
220
222 FU_ICGATE_LIST, "Comma separated list of FUs to IC-Gate.");
224
227 "Comma separated list of FUs to back-register.");
228 addOption(fuBackRegList);
229
232 "Comma separated list of FUs to front-register.");
233 addOption(fuFrontRegList);
234
235 StringCmdLineOptionParser* fuMiddleRegList =
238 "Comma separated list of FUs to middle-register.");
239 addOption(fuMiddleRegList);
240}
241
242
243/**
244 * The destructor.
245 */
248
249
250/**
251 * Returns the ADF or PCF file given as last argument.
252 *
253 * @return The name of the file.
254 */
255std::string
259
260
261/**
262 * Returns the given BEM file.
263 *
264 * @return The name of the file.
265 */
266std::string
270
271
272/**
273 * Returns the given IDF file.
274 *
275 * @return The name of the file.
276 */
277std::string
281
282
283/**
284 * Returns the given HDL parameter.
285 *
286 * @return The HDL parameter.
287 */
288std::string
292
293
294/**
295 * Returns the given output directory.
296 *
297 * @return The given output directory.
298 */
299std::string
303
304/**
305 * Returns the given output directory.
306 *
307 * @return The given output directory.
308 */
309std::string
313
314
315/**
316 * Returns the IC/decoder generator plugin parameter list query.
317 *
318 * @return The plugin parameter query.
319 */
320std::string
324
325
326std::string
330
331
332std::string
336
337
338std::string
342
343
344int
346
347 int freq = 0;
348 if (findOption(CLK_FREQUENCY)->isDefined()) {
350 }
351 return freq;
352}
353
354
355std::string
359
360
361std::string
365
366bool
370
371bool
375
376bool
380
381std::string
383 string deviceFamily = "";
384 if (findOption(DEVICE_FAMILY)->isDefined()) {
385 deviceFamily = findOption(DEVICE_FAMILY)->String();
386 }
387 return deviceFamily;
388}
389
390std::string
392 string devicePart = "";
393 if (findOption(DEVICE_NAME)->isDefined()) {
394 devicePart = findOption(DEVICE_NAME)->String();
395 }
396 return devicePart;
397}
398
399/**
400 * Gets the HDL simulation time from Cmd line options. If none given, the
401 * legacy MAGICAL RUNTIME CONSTANT value 52390ns will be used.
402 */
403std::string
405 int simTime = 52390;
406 if (findOption(SIMULATION_RUNTIME)->isDefined()) {
408 }
409 std::ostringstream s;
410 s << simTime;
411
412 return s.str();
413}
414
415/**
416 * Returns true if ProGe is allowed to write the processor files to an
417 * existing directory.
418 */
419bool
423
424/**
425 * Returns true if synchronous reset.
426 */
427bool
431
432/**
433 * Returns true if asynchronous reset.
434 */
435bool
439
440/**
441 * Helper for arguments with comma-separated arguments
442 */
443std::vector<std::string>
445 const std::string argumentName) const {
446 std::vector<std::string> list;
447 std::string str;
448 if (findOption(argumentName)->isDefined()) {
449 str = findOption(argumentName)->String();
450 }
451 std::stringstream ss(str);
452 while (ss.good()) {
453 std::string sub;
454 std::getline(ss, sub, ',');
455 if (sub.size() > 1) {
456 list.emplace_back(sub);
457 }
458 }
459 return list;
460}
461
462/**
463 * Return list of HDBs.
464 */
465std::vector<std::string>
469
470/**
471 * Return list of RFs to IC-Gate.
472 */
473std::vector<std::string>
477
478/**
479 * Return list of option/argument pairs for ICDecoder plugin
480 */
481std::vector<std::pair<std::string, std::string>>
483 auto raw_pairs = commaSeparatedList(ICD_ARG_LIST);
484 std::vector<std::pair<std::string, std::string>> parsed_pairs;
485
486 for (std::string key_val_pair : raw_pairs) {
487 if (key_val_pair.size() > 1) {
488 std::stringstream kvp(key_val_pair);
489 std::string key;
490 std::string value;
491 std::getline(kvp, key, ':');
492 std::getline(kvp, value, ':');
493 parsed_pairs.emplace_back(key, value);
494 }
495 }
496 return parsed_pairs;
497}
498
499/**
500 * Return list of FUs to IC-Gate.
501 */
502std::vector<std::string>
506
507std::vector<std::string>
511
512std::vector<std::string>
516
517std::vector<std::string>
521
522/**
523 * Returns true if preferring HDL Generation.
524 */
525bool
529
530/**
531 * Returns true if all registers should be reseted.
532 */
533bool
537
538/**
539 * Prints the version of the application.
540 */
541void
543 std::cout << "generateprocessor - OpenASIP Processor Generator "
544 << Application::TCEVersionString() << std::endl;
545}
546
547
548/**
549 * Prints help of the application.
550 */
551void
553 printVersion();
554 cout << "Usage: generateprocessor [options] <processor>" << endl
555 << "where <processor> means either an ADF or PCF file." << endl;
557}
#define sub
const string ENTITY_NAME
const string RF_ICGATE_LIST
const string ICD_ARG_LIST
const string FU_MIDDLEREGISTER_LIST
const string FU_BACKREGISTER_LIST
const string DONT_RESET_ALL
const string LIST_INTEGRATORS
const string PREFER_GEN
const string PLUGIN_PARAMETERS_PARAM_NAME
const string CLK_FREQUENCY
const string DMEM_TYPE
const string TPEF_NAME
const string SIMULATION_RUNTIME
const string OUTPUTDIR_PARAM_NAME
const string FU_FRONTREGISTER_LIST
const string HDB_LIST
const string FU_ICGATE_LIST
const string DEVICE_FAMILY
const string IDF_PARAM_NAME
const string HDL_PARAM_NAME
const string FORCE_OUTPUT
const string ENTITY_NAME
const string IMEM_TYPE
const string SYNC_RESET
const string DEVICE_NAME
const string INTEGRATOR_NAME
const string SHARED_OUTPUTDIR_PARAM_NAME
const string ICDECODER_PARAM_NAME
const string BEM_PARAM_NAME
const string USE_ABSOLUTE_PATHS
const string GENERATE_TESTBENCH
static std::string TCEVersionString()
virtual int integer(int index=0) const
virtual bool isFlagOn() const
virtual std::string String(int index=0) const
virtual void printHelp() const
CmdLineOptionParser * findOption(std::string name) const
virtual std::string argument(int index) const
virtual int numberOfArguments() const
void addOption(CmdLineOptionParser *opt)
bool listAvailableIntegrators() const
std::string pluginParametersQuery() const
std::vector< std::pair< std::string, std::string > > icdArgList() const
std::vector< std::string > commaSeparatedList(const std::string argumentName) const
std::string tpefName() const
virtual void printVersion() const
std::vector< std::string > fuFrontRegistered() const
std::vector< std::string > hdbList() const
std::string hdl() const
std::string sharedOutputDirectory() const
virtual void printHelp() const
std::vector< std::string > rfIcGateList() const
std::string processorToGenerate() const
std::string imemType() const
std::string bemFile() const
std::string deviceFamilyName() const
std::vector< std::string > fuIcGateList() const
std::string idfFile() const
std::string dmemType() const
std::string outputDirectory() const
std::string simulationRuntime() const
std::string integratorName() const
std::string deviceName() const
std::string entityName() const
std::vector< std::string > fuMiddleRegistered() const
std::vector< std::string > fuBackRegistered() const