OpenASIP  2.0
AlteraMemGenerator.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 AlteraMemGenerator.cc
26  *
27  * Implementation of AlteraMemGenerator class.
28  *
29  * @author Otto Esko 2011 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <vector>
34 #include "FileSystem.hh"
35 #include "AlteraMemGenerator.hh"
36 #include "NetlistBlock.hh"
37 #include "PlatformIntegrator.hh"
38 #include "Conversion.hh"
39 
40 const TCEString AlteraMemGenerator::INIT_FILE_G = "init_file_g";
41 const TCEString AlteraMemGenerator::DEV_FAMILY_G = "dev_family_g";
42 const TCEString AlteraMemGenerator::ADDRW_G = "addrw_g";
43 const TCEString AlteraMemGenerator::DATAW_G = "dataw_g";
44 
46  int memMauWidth,
47  int widthInMaus,
48  int addrWidth,
49  TCEString initFile,
50  const PlatformIntegrator* integrator,
51  std::ostream& warningStream,
52  std::ostream& errorStream):
53  MemoryGenerator(memMauWidth, widthInMaus, addrWidth, initFile,
54  integrator, warningStream, errorStream) {
55 }
56 
58 }
59 
60 
61 std::vector<TCEString>
63  const TCEString& templateFile,
64  const TCEString& outputPath) const {
65 
66  TCEString inputFile =
68  << templateFile;
69  TCEString outputFile;
70  outputFile << outputPath << FileSystem::DIRECTORY_SEPARATOR
71  << moduleName() << ".vhd";
72 
73  instantiateTemplate(inputFile, outputFile, ttaCoreName());
74  std::vector<TCEString> files;
75  files.push_back(outputFile);
76  return files;
77 }
78 
79 
80 void
82  const ProGe::NetlistBlock& ttaCore,
83  ProGe::NetlistBlock& integratorBlock,
84  int memIndex,
85  int coreId) {
86 
89  addGenerics(integratorBlock, addrwGeneric, datawGeneric, memIndex);
90 
91  MemoryGenerator::addMemory(ttaCore, integratorBlock, memIndex, coreId);
92 }
93 
94 
95 void
97  ProGe::NetlistBlock& topBlock,
98  const TCEString& addrWidth,
99  const TCEString& dataWidth,
100  int memIndex) {
101 
102  if (!topBlock.hasParameter(DEV_FAMILY_G)) {
103  ProGe::Parameter devFamilyTop =
104  {DEV_FAMILY_G, "string", platformIntegrator()->deviceFamily()};
105  topBlock.setParameter(devFamilyTop);
106  }
107  ProGe::Parameter devFamilyComp =
108  {DEV_FAMILY_G, "string", DEV_FAMILY_G};
109  addParameter(devFamilyComp);
110 
111  TCEString initFileGenericTop;
112  // coreId is 0 because homogenous multicores share the same memory image
113  initFileGenericTop
114  << instanceName(0, memIndex) << "_" << INIT_FILE_G;
115 
116  ProGe::Parameter initFileParamTop(
117  initFileGenericTop, "string", initializationFile());
118  topBlock.setParameter(initFileParamTop);
119  ProGe::Parameter initFileParamComp(
120  INIT_FILE_G, "string", initFileParamTop.name());
121  addParameter(initFileParamComp);
122 
123  ProGe::Parameter addrw(ADDRW_G,"integer", addrWidth);
124  ProGe::Parameter memw(DATAW_G, "integer", dataWidth);
125  addParameter(addrw);
126  addParameter(memw);
127 }
AlteraMemGenerator::INIT_FILE_G
static const TCEString INIT_FILE_G
Definition: AlteraMemGenerator.hh:75
AlteraMemGenerator::ADDRW_G
static const TCEString ADDRW_G
Definition: AlteraMemGenerator.hh:77
MemoryGenerator::platformIntegrator
const PlatformIntegrator * platformIntegrator() const
Definition: MemoryGenerator.cc:225
AlteraMemGenerator::DATAW_G
static const TCEString DATAW_G
Definition: AlteraMemGenerator.hh:78
MemoryGenerator::instanceName
virtual TCEString instanceName(int coreId, int memIndex) const =0
FileSystem.hh
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
MemoryGenerator::initializationFile
TCEString initializationFile() const
Definition: MemoryGenerator.cc:219
MemoryGenerator::ttaCoreName
TCEString ttaCoreName() const
Definition: MemoryGenerator.cc:319
ProGe::NetlistBlock::setParameter
void setParameter(const std::string &name, const std::string &type, const std::string &value)
Definition: NetlistBlock.cc:89
MemoryGenerator::instantiateTemplate
void instantiateTemplate(const TCEString &inFile, const TCEString &outFile, const TCEString &entity) const
Definition: MemoryGenerator.cc:333
MemoryGenerator::templatePath
TCEString templatePath() const
Definition: MemoryGenerator.cc:325
Conversion::toString
static std::string toString(const T &source)
AlteraMemGenerator::~AlteraMemGenerator
virtual ~AlteraMemGenerator()
Definition: AlteraMemGenerator.cc:57
MemoryGenerator::addMemory
virtual void addMemory(const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
Definition: MemoryGenerator.cc:119
AlteraMemGenerator::DEV_FAMILY_G
static const TCEString DEV_FAMILY_G
Definition: AlteraMemGenerator.hh:76
PlatformIntegrator::deviceFamily
virtual TCEString deviceFamily() const =0
ProGe::BaseNetlistBlock::hasParameter
virtual bool hasParameter(const std::string &name) const
Definition: BaseNetlistBlock.cc:183
Conversion.hh
ProGe::Parameter
Definition: Parameter.hh:62
ProGe::Parameter::name
const TCEString & name() const
Definition: Parameter.cc:133
NetlistBlock.hh
MemoryGenerator::moduleName
virtual TCEString moduleName() const =0
AlteraMemGenerator::AlteraMemGenerator
AlteraMemGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
Definition: AlteraMemGenerator.cc:45
AlteraMemGenerator::addGenerics
virtual void addGenerics(ProGe::NetlistBlock &topBlock, const TCEString &addrWidth, const TCEString &dataWidth, int memIndex)
Definition: AlteraMemGenerator.cc:96
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
AlteraMemGenerator::addMemory
virtual void addMemory(const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
Definition: AlteraMemGenerator.cc:81
AlteraMemGenerator::instantiateAlteraTemplate
std::vector< TCEString > instantiateAlteraTemplate(const TCEString &templateFile, const TCEString &outputPath) const
Definition: AlteraMemGenerator.cc:62
TCEString
Definition: TCEString.hh:53
AlteraMemGenerator.hh
PlatformIntegrator.hh
MemoryGenerator::addParameter
void addParameter(const ProGe::Parameter &add)
Definition: MemoryGenerator.cc:313
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
MemoryGenerator::memoryTotalWidth
int memoryTotalWidth() const
Definition: MemoryGenerator.cc:193
MemoryGenerator::memoryAddrWidth
int memoryAddrWidth() const
Definition: MemoryGenerator.cc:212
MemoryGenerator
Definition: MemoryGenerator.hh:85