OpenASIP  2.0
Netlist.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2015 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 Netlist.hh
26  *
27  * Declaration of Netlist class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
31  * @author Henry Linjamäki 2015 (henry.linjamaki-no.spam-tut.fi)
32  * @note rating: red
33  */
34 
35 #ifndef TTA_NETLIST_HH
36 #define TTA_NETLIST_HH
37 
38 // these need to be included before Boost so we include a working
39 // and warning-free hash_map
40 #include "hash_set.hh"
41 #include "hash_map.hh"
42 
43 #include "CompilerWarnings.hh"
44 IGNORE_CLANG_WARNING("-Wunused-local-typedef")
45 #include <boost/graph/adjacency_list.hpp>
47 
49 #include "Exception.hh"
50 #include "TCEString.hh"
51 #include "Parameter.hh"
52 
53 namespace ProGe {
54 
55 class NetlistPort;
56 class NetlistPortGroup;
57 class NetlistBlock;
58 enum class SignalType;
59 
60 /**
61  * Represents a netlist of port connections.
62  */
63 class Netlist : public boost::adjacency_list<
64  boost::vecS, boost::vecS, boost::bidirectionalS, NetlistPort*,
65  PortConnectionProperty> {
66 
67  /// Map type for vertex descriptors
68  typedef std::map<const NetlistPort*, size_t> DescriptorMap;
69 
70 public:
71 
72  Netlist();
73  virtual ~Netlist();
74 
75  bool connect(
76  const NetlistPort& port1,
77  const NetlistPort& port2,
78  int port1FirstBit,
79  int port2FirstBit,
80  int width = 1);
81  bool connect(
82  const NetlistPort& port1,
83  const NetlistPort& port2);
84  bool connect(
85  const NetlistPortGroup& group1,
86  const NetlistPortGroup& group2);
87  bool connectBy(
88  SignalType byType,
89  const NetlistPortGroup& group1,
90  const NetlistPortGroup& group2);
91  bool connect(
92  const NetlistPortGroup& group1,
93  const NetlistPortGroup& group2,
94  std::map<SignalType, SignalType> connectionMap);
95  bool connectGroupByName(
96  const NetlistPortGroup& group1,
97  const NetlistPortGroup& group2);
98 
99  void disconnectPorts(
100  const NetlistPort& port1,
101  const NetlistPort& port2);
102 
103  bool isPortConnected(const NetlistPort& port) const;
104 
105  bool isEmpty() const;
106  bool hasConnections() const;
107 
108  size_t registerPort(NetlistPort& port);
109  size_t descriptor(const NetlistPort& port) const;
110  bool isRegistered(const NetlistPort& port) const;
111  void unregisterPort(NetlistPort& port);
112 
113  //todo overload boost's operator[] with arg (const NetlistPort& port)
114 
115  void setParameter(
116  const std::string& name,
117  const std::string& type,
118  const std::string& value);
119  void setParameter(const Parameter& param);
120  void removeParameter(const std::string& name);
121  bool hasParameter(const std::string& name) const;
122  size_t parameterCount() const;
123  Parameter parameter(size_t index) const;
124 
125  typedef boost::graph_traits<Netlist>::edge_iterator iterator;
126  typedef boost::graph_traits<const Netlist>::edge_iterator const_iterator;
127  iterator begin();
128  iterator end();
129  const_iterator begin() const;
130  const_iterator end() const;
131 
132  typedef DescriptorMap::iterator descriptor_iterator;
133  typedef DescriptorMap::const_iterator const_descriptor_iterator;
138 
139  static void connectClocks(NetlistBlock& block);
140  static void connectResets(NetlistBlock& block);
141 private:
142  /// Vector type for parameters.
143  typedef std::vector<Parameter> ParameterTable;
144 
145  /// Vertex descriptor map.
147  /// Parameters of the netlist.
149 
150  /// This should be set to the entity name of the generate core,
151  /// if it's not the same as the toplevel module name.
153 
154  static const std::string INVERTER_MODULE;
155  static const std::string INVERTER_INPUT;
156  static const std::string INVERTER_OUTPUT;
157 };
158 }
159 
160 #endif
POP_CLANG_DIAGS
#define POP_CLANG_DIAGS
Definition: CompilerWarnings.hh:96
ProGe::Netlist::removeParameter
void removeParameter(const std::string &name)
Definition: Netlist.cc:386
ProGe::Netlist::unregisterPort
void unregisterPort(NetlistPort &port)
Definition: Netlist.cc:342
ProGe::Netlist::ParameterTable
std::vector< Parameter > ParameterTable
Vector type for parameters.
Definition: Netlist.hh:143
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
ProGe::Netlist::parameters_
ParameterTable parameters_
Parameters of the netlist.
Definition: Netlist.hh:148
Exception.hh
ProGe::Netlist::isPortConnected
bool isPortConnected(const NetlistPort &port) const
Definition: Netlist.cc:273
IGNORE_CLANG_WARNING
#define IGNORE_CLANG_WARNING(X)
Definition: CompilerWarnings.hh:85
ProGe::Netlist::disconnectPorts
void disconnectPorts(const NetlistPort &port1, const NetlistPort &port2)
Definition: Netlist.cc:135
ProGe::Netlist::end
iterator end()
Definition: Netlist.cc:448
ProGe::Netlist::descriptorEnd
descriptor_iterator descriptorEnd()
Definition: Netlist.cc:468
ProGe::Netlist::~Netlist
virtual ~Netlist()
Definition: Netlist.cc:63
ProGe::Netlist
Definition: Netlist.hh:63
hash_set.hh
ProGe::Netlist::connect
bool connect(const NetlistPort &port1, const NetlistPort &port2, int port1FirstBit, int port2FirstBit, int width=1)
Definition: Netlist.cc:83
ProGe::Netlist::connectGroupByName
bool connectGroupByName(const NetlistPortGroup &group1, const NetlistPortGroup &group2)
Definition: Netlist.cc:238
TCEString.hh
ProGe::NetlistPortGroup
Definition: NetlistPortGroup.hh:53
ProGe::Netlist::parameterCount
size_t parameterCount() const
Definition: Netlist.cc:422
ProGe::Netlist::hasParameter
bool hasParameter(const std::string &name) const
Definition: Netlist.cc:403
ProGe::Netlist::descriptor_iterator
DescriptorMap::iterator descriptor_iterator
Definition: Netlist.hh:132
ProGe::Netlist::descriptorBegin
descriptor_iterator descriptorBegin()
Definition: Netlist.cc:463
ProGe::Netlist::const_descriptor_iterator
DescriptorMap::const_iterator const_descriptor_iterator
Definition: Netlist.hh:133
ProGe::Parameter
Definition: Parameter.hh:62
ProGe::Netlist::INVERTER_MODULE
static const std::string INVERTER_MODULE
Definition: Netlist.hh:154
ProGe::Netlist::iterator
boost::graph_traits< Netlist >::edge_iterator iterator
Definition: Netlist.hh:125
ProGe::Netlist::connectClocks
static void connectClocks(NetlistBlock &block)
Definition: Netlist.cc:483
ProGe::Netlist::descriptor
size_t descriptor(const NetlistPort &port) const
Definition: Netlist.cc:325
ProGe::Netlist::connectResets
static void connectResets(NetlistBlock &block)
Definition: Netlist.cc:511
ProGe::Netlist::DescriptorMap
std::map< const NetlistPort *, size_t > DescriptorMap
Map type for vertex descriptors.
Definition: Netlist.hh:68
ProGe::SignalType
SignalType
Definition: SignalTypes.hh:42
hash_map.hh
ProGe::Netlist::isRegistered
bool isRegistered(const NetlistPort &port) const
Definition: Netlist.cc:334
ProGe::Netlist::Netlist
Netlist()
Definition: Netlist.cc:56
ProGe::Netlist::registerPort
size_t registerPort(NetlistPort &port)
Definition: Netlist.cc:309
ProGe::Netlist::isEmpty
bool isEmpty() const
Definition: Netlist.cc:288
ProGe
Definition: FUGen.hh:54
TCEString
Definition: TCEString.hh:53
ProGe::Netlist::hasConnections
bool hasConnections() const
Definition: Netlist.cc:296
ProGe::Netlist::parameter
Parameter parameter(size_t index) const
Definition: Netlist.cc:434
PortConnectionProperty.hh
ProGe::Netlist::const_iterator
boost::graph_traits< const Netlist >::edge_iterator const_iterator
Definition: Netlist.hh:126
ProGe::NetlistPort
Definition: NetlistPort.hh:70
ProGe::Netlist::setParameter
void setParameter(const std::string &name, const std::string &type, const std::string &value)
Definition: Netlist.cc:362
ProGe::Netlist::vertexDescriptorMap_
DescriptorMap vertexDescriptorMap_
Vertex descriptor map.
Definition: Netlist.hh:146
ProGe::Netlist::coreEntityName_
TCEString coreEntityName_
This should be set to the entity name of the generate core, if it's not the same as the toplevel modu...
Definition: Netlist.hh:152
ProGe::Netlist::INVERTER_INPUT
static const std::string INVERTER_INPUT
Definition: Netlist.hh:155
ProGe::Netlist::INVERTER_OUTPUT
static const std::string INVERTER_OUTPUT
Definition: Netlist.hh:156
Parameter.hh
ProGe::Netlist::begin
iterator begin()
Definition: Netlist.cc:443
CompilerWarnings.hh
ProGe::Netlist::connectBy
bool connectBy(SignalType byType, const NetlistPortGroup &group1, const NetlistPortGroup &group2)
Definition: Netlist.cc:182