OpenASIP  2.0
MachineImplementation.hh
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 MachineImplementation.hh
26  *
27  * Declaration of MachineImplementation class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_MACHINE_IMPLEMENTATION_HH
34 #define TTA_MACHINE_IMPLEMENTATION_HH
35 
36 #include <string>
37 #include <vector>
38 #include "Serializable.hh"
43 #include "FUGenerated.hh"
44 
45 
46 
47 namespace IDF {
48 
49 class UnitImplementationLocation;
50 
51 /**
52  * Represents the implementation of a machine defined in an IDF.
53  */
55 public:
57 
58  MachineImplementation(const ObjectState* state);
59 
60  virtual ~MachineImplementation();
61 
62  std::string sourceIDF() const;
63 
64  std::string icDecoderPluginName() const;
65  bool hasICDecoderPluginName() const;
66  std::string icDecoderPluginFile() const;
67 
68  bool hasICDecoderPluginFile() const;
69  std::string icDecoderHDB() const;
70  bool hasICDecoderHDB() const;
71  std::string decompressorFile() const;
72  bool hasDecompressorFile() const;
73 
74  void setICDecoderPluginName(const std::string& name);
75  void setICDecoderPluginFile(const std::string& file);
76  void setICDecoderHDB(const std::string& file);
77  void setDecompressorFile(const std::string& file);
78 
79  unsigned icDecoderParameterCount() const;
80  std::string icDecoderParameterName(unsigned param) const;
81  std::string icDecoderParameterValue(const std::string& name) const;
82  std::string icDecoderParameterValue(unsigned param) const;
85  const std::string& name, const std::string& value);
86 
87  bool hasFUImplementation(const std::string& unitName) const;
88  bool hasRFImplementation(const std::string& unitName) const;
89  bool hasIUImplementation(const std::string& unitName) const;
90  bool hasBusImplementation(const std::string& busName) const;
91  bool hasSocketImplementation(const std::string& socketName) const;
92 
93  int fuImplementationCount() const;
94  int rfImplementationCount() const;
95  int iuImplementationCount() const;
96  int busImplementationCount() const;
97  int socketImplementationCount() const;
98 
99  FUImplementationLocation& fuImplementation(const std::string& fu) const;
100  RFImplementationLocation& rfImplementation(const std::string& rf) const;
101  RFImplementationLocation& iuImplementation(const std::string& iu) const;
102  BusImplementationLocation& busImplementation(const std::string& bus) const;
104  const std::string& socket) const;
105 
106  FUImplementationLocation& fuImplementation(int index) const;
107  RFImplementationLocation& rfImplementation(int index) const;
108  RFImplementationLocation& iuImplementation(int index) const;
111 
117 
118  void removeFUImplementation(const std::string& unitName);
119  void removeRFImplementation(const std::string& unitName);
120  void removeIUImplementation(const std::string& unitName);
121  void removeBusImplementation(const std::string& unitName);
122  void removeSocketImplementation(const std::string& unitName);
123 
124  // methods from Serializable interface
125  virtual void loadState(const ObjectState* state);
126  virtual ObjectState* saveState() const;
127 
128  static MachineImplementation* loadFromIDF(const std::string& idfFileName);
129 
130  void makeImplFilesRelative(const std::vector<std::string>& sPaths);
131  bool checkImplFiles(
132  size_t& missingFiles,
133  size_t& alternativeFiles);
134  bool isLibraryImplFile(
135  const std::string& path,
136  std::string& resolvedPath);
137 
138  /// ObjectState name for machine implementation.
139  static const std::string OSNAME_MACHINE_IMPLEMENTATION;
140  /// ObjectState attribute name for the source IDF.
141  static const std::string OSKEY_SOURCE_IDF;
142  /// ObjectState name for the name of the IC/decoder plugin file.
143  static const std::string OSNAME_IC_DECODER_PLUGIN;
144  /// ObjectState attribute name for ic&decoder name.
145  static const std::string OSKEY_IC_DECODER_NAME;
146  /// ObjectState attribute name for ic&decoder file.
147  static const std::string OSKEY_IC_DECODER_FILE;
148  /// ObjectState attribute name for ic&decoder parameter.
149  static const std::string OSNAME_IC_DECODER_PARAMETER;
150  /// ObjectState attribute name for ic&decoder parameter name.
151  static const std::string OSKEY_IC_DECODER_PARAMETER_NAME;
152  /// ObjectState attribute name for ic&decoder parameter value.
153  static const std::string OSKEY_IC_DECODER_PARAMETER_VALUE;
154  /// ObjectState attribute name for ic&decoder HDB.
155  static const std::string OSKEY_IC_DECODER_HDB;
156  /// ObjectState attribute key for the name of the decompressor file.
157  static const std::string OSKEY_DECOMPRESSOR_FILE;
158  /// ObjectState name for FU generations container.
159  static const std::string OSNAME_FU_GENERATED;
160  /// ObjectState name for FU implementation container.
161  static const std::string OSNAME_FU_IMPLEMENTATIONS;
162  /// ObjectState name for RF implementation container.
163  static const std::string OSNAME_RF_IMPLEMENTATIONS;
164  /// ObjectState name for IU implementation container.
165  static const std::string OSNAME_IU_IMPLEMENTATIONS;
166  /// ObjectState name for bus implementation container.
167  static const std::string OSNAME_BUS_IMPLEMENTATIONS;
168  /// ObjectState name for socket implementation container.
169  static const std::string OSNAME_SOCKET_IMPLEMENTATIONS;
170 
171  const std::vector<FUGenerated>& FUGenerations() const;
172  std::vector<FUGenerated>& FUGenerations();
173  bool hasFUGeneration(const std::string& name) const;
174  void removeFuGeneration(const std::string& name);
175  void addFuGeneration(const FUGenerated& fug);
176 
177 private:
178  /// Vector type for UnitImplementationLocation.
179  typedef std::vector<UnitImplementationLocation*> ImplementationTable;
180 
181  /// IC/Decoder parameter struct.
182  struct Parameter {
183  std::string name;
184  std::string value;
185  };
186 
187  bool checkImplFile(
188  const std::vector<std::string>& primarySearchPaths,
189  const std::vector<std::string>& secondarySearchPaths,
190  std::string& file);
191  bool isLibraryImplFile();
192  void makeHDBPathRelative(
193  const std::vector<std::string>& searchPaths,
194  UnitImplementationLocation& implem) const;
196  const ImplementationTable& table,
197  const std::string& unitName) const;
198  void ensureIndexValidity(int index, const ImplementationTable& table) const;
199  void clearState();
200 
201  /// Generated FUs.
202  std::vector<FUGenerated> fuGenerated_;
203 
204  /// FU implementations.
206  /// RF implementations.
208  /// IU implementations.
210  /// BUS implementations.
212  /// SOCKET implementations.
214 
215  /// Name of the IC/decoder plugin.
216  std::string icDecoderPluginName_;
217  /// Name of the IC/decoder plugin file.
218  std::string icDecoderPluginFile_;
219  /// Name of the HDB of the IC/decoder plugin.
220  std::string icDecoderHDB_;
221  /// Name of the decompressor block file.
222  std::string decompressorFile_;
223  /// Absolute path to the source IDF file.
224  std::string sourceIDF_;
225  /// IC/decoder plugin parameters.
226  std::vector<Parameter> icDecoderParameters_;
227 
228  /// Implementation files defined in IDF which cannot be located.
229  std::vector<std::string> missingFiles_;
230  /// Possible alternative file paths for missing implementation files.
231  std::vector<std::string> alternativeFiles_;
232 
233 };
234 }
235 
236 #endif
237 
238 
IDF::MachineImplementation::checkImplFile
bool checkImplFile(const std::vector< std::string > &primarySearchPaths, const std::vector< std::string > &secondarySearchPaths, std::string &file)
Definition: MachineImplementation.cc:1224
IDF::UnitImplementationLocation
Definition: UnitImplementationLocation.hh:48
IDF::MachineImplementation::removeFUImplementation
void removeFUImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:634
RFImplementationLocation.hh
IDF::MachineImplementation::icDecoderHDB
std::string icDecoderHDB() const
Definition: MachineImplementation.cc:179
IDF::MachineImplementation::OSNAME_RF_IMPLEMENTATIONS
static const std::string OSNAME_RF_IMPLEMENTATIONS
ObjectState name for RF implementation container.
Definition: MachineImplementation.hh:163
IDF::MachineImplementation::alternativeFiles_
std::vector< std::string > alternativeFiles_
Possible alternative file paths for missing implementation files.
Definition: MachineImplementation.hh:231
IDF::MachineImplementation::hasRFImplementation
bool hasRFImplementation(const std::string &unitName) const
Definition: MachineImplementation.cc:245
IDF::MachineImplementation::missingFiles_
std::vector< std::string > missingFiles_
Implementation files defined in IDF which cannot be located.
Definition: MachineImplementation.hh:229
IDF::MachineImplementation::hasICDecoderPluginFile
bool hasICDecoderPluginFile() const
Definition: MachineImplementation.cc:168
IDF::MachineImplementation::removeRFImplementation
void removeRFImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:659
IDF::MachineImplementation::loadState
virtual void loadState(const ObjectState *state)
Definition: MachineImplementation.cc:762
IDF::MachineImplementation::decompressorFile_
std::string decompressorFile_
Name of the decompressor block file.
Definition: MachineImplementation.hh:222
IDF::MachineImplementation::OSNAME_IU_IMPLEMENTATIONS
static const std::string OSNAME_IU_IMPLEMENTATIONS
ObjectState name for IU implementation container.
Definition: MachineImplementation.hh:165
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
Serializable
Definition: Serializable.hh:44
IDF::MachineImplementation::iuImplementation
RFImplementationLocation & iuImplementation(const std::string &iu) const
Definition: MachineImplementation.cc:399
ObjectState
Definition: ObjectState.hh:59
FUGenerated.hh
IDF::MachineImplementation::OSKEY_IC_DECODER_PARAMETER_VALUE
static const std::string OSKEY_IC_DECODER_PARAMETER_VALUE
ObjectState attribute name for ic&decoder parameter value.
Definition: MachineImplementation.hh:153
IDF::MachineImplementation::socketImplementation
SocketImplementationLocation & socketImplementation(const std::string &socket) const
Definition: MachineImplementation.cc:441
IDF::MachineImplementation::rfImplementations_
ImplementationTable rfImplementations_
RF implementations.
Definition: MachineImplementation.hh:207
IDF::MachineImplementation::removeFuGeneration
void removeFuGeneration(const std::string &name)
Definition: MachineImplementation.cc:1605
IDF::MachineImplementation::OSKEY_DECOMPRESSOR_FILE
static const std::string OSKEY_DECOMPRESSOR_FILE
ObjectState attribute key for the name of the decompressor file.
Definition: MachineImplementation.hh:157
IDF::MachineImplementation::hasDecompressorFile
bool hasDecompressorFile() const
Definition: MachineImplementation.cc:219
IDF::MachineImplementation::hasFUImplementation
bool hasFUImplementation(const std::string &unitName) const
Definition: MachineImplementation.cc:231
BusImplementationLocation.hh
IDF::MachineImplementation::Parameter::name
std::string name
Definition: MachineImplementation.hh:183
IDF::MachineImplementation::iuImplementations_
ImplementationTable iuImplementations_
IU implementations.
Definition: MachineImplementation.hh:209
IDF::MachineImplementation::hasIUImplementation
bool hasIUImplementation(const std::string &unitName) const
Definition: MachineImplementation.cc:259
IDF::MachineImplementation::icDecoderParameters_
std::vector< Parameter > icDecoderParameters_
IC/decoder plugin parameters.
Definition: MachineImplementation.hh:226
IDF::MachineImplementation::OSKEY_IC_DECODER_PARAMETER_NAME
static const std::string OSKEY_IC_DECODER_PARAMETER_NAME
ObjectState attribute name for ic&decoder parameter name.
Definition: MachineImplementation.hh:151
IDF::MachineImplementation::hasFUGeneration
bool hasFUGeneration(const std::string &name) const
Definition: MachineImplementation.cc:1590
IDF::MachineImplementation::rfImplementation
RFImplementationLocation & rfImplementation(const std::string &rf) const
Definition: MachineImplementation.cc:377
IDF::MachineImplementation::removeSocketImplementation
void removeSocketImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:735
IDF::MachineImplementation::icDecoderParameterValue
std::string icDecoderParameterValue(const std::string &name) const
Definition: MachineImplementation.cc:1415
IDF::MachineImplementation::clearState
void clearState()
Definition: MachineImplementation.cc:1352
IDF::MachineImplementation::saveState
virtual ObjectState * saveState() const
Definition: MachineImplementation.cc:862
IDF::MachineImplementation::sourceIDF_
std::string sourceIDF_
Absolute path to the source IDF file.
Definition: MachineImplementation.hh:224
IDF::MachineImplementation::setICDecoderHDB
void setICDecoderHDB(const std::string &file)
Definition: MachineImplementation.cc:1488
IDF::MachineImplementation::busImplementations_
ImplementationTable busImplementations_
BUS implementations.
Definition: MachineImplementation.hh:211
IDF::MachineImplementation::icDecoderParameterCount
unsigned icDecoderParameterCount() const
Definition: MachineImplementation.cc:1371
IDF::MachineImplementation::MachineImplementation
MachineImplementation()
Definition: MachineImplementation.cc:84
IDF::MachineImplementation::icDecoderParameterName
std::string icDecoderParameterName(unsigned param) const
Definition: MachineImplementation.cc:1382
IDF::MachineImplementation::makeImplFilesRelative
void makeImplFilesRelative(const std::vector< std::string > &sPaths)
Definition: MachineImplementation.cc:967
IDF::MachineImplementation::makeHDBPathRelative
void makeHDBPathRelative(const std::vector< std::string > &searchPaths, UnitImplementationLocation &implem) const
Definition: MachineImplementation.cc:1288
IDF::MachineImplementation::hasBusImplementation
bool hasBusImplementation(const std::string &busName) const
Definition: MachineImplementation.cc:272
IDF::MachineImplementation::OSNAME_SOCKET_IMPLEMENTATIONS
static const std::string OSNAME_SOCKET_IMPLEMENTATIONS
ObjectState name for socket implementation container.
Definition: MachineImplementation.hh:169
IDF::MachineImplementation::removeIUImplementation
void removeIUImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:684
IDF::FUGenerated
Definition: FUGenerated.hh:41
IDF::MachineImplementation::fuImplementations_
ImplementationTable fuImplementations_
FU implementations.
Definition: MachineImplementation.hh:205
IDF::MachineImplementation::clearICDecoderParameters
void clearICDecoderParameters()
Definition: MachineImplementation.cc:1512
IDF::MachineImplementation::addBusImplementation
void addBusImplementation(BusImplementationLocation *implementation)
Definition: MachineImplementation.cc:596
IDF::MachineImplementation::setICDecoderPluginName
void setICDecoderPluginName(const std::string &name)
Definition: MachineImplementation.cc:1462
IDF::MachineImplementation::icDecoderPluginFile_
std::string icDecoderPluginFile_
Name of the IC/decoder plugin file.
Definition: MachineImplementation.hh:218
IDF::MachineImplementation::addFuGeneration
void addFuGeneration(const FUGenerated &fug)
Definition: MachineImplementation.cc:1619
IDF::MachineImplementation::setDecompressorFile
void setDecompressorFile(const std::string &file)
Definition: MachineImplementation.cc:1502
IDF::MachineImplementation::OSKEY_IC_DECODER_NAME
static const std::string OSKEY_IC_DECODER_NAME
ObjectState attribute name for ic&decoder name.
Definition: MachineImplementation.hh:145
IDF::MachineImplementation::fuGenerated_
std::vector< FUGenerated > fuGenerated_
Generated FUs.
Definition: MachineImplementation.hh:202
SocketImplementationLocation.hh
FUImplementationLocation.hh
IDF::MachineImplementation::decompressorFile
std::string decompressorFile() const
Definition: MachineImplementation.cc:205
IDF::MachineImplementation::rfImplementationCount
int rfImplementationCount() const
Definition: MachineImplementation.cc:310
IDF::MachineImplementation::addRFImplementation
void addRFImplementation(RFImplementationLocation *implementation)
Definition: MachineImplementation.cc:554
IDF::MachineImplementation::busImplementationCount
int busImplementationCount() const
Definition: MachineImplementation.cc:331
IDF::MachineImplementation::ImplementationTable
std::vector< UnitImplementationLocation * > ImplementationTable
Vector type for UnitImplementationLocation.
Definition: MachineImplementation.hh:179
IDF::MachineImplementation::sourceIDF
std::string sourceIDF() const
Definition: MachineImplementation.cc:121
IDF::MachineImplementation::busImplementation
BusImplementationLocation & busImplementation(const std::string &bus) const
Definition: MachineImplementation.cc:420
IDF::MachineImplementation::removeBusImplementation
void removeBusImplementation(const std::string &unitName)
Definition: MachineImplementation.cc:709
IDF::MachineImplementation::OSNAME_IC_DECODER_PLUGIN
static const std::string OSNAME_IC_DECODER_PLUGIN
ObjectState name for the name of the IC/decoder plugin file.
Definition: MachineImplementation.hh:143
IDF::MachineImplementation::iuImplementationCount
int iuImplementationCount() const
Definition: MachineImplementation.cc:321
IDF::MachineImplementation::~MachineImplementation
virtual ~MachineImplementation()
Definition: MachineImplementation.cc:110
IDF::MachineImplementation::OSNAME_IC_DECODER_PARAMETER
static const std::string OSNAME_IC_DECODER_PARAMETER
ObjectState attribute name for ic&decoder parameter.
Definition: MachineImplementation.hh:149
IDF::MachineImplementation::OSNAME_FU_GENERATED
static const std::string OSNAME_FU_GENERATED
ObjectState name for FU generations container.
Definition: MachineImplementation.hh:159
Serializable.hh
IDF::MachineImplementation::OSNAME_FU_IMPLEMENTATIONS
static const std::string OSNAME_FU_IMPLEMENTATIONS
ObjectState name for FU implementation container.
Definition: MachineImplementation.hh:161
IDF::MachineImplementation::socketImplementations_
ImplementationTable socketImplementations_
SOCKET implementations.
Definition: MachineImplementation.hh:213
IDF::MachineImplementation::setICDecoderParameter
void setICDecoderParameter(const std::string &name, const std::string &value)
Definition: MachineImplementation.cc:1437
IDF::MachineImplementation::OSKEY_IC_DECODER_HDB
static const std::string OSKEY_IC_DECODER_HDB
ObjectState attribute name for ic&decoder HDB.
Definition: MachineImplementation.hh:155
IDF::MachineImplementation::icDecoderPluginFile
std::string icDecoderPluginFile() const
Definition: MachineImplementation.cc:153
IDF::MachineImplementation::fuImplementationCount
int fuImplementationCount() const
Definition: MachineImplementation.cc:299
IDF::MachineImplementation::addFUImplementation
void addFUImplementation(FUImplementationLocation *implementation)
Definition: MachineImplementation.cc:533
IDF::MachineImplementation::socketImplementationCount
int socketImplementationCount() const
Definition: MachineImplementation.cc:341
IDF::MachineImplementation::Parameter::value
std::string value
Definition: MachineImplementation.hh:184
IDF::MachineImplementation::isLibraryImplFile
bool isLibraryImplFile()
IDF::MachineImplementation::Parameter
IC/Decoder parameter struct.
Definition: MachineImplementation.hh:182
IDF::MachineImplementation::hasICDecoderPluginName
bool hasICDecoderPluginName() const
Definition: MachineImplementation.cc:142
IDF::MachineImplementation::setICDecoderPluginFile
void setICDecoderPluginFile(const std::string &file)
Definition: MachineImplementation.cc:1474
IDF::MachineImplementation::fuImplementation
FUImplementationLocation & fuImplementation(const std::string &fu) const
Definition: MachineImplementation.cc:355
IDF::MachineImplementation::OSNAME_MACHINE_IMPLEMENTATION
static const std::string OSNAME_MACHINE_IMPLEMENTATION
ObjectState name for machine implementation.
Definition: MachineImplementation.hh:139
IDF::MachineImplementation::checkImplFiles
bool checkImplFiles(size_t &missingFiles, size_t &alternativeFiles)
Definition: MachineImplementation.cc:1066
IDF::MachineImplementation::ensureIndexValidity
void ensureIndexValidity(int index, const ImplementationTable &table) const
Definition: MachineImplementation.cc:1340
IDF::MachineImplementation::FUGenerations
const std::vector< FUGenerated > & FUGenerations() const
Definition: MachineImplementation.cc:1572
IDF::MachineImplementation::icDecoderPluginName_
std::string icDecoderPluginName_
Name of the IC/decoder plugin.
Definition: MachineImplementation.hh:216
IDF::MachineImplementation::icDecoderHDB_
std::string icDecoderHDB_
Name of the HDB of the IC/decoder plugin.
Definition: MachineImplementation.hh:220
IDF::MachineImplementation::icDecoderPluginName
std::string icDecoderPluginName() const
Definition: MachineImplementation.cc:132
IDF::MachineImplementation::addSocketImplementation
void addSocketImplementation(SocketImplementationLocation *implementation)
Definition: MachineImplementation.cc:616
IDF::MachineImplementation::OSNAME_BUS_IMPLEMENTATIONS
static const std::string OSNAME_BUS_IMPLEMENTATIONS
ObjectState name for bus implementation container.
Definition: MachineImplementation.hh:167
IDF::MachineImplementation::hasICDecoderHDB
bool hasICDecoderHDB() const
Definition: MachineImplementation.cc:193
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
IDF::MachineImplementation::loadFromIDF
static MachineImplementation * loadFromIDF(const std::string &idfFileName)
Definition: MachineImplementation.cc:1524
IDF::MachineImplementation::findImplementation
UnitImplementationLocation * findImplementation(const ImplementationTable &table, const std::string &unitName) const
Definition: MachineImplementation.cc:1315
IDF::MachineImplementation::OSKEY_SOURCE_IDF
static const std::string OSKEY_SOURCE_IDF
ObjectState attribute name for the source IDF.
Definition: MachineImplementation.hh:141
IDF::MachineImplementation::OSKEY_IC_DECODER_FILE
static const std::string OSKEY_IC_DECODER_FILE
ObjectState attribute name for ic&decoder file.
Definition: MachineImplementation.hh:147
IDF
Definition: DSDBManager.hh:54
IDF::MachineImplementation::addIUImplementation
void addIUImplementation(RFImplementationLocation *implementation)
Definition: MachineImplementation.cc:575
IDF::MachineImplementation::hasSocketImplementation
bool hasSocketImplementation(const std::string &socketName) const
Definition: MachineImplementation.cc:286