OpenASIP  2.0
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 
48 namespace TTAMachine {
49  class Machine;
50 }
51 
52 namespace 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  */
63 public:
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);
82  bool isBustraceEnabled();
83 
85  const TTAMachine::Socket& socket,
86  const TTAMachine::Segment& segment) const;
87 
88  virtual int outputSocketDataControlValue(
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 
97 private:
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);
152  static int maxOutputSocketDataPortWidth(
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
DefaultICGenerator::BusAltSignalMap
std::map< const TTAMachine::Bus *, SocketSignalMap * > BusAltSignalMap
Definition: DefaultICGenerator.hh:100
DefaultICGenerator::dataWidthGeneric
static std::string dataWidthGeneric(int port)
Definition: DefaultICGenerator.cc:2378
HDBTypes.hh
DefaultICGenerator::busAltSignal
std::string busAltSignal(const TTAMachine::Bus &bus, const TTAMachine::Socket &socket)
Definition: DefaultICGenerator.cc:2332
DefaultICGenerator::generateSocket
void generateSocket(TTAMachine::Socket::Direction direction, int portConns, int segmentConns, const std::string &dstDirectory) const
Definition: DefaultICGenerator.cc:453
DefaultICGenerator::outputSocketEntityName
std::string outputSocketEntityName(int busConns, int portConns) const
Definition: DefaultICGenerator.cc:2496
DefaultICGenerator::busMuxEnablePort
static std::string busMuxEnablePort(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2308
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
DefaultICGenerator::simmSignal
static std::string simmSignal(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2402
DefaultICGenerator::declareSocketEntities
void declareSocketEntities(std::ostream &stream) const
Definition: DefaultICGenerator.cc:1443
DefaultICGenerator::dataControlWidth
static int dataControlWidth(TTAMachine::Socket::Direction direction, int portConns)
Definition: DefaultICGenerator.cc:2152
TTAMachine::Segment
Definition: Segment.hh:54
DefaultICGenerator::addICToNetlist
void addICToNetlist(const ProGe::NetlistGenerator &generator, ProGe::NetlistBlock &netlistBlock)
Definition: DefaultICGenerator.cc:114
DefaultICGenerator::writeBustraceExportCode
void writeBustraceExportCode(std::ostream &stream) const
Definition: DefaultICGenerator.cc:906
DefaultICGenerator::simmControlPort
static std::string simmControlPort(const std::string &busName)
Definition: DefaultICGenerator.cc:2257
TTAMachine::Bus
Definition: Bus.hh:53
DefaultICGenerator::busMuxEntityName
static std::string busMuxEntityName(TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2503
DefaultICGenerator::SocketSignalMap
std::map< const TTAMachine::Socket *, int > SocketSignalMap
Definition: DefaultICGenerator.hh:98
DefaultICGenerator::getBusConnections
virtual const BusSocketMap getBusConnections() const
Definition: DefaultICGenerator.cc:2060
DefaultICGenerator::socketFileName
static std::string socketFileName(const ProGe::HDL language, TTAMachine::Socket::Direction direction, int portConns, int segmentConns)
Definition: DefaultICGenerator.cc:2439
TTAMachine::Socket::Direction
Direction
Definition: Socket.hh:58
DefaultICGenerator::busConnections
BusSocketMap busConnections
Definition: DefaultICGenerator.hh:217
DefaultICGenerator::outputSocketDataPort
static std::string outputSocketDataPort(const std::string &socket, int port)
Definition: DefaultICGenerator.cc:2204
DefaultICGenerator::socketIsGenerated
bool socketIsGenerated(const TTAMachine::Socket &socket)
Definition: DefaultICGenerator.cc:1978
Socket.hh
DefaultICGenerator::socketDataControlPort
static std::string socketDataControlPort(const std::string &name)
Definition: DefaultICGenerator.cc:2232
DefaultICGenerator::generateBusTrace_
bool generateBusTrace_
Tells whether to generate bus tracing code.
Definition: DefaultICGenerator.hh:210
DefaultICGenerator::exportBustrace_
bool exportBustrace_
Tells whether to export bustraces to debugger.
Definition: DefaultICGenerator.hh:212
DefaultICGenerator::socketEntityName
std::string socketEntityName(TTAMachine::Socket &socket) const
Definition: DefaultICGenerator.cc:2464
DefaultICGenerator::generateInputSocketRuleForBus
void generateInputSocketRuleForBus(int bus, int ind, std::ofstream &stream) const
Definition: DefaultICGenerator.cc:621
DefaultICGenerator::inputSocketControlValue
virtual int inputSocketControlValue(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment) const
Definition: DefaultICGenerator.cc:2042
CentralizedControlICGenerator
Definition: CentralizedControlICGenerator.hh:52
DefaultICGenerator::createSignalsForIC
void createSignalsForIC(std::ostream &stream)
Definition: DefaultICGenerator.cc:1364
DefaultICGenerator::writeBusDumpCode
void writeBusDumpCode(std::ostream &stream) const
Definition: DefaultICGenerator.cc:1671
DefaultICGenerator::busMuxControlPort
static std::string busMuxControlPort(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2303
DefaultICGenerator::busSignal
static std::string busSignal(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2319
DefaultICGenerator::generateInputMux
void generateInputMux(int segmentConns, std::ofstream &stream) const
Definition: DefaultICGenerator.cc:493
DefaultICGenerator::BusSocketMap
std::map< const TTAMachine::Bus *, std::set< TTAMachine::Socket * > > BusSocketMap
Definition: DefaultICGenerator.hh:65
DefaultICGenerator::setGenerateBusTrace
void setGenerateBusTrace(bool generate)
Definition: DefaultICGenerator.cc:337
DefaultICGenerator::isGcuPort
bool isGcuPort(const TTAMachine::Port *port) const
Definition: DefaultICGenerator.cc:432
DefaultICGenerator::inputSocketDataPortWidth
static int inputSocketDataPortWidth(const TTAMachine::Socket &socket)
Definition: DefaultICGenerator.cc:2070
DefaultICGenerator::DefaultICGenerator
DefaultICGenerator(const TTAMachine::Machine &machine)
Definition: DefaultICGenerator.cc:81
TTAMachine::Port
Definition: Port.hh:54
DefaultICGenerator::simmDataPort
static std::string simmDataPort(const std::string &busName)
Definition: DefaultICGenerator.cc:2244
DefaultICGenerator::generateOutputSocket
void generateOutputSocket(int portConns, int segmentConns, std::ofstream &stream) const
Definition: DefaultICGenerator.cc:652
CentralizedControlICGenerator.hh
DefaultICGenerator::inputSocketBusPort
static std::string inputSocketBusPort(int bus)
Definition: DefaultICGenerator.cc:2269
DefaultICGenerator::simmSocket
static std::string simmSocket(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2390
TTAMachine::Socket
Definition: Socket.hh:53
DefaultICGenerator::altSignalMap_
BusAltSignalMap altSignalMap_
Signal numbers for controlling sockets.
Definition: DefaultICGenerator.hh:208
DefaultICGenerator::busMuxDataPort
static std::string busMuxDataPort(const TTAMachine::Bus &bus, int index)
Definition: DefaultICGenerator.cc:2298
DefaultICGenerator
Definition: DefaultICGenerator.hh:62
DefaultICGenerator::busWidthGeneric
static std::string busWidthGeneric(int bus)
Definition: DefaultICGenerator.cc:2366
DefaultICGenerator::generatedInputSockets_
std::set< std::pair< int, int > > generatedInputSockets_
Definition: DefaultICGenerator.hh:221
Machine.hh
ProGeTypes.hh
DefaultICGenerator::outputSockets
static std::set< TTAMachine::Socket * > outputSockets(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:1954
DefaultICGenerator::writeInputSocketComponentDeclaration
static void writeInputSocketComponentDeclaration(const ProGe::HDL language, int segmentConns, int ind, std::ostream &stream)
Definition: DefaultICGenerator.cc:1593
DefaultICGenerator::socketBusControlPort
static std::string socketBusControlPort(const std::string &name)
Definition: DefaultICGenerator.cc:2220
DefaultICGenerator::~DefaultICGenerator
virtual ~DefaultICGenerator()
Definition: DefaultICGenerator.cc:91
DefaultICGenerator::generateSocketsAndMuxes
void generateSocketsAndMuxes(const std::string &dstDirectory)
Definition: DefaultICGenerator.cc:388
DefaultICGenerator::icBlock_
ProGe::NetlistBlock * icBlock_
The netlist block of IC.
Definition: DefaultICGenerator.hh:206
DefaultICGenerator::SetHDL
void SetHDL(ProGe::HDL language)
Definition: DefaultICGenerator.cc:103
ProGe::NetlistGenerator
Definition: NetlistGenerator.hh:84
DefaultICGenerator::writeInterconnectionNetwork
void writeInterconnectionNetwork(std::ostream &stream)
Definition: DefaultICGenerator.cc:947
DefaultICGenerator::isBusConnected
static bool isBusConnected(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:1913
DefaultICGenerator::convertDirection
static ProGe::Direction convertDirection(TTAMachine::Socket::Direction direction)
Definition: DefaultICGenerator.cc:2416
ProGe
Definition: FUGen.hh:54
DefaultICGenerator::writeOutputSocketComponentDeclaration
static void writeOutputSocketComponentDeclaration(const ProGe::HDL language, int portConns, int segmentConns, int ind, std::ostream &stream)
Definition: DefaultICGenerator.cc:1478
DefaultICGenerator::generatedOutputSockets_
std::set< std::pair< int, int > > generatedOutputSockets_
Definition: DefaultICGenerator.hh:220
DefaultICGenerator::setBusTraceStartingCycle
void setBusTraceStartingCycle(unsigned int cycle)
Definition: DefaultICGenerator.cc:348
TCEString
Definition: TCEString.hh:53
DefaultICGenerator::machine_
const TTAMachine::Machine & machine_
The machine.
Definition: DefaultICGenerator.hh:204
DefaultICGenerator::entityNameStr_
TCEString entityNameStr_
Definition: DefaultICGenerator.hh:215
DefaultICGenerator::verifyCompatibility
void verifyCompatibility() const
Definition: DefaultICGenerator.cc:306
DefaultICGenerator::simmPortWidth
static int simmPortWidth(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:2170
DefaultICGenerator::indentation
static std::string indentation(unsigned int level)
Definition: DefaultICGenerator.cc:2513
ProGe::HDL
HDL
HDLs supported by ProGe.
Definition: ProGeTypes.hh:40
DefaultICGenerator::language_
ProGe::HDL language_
Definition: DefaultICGenerator.hh:216
DefaultICGenerator::outputSocketCntrlPinForSegment
virtual int outputSocketCntrlPinForSegment(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment) const
Definition: DefaultICGenerator.cc:364
DefaultICGenerator::maxOutputSocketDataPortWidth
static int maxOutputSocketDataPortWidth(const TTAMachine::Socket &socket)
Definition: DefaultICGenerator.cc:2106
TTAMachine
Definition: Assembler.hh:48
DefaultICGenerator::outputSocketDataControlValue
virtual int outputSocketDataControlValue(const TTAMachine::Socket &socket, const TTAMachine::Port &port) const
Definition: DefaultICGenerator.cc:2016
DefaultICGenerator::generateInterconnectionNetwork
void generateInterconnectionNetwork(const std::string &dstDirectory)
Definition: DefaultICGenerator.cc:283
DefaultICGenerator::outputSocketBusPort
static std::string outputSocketBusPort(int bus)
Definition: DefaultICGenerator.cc:2281
DefaultICGenerator::busControlWidth
static int busControlWidth(TTAMachine::Socket::Direction direction, int busConns)
Definition: DefaultICGenerator.cc:2129
DefaultICGenerator::inputMuxEntityName
std::string inputMuxEntityName(int conns) const
Definition: DefaultICGenerator.cc:2483
DefaultICGenerator::inputSockets
static std::set< TTAMachine::Socket * > inputSockets(const TTAMachine::Bus &bus)
Definition: DefaultICGenerator.cc:1932
ProGe::Direction
Direction
Direction of the port.
Definition: ProGeTypes.hh:52
DefaultICGenerator::setExportBustrace
void setExportBustrace(bool export_bt)
Definition: DefaultICGenerator.cc:327
DefaultICGenerator::busTraceStartingCycle_
unsigned int busTraceStartingCycle_
The starting cycle for bus tracing.
Definition: DefaultICGenerator.hh:214
DefaultICGenerator::isBustraceEnabled
bool isBustraceEnabled()
DefaultICGenerator::inputSocketDataPort
static std::string inputSocketDataPort(const std::string &socket)
Definition: DefaultICGenerator.cc:2190
TTAMachine::Machine
Definition: Machine.hh:73
DefaultICGenerator::outputSocketDataPortWidth
static int outputSocketDataPortWidth(const TTAMachine::Socket &socket, int port)
Definition: DefaultICGenerator.cc:2090
DefaultICGenerator::setFPGAOptimization
void setFPGAOptimization(bool optimized)