OpenASIP  2.0
MemoryGenerator.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 MemoryGenerator.hh
26  *
27  * Declaration of MemoryGenerator class.
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_MEMORY_GENERATOR_HH
34 #define TTA_MEMORY_GENERATOR_HH
35 
36 #include <iostream>
37 #include <vector>
38 #include <map>
39 #include "Netlist.hh"
40 #include "Parameter.hh"
41 #include "TCEString.hh"
42 
43 class HDLPort;
44 class PlatformIntegrator;
45 
46 namespace HDB {
47  class FUEntry;
48  class FUArchitecture;
49  class FUImplementation;
50  class FUExternalPort;
51 }
52 
53 namespace TTAMachine {
54  class FunctionUnit;
55 }
56 
57 enum MemType {
64 };
65 
66 // structure for memory information
67 struct MemInfo {
69  int mauWidth;
71  int portAddrw; //< port address width = port width - bytemask bits
72  int asAddrw; //< address width from ADF address space
73  bool isShared;
76 };
77 
78 namespace ProGe {
79  class NetlistBlock;
80  class VirtualNetlistBlock;
81  class NetlistPort;
82  class Parameter;
83 }
84 
86 public:
87 
89  int memMauWidth,
90  int widthInMaus,
91  int addrWidth,
92  TCEString initFile,
93  const PlatformIntegrator* integrator,
94  std::ostream& warningStream,
95  std::ostream& errorStream);
96 
97  virtual ~MemoryGenerator();
98 
99  /**
100  * Tests that the memory generator is compatible with TTA core.
101  * If incompatible, reasons are appended to the reasons vector
102  *
103  * @param ttaCore TTA toplevel
104  * @param coreId The core ID number
105  * @param reasons Reasons why incompatible
106  * @return is memory generator compatible with the TTA core
107  */
108  virtual bool isCompatible(
109  const ProGe::NetlistBlock& ttaCore,
110  int coreId,
111  std::vector<TCEString>& reasons) const;
112 
113  virtual void addMemory(
114  const ProGe::NetlistBlock& ttaCore,
115  ProGe::NetlistBlock& integratorBlock,
116  int memIndex,
117  int coreId);
118 
119  virtual bool generatesComponentHdlFile() const = 0;
120 
121  virtual std::vector<TCEString>
122  generateComponentFile(TCEString outputPath) = 0;
123 
124  int memoryTotalWidth() const;
125 
126  int memoryMauSize() const;
127 
128  int memoryWidthInMaus() const;
129 
130  int memoryAddrWidth() const;
131 
133 
134  /**
135  * For data memories
136  */
137  void addLsu(
138  TTAMachine::FunctionUnit& lsuArch,
139  std::vector<std::string> lsuPorts);
140 
141  protected:
142 
143  // Key: LSU port name
144  // Value: pointer to corresponding memory component/controller port
145  typedef std::multimap<TCEString, HDLPort*> PortMap;
146 
147  typedef std::pair<ProGe::NetlistBlock*, ProGe::VirtualNetlistBlock*>
149 
150  virtual bool checkFuPort(
151  const std::string fuPort,
152  std::vector<TCEString>& reasons) const;
153 
154  virtual void connectPorts(
155  ProGe::NetlistBlock& netlistBlock,
156  const ProGe::NetlistPort& memPort,
157  const ProGe::NetlistPort& corePort,
158  bool inverted,
159  int coreId);
160 
163  ProGe::NetlistBlock& integratorBlock,
164  int memIndex,
165  int coreId);
166 
167  const PlatformIntegrator* platformIntegrator() const;
168 
169  std::ostream& warningStream();
170 
171  std::ostream& errorStream();
172 
173  int portCount() const;
174 
175  const HDLPort* port(int index) const;
176 
177  const HDLPort* portByKeyName(TCEString name) const;
178 
179  TCEString portKeyName(const HDLPort* port) const;
180 
181  void addPort(const TCEString& name, HDLPort* port);
182 
183  int parameterCount() const;
184 
185  const ProGe::Parameter& parameter(int index) const;
186 
187  void addParameter(const ProGe::Parameter& add);
188 
189  TCEString ttaCoreName() const;
190 
191  virtual TCEString moduleName() const = 0;
192 
193  virtual TCEString instanceName(int coreId, int memIndex) const = 0;
194 
195  TCEString memoryIndexString(int coreId, int memIndex) const;
196 
197  /**
198  * Returns base path to template files.
199  */
200  TCEString templatePath() const;
201 
202  void instantiateTemplate(
203  const TCEString& inFile,
204  const TCEString& outFile,
205  const TCEString& entity) const;
206 
207  bool hasLSUArchitecture() const;
208 
210 
211  TCEString corePortName(const TCEString& portBaseName, int coreId) const;
212 
213 private:
214 
215  typedef std::vector<ProGe::Parameter> ParameterList;
216 
220 
222 
224 
225  std::ostream& warningStream_;
226  std::ostream& errorStream_;
227 
230 
232  std::vector<std::string> lsuPorts_;
233 
234  static const TCEString CLOCK_PORT;
235  static const TCEString RESET_PORT;
236 };
237 
238 #endif
MemoryGenerator::generateComponentFile
virtual std::vector< TCEString > generateComponentFile(TCEString outputPath)=0
MemoryGenerator::platformIntegrator
const PlatformIntegrator * platformIntegrator() const
Definition: MemoryGenerator.cc:225
Netlist.hh
MemoryGenerator::mauWidth_
int mauWidth_
Definition: MemoryGenerator.hh:217
MemoryGenerator::widthInMaus_
int widthInMaus_
Definition: MemoryGenerator.hh:218
MemoryGenerator::port
const HDLPort * port(int index) const
Definition: MemoryGenerator.cc:249
MemoryGenerator::instanceName
virtual TCEString instanceName(int coreId, int memIndex) const =0
MemoryGenerator::createMemoryNetlistBlock
virtual MemoryGenerator::BlockPair createMemoryNetlistBlock(ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
Definition: MemoryGenerator.cc:163
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
HDB
Definition: CostDatabase.hh:49
MemoryGenerator::initializationFile
TCEString initializationFile() const
Definition: MemoryGenerator.cc:219
MemoryGenerator::addPort
void addPort(const TCEString &name, HDLPort *port)
Definition: MemoryGenerator.cc:294
HDLPort
Definition: PlatformIntegrator/HDLPort.hh:48
SRAM
@ SRAM
Definition: MemoryGenerator.hh:62
MemInfo
Definition: MemoryGenerator.hh:67
MemoryGenerator::ttaCoreName
TCEString ttaCoreName() const
Definition: MemoryGenerator.cc:319
MemoryGenerator::MemoryGenerator
MemoryGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
Definition: MemoryGenerator.cc:59
MemoryGenerator::instantiateTemplate
void instantiateTemplate(const TCEString &inFile, const TCEString &outFile, const TCEString &entity) const
Definition: MemoryGenerator.cc:333
MemoryGenerator::lsuArchitecture
const TTAMachine::FunctionUnit & lsuArchitecture() const
Definition: MemoryGenerator.cc:349
MemoryGenerator::templatePath
TCEString templatePath() const
Definition: MemoryGenerator.cc:325
MemoryGenerator::~MemoryGenerator
virtual ~MemoryGenerator()
Definition: MemoryGenerator.cc:73
MemoryGenerator::memoryIndexString
TCEString memoryIndexString(int coreId, int memIndex) const
Definition: MemoryGenerator.cc:383
MemoryGenerator::initFile_
TCEString initFile_
Definition: MemoryGenerator.hh:221
DRAM
@ DRAM
Definition: MemoryGenerator.hh:63
TCEString.hh
MemoryGenerator::addMemory
virtual void addMemory(const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
Definition: MemoryGenerator.cc:119
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
MemoryGenerator::lsuPorts_
std::vector< std::string > lsuPorts_
Definition: MemoryGenerator.hh:232
MemInfo::type
MemType type
Definition: MemoryGenerator.hh:68
MemoryGenerator::generatesComponentHdlFile
virtual bool generatesComponentHdlFile() const =0
MemoryGenerator::CLOCK_PORT
static const TCEString CLOCK_PORT
Definition: MemoryGenerator.hh:234
MemoryGenerator::parameter
const ProGe::Parameter & parameter(int index) const
Definition: MemoryGenerator.cc:308
MemoryGenerator::isCompatible
virtual bool isCompatible(const ProGe::NetlistBlock &ttaCore, int coreId, std::vector< TCEString > &reasons) const
Definition: MemoryGenerator.cc:82
MemInfo::asAddrw
int asAddrw
Definition: MemoryGenerator.hh:72
MemoryGenerator::portByKeyName
const HDLPort * portByKeyName(TCEString name) const
Definition: MemoryGenerator.cc:264
ProGe::Parameter
Definition: Parameter.hh:62
MemInfo::asName
TCEString asName
Definition: MemoryGenerator.hh:74
MemoryGenerator::checkFuPort
virtual bool checkFuPort(const std::string fuPort, std::vector< TCEString > &reasons) const
Definition: MemoryGenerator.cc:106
MemoryGenerator::RESET_PORT
static const TCEString RESET_PORT
Definition: MemoryGenerator.hh:235
MemoryGenerator::memPorts_
PortMap memPorts_
Definition: MemoryGenerator.hh:228
MemoryGenerator::memoryMauSize
int memoryMauSize() const
Definition: MemoryGenerator.cc:199
MemoryGenerator::addLsu
void addLsu(TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
Definition: MemoryGenerator.cc:376
MemInfo::widthInMaus
int widthInMaus
Definition: MemoryGenerator.hh:70
MemoryGenerator::BlockPair
std::pair< ProGe::NetlistBlock *, ProGe::VirtualNetlistBlock * > BlockPair
Definition: MemoryGenerator.hh:148
MemoryGenerator::moduleName
virtual TCEString moduleName() const =0
MemInfo::mauWidth
int mauWidth
Definition: MemoryGenerator.hh:69
MemoryGenerator::warningStream
std::ostream & warningStream()
Definition: MemoryGenerator.cc:231
MemoryGenerator::lsuArch_
TTAMachine::FunctionUnit * lsuArch_
Definition: MemoryGenerator.hh:231
MemoryGenerator::PortMap
std::multimap< TCEString, HDLPort * > PortMap
Definition: MemoryGenerator.hh:145
NONE
@ NONE
Definition: MemoryGenerator.hh:59
MemInfo::isShared
bool isShared
Definition: MemoryGenerator.hh:73
MemType
MemType
Definition: MemoryGenerator.hh:57
MemoryGenerator::corePortName
TCEString corePortName(const TCEString &portBaseName, int coreId) const
Definition: MemoryGenerator.cc:356
MemoryGenerator::connectPorts
virtual void connectPorts(ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
Definition: MemoryGenerator.cc:392
ONCHIP
@ ONCHIP
Definition: MemoryGenerator.hh:61
ProGe
Definition: FUGen.hh:54
MemoryGenerator::memoryWidthInMaus
int memoryWidthInMaus() const
Definition: MemoryGenerator.cc:205
MemoryGenerator::ParameterList
std::vector< ProGe::Parameter > ParameterList
Definition: MemoryGenerator.hh:215
MemoryGenerator::portCount
int portCount() const
Definition: MemoryGenerator.cc:243
TCEString
Definition: TCEString.hh:53
UNKNOWN
@ UNKNOWN
Definition: MemoryGenerator.hh:58
MemoryGenerator::hasLSUArchitecture
bool hasLSUArchitecture() const
Definition: MemoryGenerator.cc:344
VHDL_ARRAY
@ VHDL_ARRAY
Definition: MemoryGenerator.hh:60
MemoryGenerator::addParameter
void addParameter(const ProGe::Parameter &add)
Definition: MemoryGenerator.cc:313
MemoryGenerator::params_
ParameterList params_
Definition: MemoryGenerator.hh:229
MemoryGenerator::warningStream_
std::ostream & warningStream_
Definition: MemoryGenerator.hh:225
ProGe::NetlistPort
Definition: NetlistPort.hh:70
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
MemoryGenerator::errorStream_
std::ostream & errorStream_
Definition: MemoryGenerator.hh:226
MemoryGenerator::portKeyName
TCEString portKeyName(const HDLPort *port) const
Definition: MemoryGenerator.cc:275
MemoryGenerator::errorStream
std::ostream & errorStream()
Definition: MemoryGenerator.cc:237
MemoryGenerator::memoryTotalWidth
int memoryTotalWidth() const
Definition: MemoryGenerator.cc:193
MemoryGenerator::memoryAddrWidth
int memoryAddrWidth() const
Definition: MemoryGenerator.cc:212
TTAMachine
Definition: Assembler.hh:48
MemoryGenerator::integrator_
const PlatformIntegrator * integrator_
Definition: MemoryGenerator.hh:223
MemoryGenerator::parameterCount
int parameterCount() const
Definition: MemoryGenerator.cc:302
MemInfo::portAddrw
int portAddrw
Definition: MemoryGenerator.hh:71
Parameter.hh
MemInfo::lsuName
TCEString lsuName
Definition: MemoryGenerator.hh:75
MemoryGenerator::addrWidth_
int addrWidth_
Definition: MemoryGenerator.hh:219
MemoryGenerator
Definition: MemoryGenerator.hh:85