OpenASIP  2.0
PlatformIntegrator.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 PlatformIntegerator.hh
26  *
27  * Declaration of PlatformIntegrator class.
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_PLATFORM_INTEGRATOR_HH
34 #define TTA_PLATFORM_INTEGRATOR_HH
35 
36 #include <iostream>
37 #include <string>
38 #include <vector>
39 #include <map>
40 #include "MemoryGenerator.hh"
41 #include "ProGeTypes.hh"
42 
43 namespace ProGe {
44  class Netlist;
45  class NetlistBlock;
46  class NetlistPort;
47 }
48 
49 namespace TTAMachine {
50  class Machine;
51  class FunctionUnit;
52  class AddressSpace;
53 }
54 
55 namespace IDF {
56  class MachineImplementation;
57 }
58 
59 namespace HDB {
60  class FUEntry;
61 }
62 
64 
66 public:
67 
69 
73  ProGe::HDL hdl,
74  TCEString progeOutputDir,
76  TCEString outputDir,
78  int targetClockFreq,
79  std::ostream& warningStream,
80  std::ostream& errorStream,
81  const MemInfo& imem,
82  MemType dmemType);
83 
84  virtual ~PlatformIntegrator();
85 
86  /**
87  * Integrates the TTA core(s) generated by ProGe
88  *
89  * @param progeBlock The toplevel netlist block created by ProGe
90  */
91  virtual void integrateProcessor(
92  const ProGe::NetlistBlock* progeBlock) = 0;
93 
94  /**
95  * Returns the FPGA device family
96  */
97  virtual TCEString deviceFamily() const = 0;
98 
99  /**
100  * Set the FPGA device family.
101  *
102  * Intended for TTA IP integration. Integrator can device whether this
103  * overrides the default device family.
104  */
105  virtual void setDeviceFamily(TCEString devFamily) = 0;
106 
107  /**
108  * Set or get the FPGA device name.
109  *
110  * This is used for synthesis scripts by AlmaIFIntegrator
111  * and QuartusProjectGenerator.
112  */
113  void setDeviceName(TCEString devName) { deviceName_ = devName; }
114  TCEString deviceName() const { return deviceName_; }
115 
116 
117  /**
118  * Returns the device package name
119  */
120  virtual TCEString devicePackage() const = 0;
121 
122  /**
123  * Returns the device speed class
124  */
125  virtual TCEString deviceSpeedClass() const = 0;
126 
127 
128  /**
129  * Returns the target clock frequency in MHz
130  */
131  virtual int targetClockFrequency() const;
132 
133  /**
134  * Prints information about the platform
135  */
136  virtual void printInfo(std::ostream& stream) const = 0;
137 
138 
139  /**
140  * Returns the netlist block created by ProGe which contains the tta cores
141  */
142  const ProGe::NetlistBlock& progeBlock() const;
143 
144  /**
145  * Returns the platform integration toplevel netlist block
146  */
147  const ProGe::NetlistBlock& toplevelBlock() const;
148 
149  /**
150  * Set proge share output directory if it differs from ProGe output dir
151  */
152  void setSharedOutputDir(const TCEString& sharedDir);
153 
154  /**
155  * Returns the platform integrator output path string. Might not exist.
156  *
157  * @return Platform Integrator output path
158  */
159  TCEString outputPath() const;
160 
161  /**
162  * Returns string to the platform integrator output path of the fileName
163  *
164  * @param filename Name of file
165  * @param absolute Return absolute path
166  * @return Path to file
167  */
168  TCEString outputFilePath(TCEString fileName, bool absolute = false)
169  const;
170 
171  /**
172  * Return TTA core entity name
173  */
174  TCEString coreEntityName() const;
175 
176  const TTAMachine::Machine* machine() const;
177 
178  const IDF::MachineImplementation* idf() const;
179 
180  const MemInfo& imemInfo() const;
181 
182  const MemInfo& dmemInfo(TTAMachine::AddressSpace* as) const;
183 
184  const MemInfo& dmemInfo(int index) const;
185 
186  int dmemCount() const;
187 
188  ProGe::NetlistPort* clockPort() const;
189 
190  ProGe::NetlistPort* resetPort() const;
191 
192 protected:
193 
195 
196  /**
197  * Initializes the platform integrator netlist
198  *
199  * Copies a TTA core to a new netlist, adds clock and reset ports to
200  * the new netlist.
201  *
202  * @param progeBlock The toplevel netlist block created by ProGe
203  */
205 
206  /**
207  * Integrates a single TTA core
208  *
209  *
210  * @param cores NetlistBlock containing the core(s)
211  * @param coreId Index of the core to be integrated
212  */
213  virtual bool integrateCore(const ProGe::NetlistBlock& cores, int coreId);
214 
215  virtual void exportUnconnectedPorts(int coreId);
216 
217  virtual void connectToplevelPort(const ProGe::NetlistPort& corePort,
218  const TCEString signalPrefix = "");
219 
220  virtual TCEString pinTag() const = 0;
221 
222  virtual bool chopTaggedSignals() const = 0;
223 
224  virtual bool hasPinTag(const TCEString& signal) const;
225 
226  /**
227  * Copies the ProGe generated toplevel block (i.e. tta core(s)) to a
228  * new netlist.
229  *
230  * @param progeBlock The toplevel netlist block created by ProGe
231  */
233 
234  virtual bool createMemories(int coreId);
235 
236  virtual bool generateMemory(
237  MemoryGenerator& memGen,
238  std::vector<TCEString>& generatedFiles,
239  int memIndex,
240  int coreId);
241 
242  virtual MemoryGenerator& imemInstance(MemInfo imem, int coreId) = 0;
243 
244  virtual MemoryGenerator& dmemInstance(
245  MemInfo dmem,
246  TTAMachine::FunctionUnit& lsuArch,
247  std::vector<std::string> lsuPorts) = 0;
248 
249  virtual void writeNewToplevel();
250 
251  virtual ProjectFileGenerator* projectFileGenerator() const = 0;
252 
253  void addProGeFiles() const;
254 
255  /**
256  * Returns the scheduled program name without .tpef ending
257  */
258  TCEString programName() const;
259 
260  /**
261  * Returns string to the proge-output path of the fileName
262  *
263  * @param filename Name of file
264  * @param absolute Return absolute path
265  * @return Path to file
266  */
267  TCEString
268  progeFilePath(TCEString fileName, bool absolute = false) const;
269 
270  /**
271  * Utility function for processing vhdl signals.
272  *
273  * Signal name format is fu_name_<TAG>_name : <dir> <type> {);}
274  * This function chops the signal name in such way that the name starts
275  * from <TAG> i.e. returns <TAG>_name : <dir> <type> {);}
276  *
277  * @param original Original signal name
278  * @param tag Starting tag
279  * @return Chopped string
280  */
282  const TCEString& original, const TCEString& tag) const;
283 
284  /**
285  * Appends all the vhdl files from ProGe output directory's vhdl and
286  * gcu_ic subdirectories to the given vector.
287  *
288  * @param files Vector where the filenames are appended to.
289  */
290  void progeOutputHdlFiles(std::vector<TCEString>& files) const;
291 
292  std::ostream& warningStream() const;
293 
294  std::ostream& errorStream() const;
295 
297 
298  void parseDataMemories();
299  void clearDataMemories();
300 
302 
303  static const TCEString TTA_CORE_CLK;
304  static const TCEString TTA_CORE_RSTX;
305 
306 private:
307 
308  void createOutputDir();
309 
310  std::vector<std::string> loadFUExternalPorts(
311  TTAMachine::FunctionUnit& fu) const;
312 
314 
316 
318 
320 
328 
329  std::ostream& warningStream_;
330  std::ostream& errorStream_;
331 
333 
336  std::map<TTAMachine::AddressSpace*, MemInfo> dmem_;
337 
338  std::vector<TTAMachine::FunctionUnit*> lsus_;
339 
342 
343  std::multimap<TCEString, const ProGe::NetlistPort*>* unconnectedPorts_;
344 };
345 #endif
PlatformIntegrator::programName_
TCEString programName_
Definition: PlatformIntegrator.hh:325
PlatformIntegrator::TTA_CORE_RSTX
static const TCEString TTA_CORE_RSTX
Definition: PlatformIntegrator.hh:304
PlatformIntegrator::initPlatformNetlist
virtual void initPlatformNetlist(const ProGe::NetlistBlock *progeBlock)
Definition: PlatformIntegrator.cc:317
PlatformIntegrator::warningStream_
std::ostream & warningStream_
Definition: PlatformIntegrator.hh:329
PlatformIntegrator::clockPort
ProGe::NetlistPort * clockPort() const
Definition: PlatformIntegrator.cc:692
PlatformIntegrator::lsus_
std::vector< TTAMachine::FunctionUnit * > lsus_
Definition: PlatformIntegrator.hh:338
PlatformIntegrator::coreEntityName_
TCEString coreEntityName_
Definition: PlatformIntegrator.hh:323
PlatformIntegrator::coreEntityName
TCEString coreEntityName() const
Definition: PlatformIntegrator.cc:126
PlatformIntegrator::platformEntityName
TCEString platformEntityName() const
Definition: PlatformIntegrator.cc:311
PlatformIntegrator::chopSignalToTag
TCEString chopSignalToTag(const TCEString &original, const TCEString &tag) const
Definition: PlatformIntegrator.cc:185
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
PlatformIntegrator::setSharedOutputDir
void setSharedOutputDir(const TCEString &sharedDir)
Definition: PlatformIntegrator.cc:169
HDB
Definition: CostDatabase.hh:49
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
PlatformIntegrator::targetFrequency_
int targetFrequency_
Definition: PlatformIntegrator.hh:327
PlatformIntegrator::setDeviceFamily
virtual void setDeviceFamily(TCEString devFamily)=0
PlatformIntegrator::integrateProcessor
virtual void integrateProcessor(const ProGe::NetlistBlock *progeBlock)=0
MemInfo
Definition: MemoryGenerator.hh:67
PlatformIntegrator::deviceName
TCEString deviceName() const
Definition: PlatformIntegrator.hh:114
PlatformIntegrator::pinTag
virtual TCEString pinTag() const =0
PlatformIntegrator::parseDataMemories
void parseDataMemories()
Definition: PlatformIntegrator.cc:334
MemoryGenerator.hh
PlatformIntegrator::clearDataMemories
void clearDataMemories()
Definition: PlatformIntegrator.cc:361
PlatformIntegrator::devicePackage
virtual TCEString devicePackage() const =0
PlatformIntegrator::TTA_CORE_CLK
static const TCEString TTA_CORE_CLK
Definition: PlatformIntegrator.hh:303
PlatformIntegrator::writeNewToplevel
virtual void writeNewToplevel()
Definition: PlatformIntegrator.cc:609
PlatformIntegrator::setDeviceName
void setDeviceName(TCEString devName)
Definition: PlatformIntegrator.hh:113
PlatformIntegrator::createOutputDir
void createOutputDir()
Definition: PlatformIntegrator.cc:260
PlatformIntegrator::errorStream_
std::ostream & errorStream_
Definition: PlatformIntegrator.hh:330
PlatformIntegrator::createMemories
virtual bool createMemories(int coreId)
Definition: PlatformIntegrator.cc:542
PlatformIntegrator::projectFileGenerator
virtual ProjectFileGenerator * projectFileGenerator() const =0
PlatformIntegrator::outputPath
TCEString outputPath() const
Definition: PlatformIntegrator.cc:179
PlatformIntegrator::~PlatformIntegrator
virtual ~PlatformIntegrator()
Definition: PlatformIntegrator.cc:123
PlatformIntegrator::connectToplevelPort
virtual void connectToplevelPort(const ProGe::NetlistPort &corePort, const TCEString signalPrefix="")
Definition: PlatformIntegrator.cc:464
PlatformIntegrator::dmemCount
int dmemCount() const
Definition: PlatformIntegrator.cc:685
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
PlatformIntegrator::ttaCores_
ProGe::NetlistBlock * ttaCores_
Definition: PlatformIntegrator.hh:332
PlatformIntegrator::deviceFamily
virtual TCEString deviceFamily() const =0
PlatformIntegrator::sharedOutputDir_
TCEString sharedOutputDir_
Definition: PlatformIntegrator.hh:322
PlatformIntegrator::resetPort
ProGe::NetlistPort * resetPort() const
Definition: PlatformIntegrator.cc:704
ProjectFileGenerator
Definition: ProjectFileGenerator.hh:41
PlatformIntegrator::hdl_
ProGe::HDL hdl_
Definition: PlatformIntegrator.hh:319
PlatformIntegrator::loadFUExternalPorts
std::vector< std::string > loadFUExternalPorts(TTAMachine::FunctionUnit &fu) const
Definition: PlatformIntegrator.cc:367
PlatformIntegrator::progeBlock
const ProGe::NetlistBlock & progeBlock() const
Definition: PlatformIntegrator.cc:530
PlatformIntegrator::PlatformIntegrator
PlatformIntegrator()
Definition: PlatformIntegrator.cc:68
PlatformIntegrator::idf
const IDF::MachineImplementation * idf() const
Definition: PlatformIntegrator.cc:304
PlatformIntegrator::dmem_
std::map< TTAMachine::AddressSpace *, MemInfo > dmem_
Definition: PlatformIntegrator.hh:336
PlatformIntegrator::targetClockFrequency
virtual int targetClockFrequency() const
Definition: PlatformIntegrator.cc:285
PlatformIntegrator::toplevelBlock
const ProGe::NetlistBlock & toplevelBlock() const
Definition: PlatformIntegrator.cc:537
PlatformIntegrator::machine
const TTAMachine::Machine * machine() const
Definition: PlatformIntegrator.cc:297
ProGeTypes.hh
PlatformIntegrator::printInfo
virtual void printInfo(std::ostream &stream) const =0
PlatformIntegrator::generateMemory
virtual bool generateMemory(MemoryGenerator &memGen, std::vector< TCEString > &generatedFiles, int memIndex, int coreId)
Definition: PlatformIntegrator.cc:579
PlatformIntegrator::imemInfo
const MemInfo & imemInfo() const
Definition: PlatformIntegrator.cc:651
PlatformIntegrator::hasPinTag
virtual bool hasPinTag(const TCEString &signal) const
Definition: PlatformIntegrator.cc:495
PlatformIntegrator::idf_
const IDF::MachineImplementation * idf_
Definition: PlatformIntegrator.hh:315
PlatformIntegrator::deviceName_
TCEString deviceName_
Definition: PlatformIntegrator.hh:326
PlatformIntegrator::dmemType_
MemType dmemType_
Definition: PlatformIntegrator.hh:335
PlatformIntegrator::deviceSpeedClass
virtual TCEString deviceSpeedClass() const =0
PlatformIntegrator::outputDir_
TCEString outputDir_
Definition: PlatformIntegrator.hh:324
PlatformIntegrator::dmemInstance
virtual MemoryGenerator & dmemInstance(MemInfo dmem, TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)=0
PlatformIntegrator::integratorBlock
ProGe::NetlistBlock * integratorBlock()
Definition: PlatformIntegrator.cc:291
PlatformIntegrator::progeOutputHdlFiles
void progeOutputHdlFiles(std::vector< TCEString > &files) const
Definition: PlatformIntegrator.cc:198
PlatformIntegrator::programName
TCEString programName() const
Definition: PlatformIntegrator.cc:133
MemType
MemType
Definition: MemoryGenerator.hh:57
PlatformIntegrator::exportUnconnectedPorts
virtual void exportUnconnectedPorts(int coreId)
Definition: PlatformIntegrator.cc:453
PlatformIntegrator::unconnectedPorts_
std::multimap< TCEString, const ProGe::NetlistPort * > * unconnectedPorts_
Definition: PlatformIntegrator.hh:343
PlatformIntegrator::progeFilePath
TCEString progeFilePath(TCEString fileName, bool absolute=false) const
Definition: PlatformIntegrator.cc:140
PlatformIntegrator::readLsuParameters
MemInfo readLsuParameters(const TTAMachine::FunctionUnit &lsu)
Definition: PlatformIntegrator.cc:403
ProGe
Definition: FUGen.hh:54
TCEString
Definition: TCEString.hh:53
PlatformIntegrator::dmemInfo
const MemInfo & dmemInfo(TTAMachine::AddressSpace *as) const
Definition: PlatformIntegrator.cc:657
PlatformIntegrator::warningStream
std::ostream & warningStream() const
Definition: PlatformIntegrator.cc:271
PlatformIntegrator::integrateCore
virtual bool integrateCore(const ProGe::NetlistBlock &cores, int coreId)
Definition: PlatformIntegrator.cc:434
PlatformIntegrator::integratorBlock_
ProGe::NetlistBlock * integratorBlock_
Definition: PlatformIntegrator.hh:317
PlatformIntegrator::imem_
MemInfo imem_
Definition: PlatformIntegrator.hh:334
ProGe::HDL
HDL
HDLs supported by ProGe.
Definition: ProGeTypes.hh:40
ProGe::NetlistPort
Definition: NetlistPort.hh:70
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
PlatformIntegrator::copyProgeBlockToNetlist
void copyProgeBlockToNetlist(const ProGe::NetlistBlock *progeBlock)
Definition: PlatformIntegrator.cc:502
PlatformIntegrator::outputFilePath
TCEString outputFilePath(TCEString fileName, bool absolute=false) const
Definition: PlatformIntegrator.cc:154
PlatformIntegrator::resetPort_
ProGe::NetlistPort * resetPort_
Definition: PlatformIntegrator.hh:341
TTAMachine
Definition: Assembler.hh:48
PlatformIntegrator::clkPort_
ProGe::NetlistPort * clkPort_
Definition: PlatformIntegrator.hh:340
PlatformIntegrator::errorStream
std::ostream & errorStream() const
Definition: PlatformIntegrator.cc:278
PlatformIntegrator::addProGeFiles
void addProGeFiles() const
Definition: PlatformIntegrator.cc:640
PlatformIntegrator::progeOutputDir_
TCEString progeOutputDir_
Definition: PlatformIntegrator.hh:321
PlatformIntegrator::machine_
const TTAMachine::Machine * machine_
Definition: PlatformIntegrator.hh:313
PlatformIntegrator::imemInstance
virtual MemoryGenerator & imemInstance(MemInfo imem, int coreId)=0
PlatformIntegrator::chopTaggedSignals
virtual bool chopTaggedSignals() const =0
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
IDF
Definition: DSDBManager.hh:54
TTAMachine::Machine
Definition: Machine.hh:73
MemoryGenerator
Definition: MemoryGenerator.hh:85