OpenASIP  2.0
AlteraHibiDpRamGenerator.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 AlteraHibiDpRamGenerator.cc
26  *
27  * Implementation of AlteraHibiDpRamGenerator class.
28  *
29  * Hibi lsu needs a special dual port ram generator because both of the
30  * memory ports are in the same FU.
31  *
32  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
33  * @note rating: red
34  */
35 
36 #include <iostream>
37 #include <vector>
38 #include "PlatformIntegrator.hh"
40 #include "HDLPort.hh"
41 #include "NetlistBlock.hh"
42 #include "NetlistPort.hh"
43 #include "FUExternalPort.hh"
44 #include "Conversion.hh"
45 using std::endl;
47 using ProGe::NetlistPort;
48 
50  "altera_onchip_dp_ram_comp.vhd";
51 
53  int memMauWidth,
54  int widthInMaus,
55  int addrWidth,
56  TCEString initFile,
57  const PlatformIntegrator* integrator,
58  std::ostream& warningStream,
59  std::ostream& errorStream):
60  AlteraMemGenerator(memMauWidth, widthInMaus, addrWidth, initFile,
61  integrator, warningStream, errorStream) {
62 
63  bool noInvert = false;
64  TCEString byteEnableWidth;
65  byteEnableWidth << DATAW_G << "/8";
66  // memory port 1
67  addPort("dmem1_data_in",
68  new HDLPort("q_a", DATAW_G, ProGe::BIT_VECTOR, ProGe::OUT, noInvert,
69  memoryTotalWidth()));
70  addPort("dmem1_data_out",
72  noInvert, memoryTotalWidth()));
73  addPort("dmem1_addr",
74  new HDLPort("address_a", ADDRW_G, ProGe::BIT_VECTOR, ProGe::IN,
75  noInvert, memoryAddrWidth()));
76  addPort("dmem1_mem_en",
77  new HDLPort("enable_a", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
78  addPort("dmem1_wr_en",
79  new HDLPort("wren_a", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
80  addPort("dmem1_wr_mask",
81  new HDLPort("byteena_a", byteEnableWidth, ProGe::BIT_VECTOR,
82  ProGe::IN, noInvert, memoryWidthInMaus()));
83  addPort("clk",
84  new HDLPort("clock_a", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
85 
86  // memory port 2
87  addPort("dmem2_data_in",
88  new HDLPort("q_b", DATAW_G, ProGe::BIT_VECTOR, ProGe::OUT, noInvert,
89  memoryTotalWidth()));
90  addPort("dmem2_data_out",
92  noInvert, memoryTotalWidth()));
93  addPort("dmem2_addr",
94  new HDLPort("address_b", ADDRW_G, ProGe::BIT_VECTOR, ProGe::IN,
95  noInvert, memoryAddrWidth()));
96  addPort("dmem2_mem_en",
97  new HDLPort("enable_b", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
98  addPort("dmem2_wr_en",
99  new HDLPort("wren_b", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
100  addPort("dmem2_wr_mask",
101  new HDLPort("byteena_b", byteEnableWidth, ProGe::BIT_VECTOR,
102  ProGe::IN, noInvert, memoryWidthInMaus()));
103  addPort("clk",
104  new HDLPort("clock_b", "1", ProGe::BIT, ProGe::IN, noInvert, 1));
105 }
106 
107 
109 }
110 
111 
112 bool
114  const std::string fuPort,
115  std::vector<TCEString>& reasons) const {
116 
117  // skip the hibi ports
118  TCEString hibiSignal = "hibi_";
119  if (fuPort.find(hibiSignal) != TCEString::npos) {
120  return true;
121  }
122  return MemoryGenerator::checkFuPort(fuPort, reasons);
123 }
124 
125 
126 void
128  ProGe::NetlistBlock& netlistBlock,
129  const ProGe::NetlistPort& memPort,
130  const ProGe::NetlistPort& corePort,
131  bool inverted,
132  int coreId) {
133 
134  // address ports need special connection
135  if (memPort.name().find("address_") != TCEString::npos) {
136  netlistBlock.netlist().connect(
137  memPort, corePort, 0, 0, memoryAddrWidth());
138  } else {
140  netlistBlock, memPort, corePort, inverted, coreId);
141  }
142 }
143 
144 bool
146  return true;
147 }
148 
149 
150 std::vector<TCEString>
152 
153  return instantiateAlteraTemplate(COMPONENT_FILE, outputPath);
154 }
155 
156 
157 TCEString
159 
160  return ttaCoreName() + "_altera_onchip_dp_ram_comp";
161 }
162 
163 
164 TCEString
165 AlteraHibiDpRamGenerator::instanceName(int coreId, int memIndex) const {
166 
167  TCEString iname("onchip_dp_dmem_");
168  return iname << memoryIndexString(coreId, memIndex);
169 }
AlteraMemGenerator::ADDRW_G
static const TCEString ADDRW_G
Definition: AlteraMemGenerator.hh:77
AlteraHibiDpRamGenerator::generateComponentFile
virtual std::vector< TCEString > generateComponentFile(TCEString outputPath)
Definition: AlteraHibiDpRamGenerator.cc:151
ProGe::NetlistBlock::netlist
virtual const Netlist & netlist() const
Definition: BaseNetlistBlock.cc:348
AlteraMemGenerator::DATAW_G
static const TCEString DATAW_G
Definition: AlteraMemGenerator.hh:78
AlteraMemGenerator
Definition: AlteraMemGenerator.hh:43
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
MemoryGenerator::addPort
void addPort(const TCEString &name, HDLPort *port)
Definition: MemoryGenerator.cc:294
HDLPort
Definition: PlatformIntegrator/HDLPort.hh:48
ProGe::BIT_VECTOR
@ BIT_VECTOR
Several bits.
Definition: ProGeTypes.hh:48
MemoryGenerator::ttaCoreName
TCEString ttaCoreName() const
Definition: MemoryGenerator.cc:319
MemoryGenerator::memoryIndexString
TCEString memoryIndexString(int coreId, int memIndex) const
Definition: MemoryGenerator.cc:383
ProGe::Netlist::connect
bool connect(const NetlistPort &port1, const NetlistPort &port2, int port1FirstBit, int port2FirstBit, int width=1)
Definition: Netlist.cc:83
AlteraHibiDpRamGenerator::~AlteraHibiDpRamGenerator
virtual ~AlteraHibiDpRamGenerator()
Definition: AlteraHibiDpRamGenerator.cc:108
AlteraHibiDpRamGenerator::generatesComponentHdlFile
virtual bool generatesComponentHdlFile() const
Definition: AlteraHibiDpRamGenerator.cc:145
Conversion.hh
MemoryGenerator::checkFuPort
virtual bool checkFuPort(const std::string fuPort, std::vector< TCEString > &reasons) const
Definition: MemoryGenerator.cc:106
NetlistPort.hh
AlteraHibiDpRamGenerator::instanceName
virtual TCEString instanceName(int coreId, int memIndex) const
Definition: AlteraHibiDpRamGenerator.cc:165
NetlistBlock.hh
AlteraHibiDpRamGenerator.hh
AlteraHibiDpRamGenerator::COMPONENT_FILE
static const TCEString COMPONENT_FILE
Definition: AlteraHibiDpRamGenerator.hh:81
HDLPort.hh
ProGe::BIT
@ BIT
One bit.
Definition: ProGeTypes.hh:47
ProGe::NetlistPort::name
std::string name() const
Definition: NetlistPort.cc:283
ProGe::OUT
@ OUT
Output port.
Definition: ProGeTypes.hh:54
AlteraHibiDpRamGenerator::AlteraHibiDpRamGenerator
AlteraHibiDpRamGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
Definition: AlteraHibiDpRamGenerator.cc:52
AlteraMemGenerator::instantiateAlteraTemplate
std::vector< TCEString > instantiateAlteraTemplate(const TCEString &templateFile, const TCEString &outputPath) const
Definition: AlteraMemGenerator.cc:62
FUExternalPort.hh
MemoryGenerator::connectPorts
virtual void connectPorts(ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
Definition: MemoryGenerator.cc:392
MemoryGenerator::memoryWidthInMaus
int memoryWidthInMaus() const
Definition: MemoryGenerator.cc:205
AlteraHibiDpRamGenerator::checkFuPort
virtual bool checkFuPort(const std::string fuPort, std::vector< TCEString > &reasons) const
Definition: AlteraHibiDpRamGenerator.cc:113
TCEString
Definition: TCEString.hh:53
PlatformIntegrator.hh
AlteraHibiDpRamGenerator::connectPorts
virtual void connectPorts(ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
Definition: AlteraHibiDpRamGenerator.cc:127
AlteraHibiDpRamGenerator::moduleName
virtual TCEString moduleName() const
Definition: AlteraHibiDpRamGenerator.cc:158
ProGe::NetlistPort
Definition: NetlistPort.hh:70
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
MemoryGenerator::memoryTotalWidth
int memoryTotalWidth() const
Definition: MemoryGenerator.cc:193
MemoryGenerator::memoryAddrWidth
int memoryAddrWidth() const
Definition: MemoryGenerator.cc:212
ProGe::IN
@ IN
Input port.
Definition: ProGeTypes.hh:53