OpenASIP 2.2
Loading...
Searching...
No Matches
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"
45using std::endl;
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,
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,
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
110
111
112bool
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
126void
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
144bool
148
149
150std::vector<TCEString>
155
156
159
160 return ttaCoreName() + "_altera_onchip_dp_ram_comp";
161}
162
163
165AlteraHibiDpRamGenerator::instanceName(int coreId, int memIndex) const {
166
167 TCEString iname("onchip_dp_dmem_");
168 return iname << memoryIndexString(coreId, memIndex);
169}
virtual TCEString moduleName() const
virtual TCEString instanceName(int coreId, int memIndex) const
AlteraHibiDpRamGenerator(int memMauWidth, int widthInMaus, int addrWidth, TCEString initFile, const PlatformIntegrator *integrator, std::ostream &warningStream, std::ostream &errorStream)
virtual std::vector< TCEString > generateComponentFile(TCEString outputPath)
virtual bool generatesComponentHdlFile() const
virtual void connectPorts(ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
virtual bool checkFuPort(const std::string fuPort, std::vector< TCEString > &reasons) const
static const TCEString COMPONENT_FILE
static const TCEString ADDRW_G
std::vector< TCEString > instantiateAlteraTemplate(const TCEString &templateFile, const TCEString &outputPath) const
static const TCEString DATAW_G
TCEString memoryIndexString(int coreId, int memIndex) const
int memoryWidthInMaus() const
virtual bool checkFuPort(const std::string fuPort, std::vector< TCEString > &reasons) const
void addPort(const TCEString &name, HDLPort *port)
int memoryTotalWidth() const
int memoryAddrWidth() const
virtual void connectPorts(ProGe::NetlistBlock &netlistBlock, const ProGe::NetlistPort &memPort, const ProGe::NetlistPort &corePort, bool inverted, int coreId)
TCEString ttaCoreName() const
virtual const Netlist & netlist() const
std::string name() const
bool connect(const NetlistPort &port1, const NetlistPort &port2, int port1FirstBit, int port2FirstBit, int width=1)
Definition Netlist.cc:83
@ BIT
One bit.
Definition ProGeTypes.hh:47
@ BIT_VECTOR
Several bits.
Definition ProGeTypes.hh:48
@ OUT
Output port.
Definition ProGeTypes.hh:54
@ IN
Input port.
Definition ProGeTypes.hh:53