OpenASIP  2.0
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"
37 #include "ProjectFileGenerator.hh"
38 #include "Machine.hh"
39 #include "NetlistPort.hh"
40 #include "NetlistBlock.hh"
42 using ProGe::NetlistPort;
43 
45 }
46 
47 
50  const IDF::MachineImplementation* idf,
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 
84 void
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 
98  addProGeFiles();
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());
149  projectFileGenerator()->addMemInitFile(initFile);
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 }
AlteraIntegrator::integrateProcessor
virtual void integrateProcessor(const ProGe::NetlistBlock *progeBlock)
Definition: AlteraIntegrator.cc:85
PlatformIntegrator::initPlatformNetlist
virtual void initPlatformNetlist(const ProGe::NetlistBlock *progeBlock)
Definition: PlatformIntegrator.cc:317
AlteraIntegrator.hh
AlteraIntegrator::imemGen_
MemoryGenerator * imemGen_
Definition: AlteraIntegrator.hh:73
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
AlteraIntegrator::imemInstance
virtual MemoryGenerator & imemInstance(MemInfo imem, int coreId)
Definition: AlteraIntegrator.cc:104
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
MemInfo
Definition: MemoryGenerator.hh:67
PlatformIntegrator::writeNewToplevel
virtual void writeNewToplevel()
Definition: PlatformIntegrator.cc:609
ProjectFileGenerator::writeProjectFiles
virtual void writeProjectFiles()=0
AlteraIntegrator::dmemGen_
std::map< TCEString, MemoryGenerator * > dmemGen_
Definition: AlteraIntegrator.hh:74
PlatformIntegrator::projectFileGenerator
virtual ProjectFileGenerator * projectFileGenerator() const =0
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
AlteraIntegrator::dmemInstance
virtual MemoryGenerator & dmemInstance(MemInfo dmem, TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
Definition: AlteraIntegrator.cc:134
AlteraOnchipRomGenerator
Definition: AlteraOnchipRomGenerator.hh:43
MemInfo::type
MemType type
Definition: MemoryGenerator.hh:68
InvalidData
Definition: Exception.hh:149
MemInfo::asName
TCEString asName
Definition: MemoryGenerator.hh:74
NetlistPort.hh
PlatformIntegrator::progeBlock
const ProGe::NetlistBlock & progeBlock() const
Definition: PlatformIntegrator.cc:530
NetlistBlock.hh
Machine.hh
MemoryGenerator::addLsu
void addLsu(TTAMachine::FunctionUnit &lsuArch, std::vector< std::string > lsuPorts)
Definition: MemoryGenerator.cc:376
MemInfo::widthInMaus
int widthInMaus
Definition: MemoryGenerator.hh:70
VhdlRomGenerator
Definition: VhdlRomGenerator.hh:42
MemInfo::mauWidth
int mauWidth
Definition: MemoryGenerator.hh:69
VhdlRomGenerator.hh
ProjectFileGenerator.hh
PlatformIntegrator::programName
TCEString programName() const
Definition: PlatformIntegrator.cc:133
MemType
MemType
Definition: MemoryGenerator.hh:57
ONCHIP
@ ONCHIP
Definition: MemoryGenerator.hh:61
TCEString
Definition: TCEString.hh:53
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
UNKNOWN
@ UNKNOWN
Definition: MemoryGenerator.hh:58
AlteraIntegrator::AlteraIntegrator
AlteraIntegrator()
Definition: AlteraIntegrator.cc:44
VHDL_ARRAY
@ VHDL_ARRAY
Definition: MemoryGenerator.hh:60
ProGe::HDL
HDL
HDLs supported by ProGe.
Definition: ProGeTypes.hh:40
ProGe::NetlistPort
Definition: NetlistPort.hh:70
ProjectFileGenerator::addMemInitFile
void addMemInitFile(const TCEString &memInit)
Definition: ProjectFileGenerator.cc:72
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
AlteraIntegrator::~AlteraIntegrator
virtual ~AlteraIntegrator()
Definition: AlteraIntegrator.cc:68
MemInfo::portAddrw
int portAddrw
Definition: MemoryGenerator.hh:71
PlatformIntegrator::errorStream
std::ostream & errorStream() const
Definition: PlatformIntegrator.cc:278
PlatformIntegrator::addProGeFiles
void addProGeFiles() const
Definition: PlatformIntegrator.cc:640
AlteraOnchipRamGenerator
Definition: AlteraOnchipRamGenerator.hh:43
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
AlteraOnchipRamGenerator.hh
AlteraOnchipRomGenerator.hh
TTAMachine::Machine
Definition: Machine.hh:73
MemoryGenerator
Definition: MemoryGenerator.hh:85