OpenASIP 2.2
Loading...
Searching...
No Matches
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
40const TCEString AlteraMemGenerator::INIT_FILE_G = "init_file_g";
41const TCEString AlteraMemGenerator::DEV_FAMILY_G = "dev_family_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
59
60
61std::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
80void
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
95void
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 =
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}
static const TCEString ADDRW_G
std::vector< TCEString > instantiateAlteraTemplate(const TCEString &templateFile, const TCEString &outputPath) const
static const TCEString DATAW_G
virtual void addMemory(const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
virtual void addGenerics(ProGe::NetlistBlock &topBlock, const TCEString &addrWidth, const TCEString &dataWidth, int memIndex)
AlteraMemGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
static const TCEString INIT_FILE_G
static const TCEString DEV_FAMILY_G
static std::string toString(const T &source)
static const std::string DIRECTORY_SEPARATOR
TCEString initializationFile() const
virtual TCEString instanceName(int coreId, int memIndex) const =0
virtual TCEString moduleName() const =0
const PlatformIntegrator * platformIntegrator() const
void addParameter(const ProGe::Parameter &add)
int memoryTotalWidth() const
virtual void addMemory(const ProGe::NetlistBlock &ttaCore, ProGe::NetlistBlock &integratorBlock, int memIndex, int coreId)
int memoryAddrWidth() const
TCEString templatePath() const
void instantiateTemplate(const TCEString &inFile, const TCEString &outFile, const TCEString &entity) const
TCEString ttaCoreName() const
virtual TCEString deviceFamily() const =0
virtual bool hasParameter(const std::string &name) const
void setParameter(const std::string &name, const std::string &type, const std::string &value)
const TCEString & name() const
Definition Parameter.cc:133