OpenASIP 2.2
Loading...
Searching...
No Matches
DefaultICGenerator.hh
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 DefaultICGenerator.hh
26 *
27 * Declaration of DefaultICGenerator class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @author Otto Esko 2008 (otto.esko-no.spam-tut.fi)
31 * @author Pekka Jääskeläinen 2011
32 * @author Vinogradov Viacheslav(added Verilog generating) 2012
33 * @note rating: red
34 */
35
36#ifndef TTA_DEFAULT_IC_GENERATOR_HH
37#define TTA_DEFAULT_IC_GENERATOR_HH
38
39#include <map>
40#include <set>
41
43#include "ProGeTypes.hh"
44#include "HDBTypes.hh"
45#include "Socket.hh"
46#include "Machine.hh"
47
48namespace TTAMachine {
49 class Machine;
50}
51
52namespace ProGe {
53 class Netlist;
54 class NetlistBlock;
55 class NetlistGenerator;
56}
57
58/**
59 * This class generates interconnection network in VHDL/Verilog.
60 * The network uses and-or buses.
61 */
63public:
64 typedef std::map<const TTAMachine::Bus*,
65 std::set<TTAMachine::Socket*>> BusSocketMap;
66
68 virtual ~DefaultICGenerator();
69
70 void SetHDL(ProGe::HDL language);
71
72 void addICToNetlist(
73 const ProGe::NetlistGenerator& generator,
74 ProGe::NetlistBlock& netlistBlock);
75 void generateInterconnectionNetwork(const std::string& dstDirectory);
76 void verifyCompatibility() const;
77
78 void setGenerateBusTrace(bool generate);
79 void setExportBustrace(bool export_bt);
80 void setFPGAOptimization(bool optimized);
81 void setBusTraceStartingCycle(unsigned int cycle);
83
85 const TTAMachine::Socket& socket,
86 const TTAMachine::Segment& segment) const;
87
89 const TTAMachine::Socket& socket, const TTAMachine::Port& port) const;
90
91 virtual int inputSocketControlValue(
92 const TTAMachine::Socket& socket,
93 const TTAMachine::Segment& segment) const;
94
95 virtual const BusSocketMap getBusConnections() const;
96
97private:
98 typedef std::map<const TTAMachine::Socket*, int> SocketSignalMap;
99 typedef std::map<const TTAMachine::Bus*, SocketSignalMap*>
101
102 void writeInterconnectionNetwork(std::ostream& stream);
103
104 void generateSocketsAndMuxes(const std::string& dstDirectory);
105
106 bool isGcuPort(const TTAMachine::Port* port) const;
107
108 void generateSocket(
109 TTAMachine::Socket::Direction direction, int portConns,
110 int segmentConns, const std::string& dstDirectory) const;
111 void generateInputMux(
112 int segmentConns,
113 std::ofstream& stream) const;
115 int bus,
116 int ind,
117 std::ofstream& stream) const;
119 int portConns,
120 int segmentConns,
121 std::ofstream& stream) const;
122 void createSignalsForIC(std::ostream& stream);
123 void declareSocketEntities(std::ostream& stream) const;
125 const ProGe::HDL language,
126 int portConns,
127 int segmentConns,
128 int ind,
129 std::ostream& stream);
131 const ProGe::HDL language,
132 int segmentConns,
133 int ind,
134 std::ostream& stream);
135 void writeBusDumpCode(std::ostream& stream) const;
136 void writeBustraceExportCode(std::ostream& stream) const;
137
138 static bool isBusConnected(const TTAMachine::Bus& bus);
139 static std::set<TTAMachine::Socket*> inputSockets(
140 const TTAMachine::Bus& bus);
141 static std::set<TTAMachine::Socket*> outputSockets(
142 const TTAMachine::Bus& bus);
143
144 bool socketIsGenerated(const TTAMachine::Socket& socket);
145 bool socketIsGenerated(int segmentConns, int portConns,
147
148 static int inputSocketDataPortWidth(const TTAMachine::Socket& socket);
149 static int outputSocketDataPortWidth(
150 const TTAMachine::Socket& socket,
151 int port);
153 const TTAMachine::Socket& socket);
154 static int busControlWidth(
156 int busConns);
157 static int dataControlWidth(
159 int portConns);
160 static int simmPortWidth(const TTAMachine::Bus& bus);
161
162 static std::string inputSocketDataPort(const std::string& socket);
163 static std::string outputSocketDataPort(
164 const std::string& socket,
165 int port);
166 static std::string socketBusControlPort(const std::string& name);
167 static std::string socketDataControlPort(const std::string& name);
168 static std::string simmDataPort(const std::string& busName);
169 static std::string simmControlPort(const std::string& busName);
170 static std::string inputSocketBusPort(int bus);
171 static std::string outputSocketBusPort(int bus);
172 static std::string outputSocketDataPort(int port);
173 static std::string busMuxDataPort(const TTAMachine::Bus& bus, int index);
174 static std::string busMuxControlPort(const TTAMachine::Bus& bus);
175 static std::string busMuxEnablePort(const TTAMachine::Bus& bus);
176
177 static std::string busWidthGeneric(int bus);
178 static std::string dataWidthGeneric(int port);
179
180 static std::string simmSocket(const TTAMachine::Bus& bus);
181 static std::string simmSignal(const TTAMachine::Bus& bus);
182
183 static std::string busSignal(const TTAMachine::Bus& bus);
184 std::string busAltSignal(
185 const TTAMachine::Bus& bus,
186 const TTAMachine::Socket& socket);
187
190
191 static std::string socketFileName(
192 const ProGe::HDL language,
194 int portConns,
195 int segmentConns);
196 std::string socketEntityName(TTAMachine::Socket &socket) const;
197 static std::string busMuxEntityName(TTAMachine::Bus &bus);
198 std::string inputMuxEntityName(int conns) const;
199 std::string outputSocketEntityName(int busConns, int portConns) const;
200
201 static std::string indentation(unsigned int level);
202
203 /// The machine.
205 /// The netlist block of IC.
207 /// Signal numbers for controlling sockets.
209 /// Tells whether to generate bus tracing code.
211 /// Tells whether to export bustraces to debugger
213 /// The starting cycle for bus tracing.
218
219 // Bookkeeping between writing socket RTL and entity
220 std::set<std::pair<int, int>> generatedOutputSockets_;
221 std::set<std::pair<int, int>> generatedInputSockets_;
222};
223
224#endif
TTAMachine::Machine * machine
the architecture definition of the estimated processor
void verifyCompatibility() const
void setFPGAOptimization(bool optimized)
static std::set< TTAMachine::Socket * > inputSockets(const TTAMachine::Bus &bus)
static std::string busMuxEntityName(TTAMachine::Bus &bus)
std::string socketEntityName(TTAMachine::Socket &socket) const
static std::string simmSocket(const TTAMachine::Bus &bus)
std::string outputSocketEntityName(int busConns, int portConns) const
static std::string inputSocketBusPort(int bus)
void setBusTraceStartingCycle(unsigned int cycle)
void setGenerateBusTrace(bool generate)
virtual int outputSocketDataControlValue(const TTAMachine::Socket &socket, const TTAMachine::Port &port) const
std::map< const TTAMachine::Socket *, int > SocketSignalMap
static ProGe::Direction convertDirection(TTAMachine::Socket::Direction direction)
static std::string simmSignal(const TTAMachine::Bus &bus)
static std::string simmControlPort(const std::string &busName)
std::map< const TTAMachine::Bus *, SocketSignalMap * > BusAltSignalMap
static int maxOutputSocketDataPortWidth(const TTAMachine::Socket &socket)
static std::string socketFileName(const ProGe::HDL language, TTAMachine::Socket::Direction direction, int portConns, int segmentConns)
const TTAMachine::Machine & machine_
The machine.
void SetHDL(ProGe::HDL language)
void declareSocketEntities(std::ostream &stream) const
static int outputSocketDataPortWidth(const TTAMachine::Socket &socket, int port)
virtual int inputSocketControlValue(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment) const
static void writeInputSocketComponentDeclaration(const ProGe::HDL language, int segmentConns, int ind, std::ostream &stream)
static std::string indentation(unsigned int level)
std::string busAltSignal(const TTAMachine::Bus &bus, const TTAMachine::Socket &socket)
static bool isBusConnected(const TTAMachine::Bus &bus)
virtual const BusSocketMap getBusConnections() const
static std::string dataWidthGeneric(int port)
void generateInputSocketRuleForBus(int bus, int ind, std::ofstream &stream) const
BusAltSignalMap altSignalMap_
Signal numbers for controlling sockets.
void generateSocket(TTAMachine::Socket::Direction direction, int portConns, int segmentConns, const std::string &dstDirectory) const
void generateOutputSocket(int portConns, int segmentConns, std::ofstream &stream) const
void createSignalsForIC(std::ostream &stream)
std::set< std::pair< int, int > > generatedOutputSockets_
bool socketIsGenerated(const TTAMachine::Socket &socket)
static std::set< TTAMachine::Socket * > outputSockets(const TTAMachine::Bus &bus)
void writeBusDumpCode(std::ostream &stream) const
void addICToNetlist(const ProGe::NetlistGenerator &generator, ProGe::NetlistBlock &netlistBlock)
static std::string simmDataPort(const std::string &busName)
static std::string outputSocketBusPort(int bus)
virtual int outputSocketCntrlPinForSegment(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment) const
static std::string outputSocketDataPort(const std::string &socket, int port)
void setExportBustrace(bool export_bt)
void generateSocketsAndMuxes(const std::string &dstDirectory)
std::set< std::pair< int, int > > generatedInputSockets_
static int dataControlWidth(TTAMachine::Socket::Direction direction, int portConns)
void generateInterconnectionNetwork(const std::string &dstDirectory)
static std::string busWidthGeneric(int bus)
static int simmPortWidth(const TTAMachine::Bus &bus)
static std::string busMuxDataPort(const TTAMachine::Bus &bus, int index)
ProGe::NetlistBlock * icBlock_
The netlist block of IC.
static std::string socketBusControlPort(const std::string &name)
unsigned int busTraceStartingCycle_
The starting cycle for bus tracing.
static std::string busSignal(const TTAMachine::Bus &bus)
void generateInputMux(int segmentConns, std::ofstream &stream) const
std::string inputMuxEntityName(int conns) const
void writeBustraceExportCode(std::ostream &stream) const
static int busControlWidth(TTAMachine::Socket::Direction direction, int busConns)
static std::string socketDataControlPort(const std::string &name)
static int inputSocketDataPortWidth(const TTAMachine::Socket &socket)
bool generateBusTrace_
Tells whether to generate bus tracing code.
void writeInterconnectionNetwork(std::ostream &stream)
bool isGcuPort(const TTAMachine::Port *port) const
static std::string busMuxControlPort(const TTAMachine::Bus &bus)
static std::string inputSocketDataPort(const std::string &socket)
bool exportBustrace_
Tells whether to export bustraces to debugger.
static std::string busMuxEnablePort(const TTAMachine::Bus &bus)
std::map< const TTAMachine::Bus *, std::set< TTAMachine::Socket * > > BusSocketMap
static void writeOutputSocketComponentDeclaration(const ProGe::HDL language, int portConns, int segmentConns, int ind, std::ostream &stream)
Definition FUGen.hh:54
Direction
Direction of the port.
Definition ProGeTypes.hh:52
HDL
HDLs supported by ProGe.
Definition ProGeTypes.hh:40