OpenASIP  2.0
EstimatorCmdLineOptions.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 EstimatorCmdLineOptions.cc
26  *
27  * Declaration of EstimatorCmdLineOptions.
28  *
29  * @author Pekka J��skel�inen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <iostream>
34 
35 #include "CmdLineOptions.hh"
37 #include "tce_config.h"
38 
39 
40 /// Long switch string for setting the TPEF (program).
41 const std::string SWL_TPEF = "program";
42 /// Short switch string for setting the TPEF (program).
43 const std::string SWS_TPEF = "p";
44 /// Long switch string for setting the TraceDB.
45 const std::string SWL_TRACE = "trace";
46 /// Short switch string for setting the TraceDB.
47 const std::string SWS_TRACE = "t";
48 
49 /// Long switch string for setting the total area estimation.
50 const std::string SWL_TOTALAREA = "total-area";
51 /// Short switch string for setting the total area estimation.
52 const std::string SWS_TOTALAREA = "a";
53 /// Long switch string for setting the longest path estimation.
54 const std::string SWL_LONGESTPATH = "longest-path";
55 /// Short switch string for setting the longest path estimation.
56 const std::string SWS_LONGESTPATH = "l";
57 /// Long switch string for setting the total energy consumed estimation.
58 const std::string SWL_TOTALENERGY = "total-energy";
59 /// Short switch string for setting the total energy consumed estimation.
60 const std::string SWS_TOTALENERGY = "e";
61 
62 /**
63  * Constructor.
64  */
66  addOption(
68  SWL_TPEF,
69  "sets the TTA program exchange format file (TPEF) from which to "
70  "load the estimated program (required for energy estimation only)",
71  SWS_TPEF));
72  addOption(
74  SWL_TRACE,
75  "sets the simulation trace database (TraceDB) from which to "
76  "load the simulation data of the estimated program (required for "
77  "energy estimation only)",
78  SWS_TRACE));
79  addOption(
82  "run total area estimation",
83  SWS_TOTALAREA));
84  addOption(
87  "run longest path estimation",
89  addOption(
92  "run total energy consumption estimation",
94 }
95 
96 /**
97  * Destructor.
98  */
100 }
101 
102 /**
103  * Prints the version of the program.
104  */
105 void
107  std::cout << "estimate - TTA Processor Cost Estimator "
108  << Application::TCEVersionString() << std::endl;
109 }
110 
111 /**
112  * Prints the help menu of the program.
113  */
114 void
116  printVersion();
117  std::cout << std::endl
118  << "usage: estimate [options] ADF IDF "
119  << std::endl
120  << std::endl
121  << "ADF and IDF are required always, TPEF and TraceDB only for "
122  << "energy estimation, which is not performed in case they are "
123  << "not given."
124  << std::endl;
126 }
127 
128 /**
129  * Returns the TPEF file name given by the user.
130  *
131  * If no value is given in the parsed command line, returns an empty string.
132  *
133  * @return The TPEF file name.
134  */
135 std::string
137  return findOption(SWL_TPEF)->String();
138 }
139 
140 /**
141  * Returns the TraceDB file name given by the user.
142  *
143  * If no value is given in the parsed command line, returns an empty string.
144  *
145  * @return The TraceDB file name.
146  */
147 std::string
149  return findOption(SWL_TRACE)->String();
150 }
151 
152 /**
153  * Test if estimation selection flags are given, returns true is so.
154  *
155  * @return True if estimation selection flags are given.
156  */
157 bool
159  if (findOption(SWL_TOTALAREA)->isDefined() ||
160  findOption(SWL_LONGESTPATH)->isDefined() ||
161  findOption(SWL_LONGESTPATH)->isDefined()) {
162 
163  return true;
164  }
165  return false;
166 }
167 
168 /**
169  * Checks if run total area estimation option was given.
170  *
171  * @return True if option was given and was not "no" prefixed
172  */
173 bool
175  if (findOption(SWL_TOTALAREA)->isDefined()) {
176  return findOption(SWL_TOTALAREA)->isFlagOn();
177  }
178  return false;
179 }
180 
181 /**
182  * Checks if run longest path estimation option was given.
183  *
184  * @return True if option was given and was not "no" prefixed
185  */
186 bool
188  if (findOption(SWL_LONGESTPATH)->isDefined()) {
190  }
191  return false;
192 }
193 
194 /**
195  * Checks if run total energy consumption estimation option was given.
196  *
197  * @return True if option was given and was not "no" prefixed
198  */
199 bool
201  if (findOption(SWL_TOTALENERGY)->isDefined()) {
203  }
204  return false;
205 }
206 
SWL_TOTALENERGY
const std::string SWL_TOTALENERGY
Long switch string for setting the total energy consumed estimation.
Definition: EstimatorCmdLineOptions.cc:58
SWS_TPEF
const std::string SWS_TPEF
Short switch string for setting the TPEF (program).
Definition: EstimatorCmdLineOptions.cc:43
CmdLineOptions.hh
CmdLineOptionParser::isFlagOn
virtual bool isFlagOn() const
Definition: CmdLineOptionParser.cc:126
EstimatorCmdLineOptions::totalArea
bool totalArea() const
Definition: EstimatorCmdLineOptions.cc:174
SWL_LONGESTPATH
const std::string SWL_LONGESTPATH
Long switch string for setting the longest path estimation.
Definition: EstimatorCmdLineOptions.cc:54
SWL_TRACE
const std::string SWL_TRACE
Long switch string for setting the TraceDB.
Definition: EstimatorCmdLineOptions.cc:45
CmdLineParser::addOption
void addOption(CmdLineOptionParser *opt)
EstimatorCmdLineOptions::EstimatorCmdLineOptions
EstimatorCmdLineOptions()
Definition: EstimatorCmdLineOptions.cc:65
EstimatorCmdLineOptions::~EstimatorCmdLineOptions
virtual ~EstimatorCmdLineOptions()
Definition: EstimatorCmdLineOptions.cc:99
EstimatorCmdLineOptions::traceDB
std::string traceDB()
Definition: EstimatorCmdLineOptions.cc:148
CmdLineOptions
Definition: CmdLineOptions.hh:54
SWS_TOTALENERGY
const std::string SWS_TOTALENERGY
Short switch string for setting the total energy consumed estimation.
Definition: EstimatorCmdLineOptions.cc:60
BoolCmdLineOptionParser
Definition: CmdLineOptionParser.hh:278
EstimatorCmdLineOptions::printHelp
virtual void printHelp() const
Definition: EstimatorCmdLineOptions.cc:115
EstimatorCmdLineOptions::TPEF
std::string TPEF()
Definition: EstimatorCmdLineOptions.cc:136
EstimatorCmdLineOptions::printVersion
virtual void printVersion() const
Definition: EstimatorCmdLineOptions.cc:106
SWS_TRACE
const std::string SWS_TRACE
Short switch string for setting the TraceDB.
Definition: EstimatorCmdLineOptions.cc:47
CmdLineOptions::printHelp
virtual void printHelp() const
Definition: CmdLineOptions.cc:262
SWL_TPEF
const std::string SWL_TPEF
Long switch string for setting the TPEF (program).
Definition: EstimatorCmdLineOptions.cc:41
SWS_TOTALAREA
const std::string SWS_TOTALAREA
Short switch string for setting the total area estimation.
Definition: EstimatorCmdLineOptions.cc:52
CmdLineOptionParser::String
virtual std::string String(int index=0) const
Definition: CmdLineOptionParser.cc:102
SWL_TOTALAREA
const std::string SWL_TOTALAREA
Long switch string for setting the total area estimation.
Definition: EstimatorCmdLineOptions.cc:50
EstimatorCmdLineOptions::longestPath
bool longestPath() const
Definition: EstimatorCmdLineOptions.cc:187
EstimatorCmdLineOptions.hh
EstimatorCmdLineOptions::runOnlyEstimations
bool runOnlyEstimations() const
Definition: EstimatorCmdLineOptions.cc:158
CmdLineParser::findOption
CmdLineOptionParser * findOption(std::string name) const
Definition: CmdLineParser.cc:160
EstimatorCmdLineOptions::totalEnergy
bool totalEnergy() const
Definition: EstimatorCmdLineOptions.cc:200
Application::TCEVersionString
static std::string TCEVersionString()
Definition: Application.cc:510
StringCmdLineOptionParser
Definition: CmdLineOptionParser.hh:180
SWS_LONGESTPATH
const std::string SWS_LONGESTPATH
Short switch string for setting the longest path estimation.
Definition: EstimatorCmdLineOptions.cc:56