OpenASIP 2.2
Loading...
Searching...
No Matches
AlteraIntegrator.cc
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 AlteraIntegrator.cc
26 *
27 * Implementation of AlteraIntegrator class.
28 *
29 * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include "AlteraIntegrator.hh"
36#include "VhdlRomGenerator.hh"
38#include "Machine.hh"
39#include "NetlistPort.hh"
40#include "NetlistBlock.hh"
43
46
47
51 ProGe::HDL hdl,
52 TCEString progeOutputDir,
53 TCEString coreEntityName,
54 TCEString outputDir,
55 TCEString programName,
56 int targetClockFreq,
57 std::ostream& warningStream,
58 std::ostream& errorStream,
59 const MemInfo& imem,
60 MemType dmemType):
61 PlatformIntegrator(machine, idf, hdl, progeOutputDir, coreEntityName,
62 outputDir, programName, targetClockFreq, warningStream,
63 errorStream, imem, dmemType),
64 imemGen_(NULL), dmemGen_() {
65}
66
67
69
70 if (imemGen_ != NULL) {
71 delete imemGen_;
72 }
73 if (!dmemGen_.empty()) {
74 std::map<TCEString, MemoryGenerator*>::iterator iter =
75 dmemGen_.begin();
76 while (iter != dmemGen_.end()) {
77 delete iter->second;
78 iter++;
79 }
80 }
81}
82
83
84void
86 const ProGe::NetlistBlock* progeBlockInOldNetlist) {
87
88 initPlatformNetlist(progeBlockInOldNetlist);
89
90 const NetlistBlock& core = progeBlock();
91 int coreId = -1;
92 if (!integrateCore(core, coreId)) {
93 return;
94 }
95
97
99
101}
102
105 assert(imem.type != UNKNOWN && "Imem type not set!");
106
107 TCEString initFile;
108 if (imem.type == ONCHIP) {
109 initFile = programName() + ".mif";
111 } else if (imem.type == VHDL_ARRAY) {
112 initFile = programName() + "_imem_pkg.vhdl";
113 }
114
115 if (imemGen_ == NULL) {
116 if (imem.type == ONCHIP) {
117 imemGen_ =
119 imem.mauWidth, imem.widthInMaus, imem.portAddrw, initFile,
120 this, warningStream(), errorStream());
121 } else if (imem.type == VHDL_ARRAY) {
123 imem.mauWidth, imem.widthInMaus, imem.portAddrw, initFile,
124 this, warningStream(), errorStream());
125 } else {
126 TCEString msg = "Unsupported instruction memory type";
127 throw InvalidData(__FILE__, __LINE__, "AlteraIntegrator", msg);
128 }
129 }
130 return *imemGen_;
131}
132
135 MemInfo dmem, TTAMachine::FunctionUnit& lsuArch,
136 std::vector<std::string> lsuPorts) {
137 MemoryGenerator* memGen = NULL;
138 if (dmemGen_.find(dmem.asName) != dmemGen_.end()) {
139 memGen = dmemGen_.find(dmem.asName)->second;
140 } else {
141 if (dmem.type == ONCHIP) {
142 TCEString initFile = programName() + "_" + dmem.asName + ".mif";
143 // onchip mem size is scalable, use value from adf's Address Space
144 int addrw = dmem.portAddrw;
145 memGen =
147 dmem.mauWidth, dmem.widthInMaus, addrw, initFile,
148 this, warningStream(), errorStream());
150 } else {
151 TCEString msg = "Unsupported data memory type";
152 throw InvalidData(__FILE__, __LINE__, "AlteraIntegrator", msg);
153 }
154 memGen->addLsu(lsuArch, lsuPorts);
155 dmemGen_[dmem.asName] = memGen;
156 }
157 return *memGen;
158}
#define assert(condition)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
@ VHDL_ARRAY
@ ONCHIP
@ UNKNOWN
virtual ~AlteraIntegrator()
virtual MemoryGenerator & imemInstance(MemInfo imem, int coreId)
MemoryGenerator * imemGen_
std::map< TCEString, MemoryGenerator * > dmemGen_
virtual MemoryGenerator & dmemInstance(MemInfo dmem, TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
virtual void integrateProcessor(const ProGe::NetlistBlock *progeBlock)
void addLsu(TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
virtual void initPlatformNetlist(const ProGe::NetlistBlock *progeBlock)
std::ostream & warningStream() const
TCEString programName() const
std::ostream & errorStream() const
virtual bool integrateCore(const ProGe::NetlistBlock &cores, int coreId)
const ProGe::NetlistBlock & progeBlock() const
virtual void writeNewToplevel()
virtual ProjectFileGenerator * projectFileGenerator() const =0
void addMemInitFile(const TCEString &memInit)
virtual void writeProjectFiles()=0
HDL
HDLs supported by ProGe.
Definition ProGeTypes.hh:40
MemType type
TCEString asName