Verilog to Routing - VPR
clustered_netlist.h
Go to the documentation of this file.
1 #ifndef CLUSTERED_NETLIST_H
2 #define CLUSTERED_NETLIST_H
3 
112 #include "vpr_types.h"
113 #include "vpr_utils.h"
114 
115 #include "vtr_util.h"
116 
117 #include "netlist.h"
118 #include "clustered_netlist_fwd.h"
119 
120 class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPinId, ClusterNetId> {
121  public:
128  ClusteredNetlist(std::string name = "", std::string id = "");
129 
130  public: //Public Accessors
131 
132  /*
133  * Blocks
134  */
135 
137  t_pb* block_pb(const ClusterBlockId id) const;
138 
140  t_logical_block_type_ptr block_type(const ClusterBlockId id) const;
141 
143  ClusterNetId block_net(const ClusterBlockId blk_id, const int pin_index) const;
144 
146  int block_pin_net_index(const ClusterBlockId blk_id, const int pin_index) const;
147 
149  ClusterPinId block_pin(const ClusterBlockId blk, const int logical_pin_index) const;
150 
151  //** @brief Returns true if the specified block contains a primary input (e.g. BLIF .input primitive) */
152  bool block_contains_primary_input(const ClusterBlockId blk) const;
153 
155  bool block_contains_primary_output(const ClusterBlockId blk) const;
156 
157  /*
158  * Pins
159  */
160 
165  int pin_logical_index(const ClusterPinId pin_id) const;
166 
175  int net_pin_logical_index(const ClusterNetId net_id, int net_pin_index) const;
176 
177  /*
178  * Nets
179  */
180 
182  bool net_is_ignored(const ClusterNetId id) const;
183 
185  bool net_is_global(const ClusterNetId id) const;
186 
187  public: //Public Mutators
188 
196  ClusterBlockId create_block(const char* name, t_pb* pb, t_logical_block_type_ptr type);
197 
206  ClusterPortId create_port(const ClusterBlockId blk_id, const std::string name, BitIndex width, PortType type);
217  ClusterPinId create_pin(const ClusterPortId port_id, BitIndex port_bit, const ClusterNetId net_id, const PinType pin_type, int pin_index, bool is_const = false);
218 
223  ClusterNetId create_net(const std::string name);
224 
226  void set_net_is_ignored(ClusterNetId net_id, bool state);
227 
229  void set_net_is_global(ClusterNetId net_id, bool state);
230 
231  private: //Private Members
232  /*
233  * Netlist compression/optimization
234  */
235 
237  void clean_blocks_impl(const vtr::vector_map<ClusterBlockId, ClusterBlockId>& block_id_map) override;
238  void clean_ports_impl(const vtr::vector_map<ClusterPortId, ClusterPortId>& port_id_map) override;
239  void clean_pins_impl(const vtr::vector_map<ClusterPinId, ClusterPinId>& pin_id_map) override;
240  void clean_nets_impl(const vtr::vector_map<ClusterNetId, ClusterNetId>& net_id_map) override;
241 
243  void shrink_to_fit_impl() override;
244 
245  /*
246  * Component removal
247  */
248 
255  void remove_block_impl(const ClusterBlockId blk_id) override;
256  void remove_port_impl(const ClusterPortId port_id) override;
257  void remove_pin_impl(const ClusterPinId pin_id) override;
258  void remove_net_impl(const ClusterNetId net_id) override;
259 
260  void rebuild_block_refs_impl(const vtr::vector_map<ClusterPinId, ClusterPinId>& pin_id_map, const vtr::vector_map<ClusterPortId, ClusterPortId>& port_id_map) override;
261  void rebuild_port_refs_impl(const vtr::vector_map<ClusterBlockId, ClusterBlockId>& block_id_map, const vtr::vector_map<ClusterPinId, ClusterPinId>& pin_id_map) override;
262  void rebuild_pin_refs_impl(const vtr::vector_map<ClusterPortId, ClusterPortId>& port_id_map, const vtr::vector_map<ClusterNetId, ClusterNetId>& net_id_map) override;
263  void rebuild_net_refs_impl(const vtr::vector_map<ClusterPinId, ClusterPinId>& pin_id_map) override;
264 
265  /*
266  * Sanity Checks
267  */
268 
269  //Verify the internal data structure sizes match
270  bool validate_block_sizes_impl(size_t num_blocks) const override;
271  bool validate_port_sizes_impl(size_t num_ports) const override;
272  bool validate_pin_sizes_impl(size_t num_pins) const override;
273  bool validate_net_sizes_impl(size_t num_nets) const override;
274 
275  private: //Private Data
276  //Blocks
277  vtr::vector_map<ClusterBlockId, t_pb*> block_pbs_;
278  vtr::vector_map<ClusterBlockId, t_logical_block_type_ptr> block_types_;
279  vtr::vector_map<ClusterBlockId, std::vector<ClusterPinId>> block_logical_pins_;
281  //Pins
282  vtr::vector_map<ClusterPinId, int> pin_logical_index_;
286  //Nets
287  vtr::vector_map<ClusterNetId, bool> net_is_ignored_;
288  vtr::vector_map<ClusterNetId, bool> net_is_global_;
289 };
290 
291 #endif
int block_pin_net_index(const ClusterBlockId blk_id, const int pin_index) const
Returns the count on the net of the block attached.
Definition: clustered_netlist.cpp:41
ClusterPinId block_pin(const ClusterBlockId blk, const int logical_pin_index) const
Returns the logical pin Id associated with the specified block and logical pin index.
Definition: clustered_netlist.cpp:51
bool validate_block_sizes_impl(size_t num_blocks) const override
Definition: clustered_netlist.cpp:282
ClusterNetId create_net(const std::string name)
Create an empty, or return an existing net in the netlist.
Definition: clustered_netlist.cpp:167
void shrink_to_fit_impl() override
Shrinks internal data structures to required size to reduce memory consumption.
Definition: clustered_netlist.cpp:263
ClusteredNetlist(std::string name="", std::string id="")
Constructs a netlist.
Definition: clustered_netlist.cpp:11
vtr::StrongId< cluster_port_id_tag > ClusterPortId
A unique identifier for a port in the atom netlist.
Definition: clustered_netlist_fwd.h:26
void rebuild_block_refs_impl(const vtr::vector_map< ClusterPinId, ClusterPinId > &pin_id_map, const vtr::vector_map< ClusterPortId, ClusterPortId > &port_id_map) override
Definition: clustered_netlist.cpp:238
void remove_net_impl(const ClusterNetId net_id) override
Definition: clustered_netlist.cpp:212
This file defines the Netlist class, which stores the connectivity information of the components in a...
void remove_pin_impl(const ClusterPinId pin_id) override
Definition: clustered_netlist.cpp:208
bool block_contains_primary_output(const ClusterBlockId blk) const
Returns true if the specified block contains a primary output (e.g. BLIF .output primitive) ...
Definition: clustered_netlist.cpp:65
This is a core file that defines the major data types used by VPR.
void remove_block_impl(const ClusterBlockId blk_id) override
Removes a block from the netlist.
Definition: clustered_netlist.cpp:195
void rebuild_port_refs_impl(const vtr::vector_map< ClusterBlockId, ClusterBlockId > &block_id_map, const vtr::vector_map< ClusterPinId, ClusterPinId > &pin_id_map) override
Definition: clustered_netlist.cpp:249
void clean_ports_impl(const vtr::vector_map< ClusterPortId, ClusterPortId > &port_id_map) override
Definition: clustered_netlist.cpp:223
void set_net_is_ignored(ClusterNetId net_id, bool state)
Sets the flag in net_ignored_ = state.
Definition: clustered_netlist.cpp:183
bool net_is_global(const ClusterNetId id) const
Returns whether the net is global.
Definition: clustered_netlist.cpp:103
PinType pin_type(const ClusterPinId pin_id) const
Returns the type of the specified pin.
bool validate_pin_sizes_impl(size_t num_pins) const override
Definition: clustered_netlist.cpp:296
void clean_blocks_impl(const vtr::vector_map< ClusterBlockId, ClusterBlockId > &block_id_map) override
Removes invalid components and reorders them.
Definition: clustered_netlist.cpp:216
void set_net_is_global(ClusterNetId net_id, bool state)
Sets the flag in net_is_global_ = state.
Definition: clustered_netlist.cpp:189
void clean_nets_impl(const vtr::vector_map< ClusterNetId, ClusterNetId > &net_id_map) override
Definition: clustered_netlist.cpp:232
PortType
The type of a port in the Netlist.
Definition: netlist_fwd.h:19
vtr::vector_map< ClusterNetId, bool > net_is_ignored_
Definition: clustered_netlist.h:287
void remove_port_impl(const ClusterPortId port_id) override
Definition: clustered_netlist.cpp:204
int net_pin_logical_index(const ClusterNetId net_id, int net_pin_index) const
Finds the net_index&#39;th net pin (e.g. the 6th pin of the net) and returns the logical pin index (i...
Definition: clustered_netlist.cpp:82
vtr::vector_map< ClusterBlockId, t_pb * > block_pbs_
Definition: clustered_netlist.h:277
ClusterPinId create_pin(const ClusterPortId port_id, BitIndex port_bit, const ClusterNetId net_id, const PinType pin_type, int pin_index, bool is_const=false)
Create or return an existing pin in the netlist.
Definition: clustered_netlist.cpp:153
bool validate_net_sizes_impl(size_t num_nets) const override
Definition: clustered_netlist.cpp:303
ClusterPortId create_port(const ClusterBlockId blk_id, const std::string name, BitIndex width, PortType type)
Create or return an existing port in the netlist.
Definition: clustered_netlist.cpp:136
int pin_logical_index(const ClusterPinId pin_id) const
Returns the logical pin index (i.e. pin index on the t_logical_block_type) of the cluster pin...
Definition: clustered_netlist.cpp:76
PinType
Definition: netlist_fwd.h:25
A t_pb represents an instance of a clustered block.
Definition: vpr_types.h:288
Definition: clustered_netlist.h:120
vtr::StrongId< cluster_net_id_tag > ClusterNetId
A unique identifier for a net in the atom netlist.
Definition: clustered_netlist_fwd.h:23
Definition: netlist.h:446
vtr::vector_map< ClusterBlockId, t_logical_block_type_ptr > block_types_
Definition: clustered_netlist.h:278
void rebuild_pin_refs_impl(const vtr::vector_map< ClusterPortId, ClusterPortId > &port_id_map, const vtr::vector_map< ClusterNetId, ClusterNetId > &net_id_map) override
Definition: clustered_netlist.cpp:254
t_logical_block_type_ptr block_type(const ClusterBlockId id) const
Returns the type of CLB (Logic block, RAM, DSP, etc.)
Definition: clustered_netlist.cpp:25
bool validate_port_sizes_impl(size_t num_ports) const override
Definition: clustered_netlist.cpp:291
bool net_is_ignored(const ClusterNetId id) const
Returns whether the net is ignored i.e. not routed.
Definition: clustered_netlist.cpp:97
vtr::vector_map< ClusterBlockId, std::vector< ClusterPinId > > block_logical_pins_
Definition: clustered_netlist.h:279
bool block_contains_primary_input(const ClusterBlockId blk) const
Definition: clustered_netlist.cpp:58
vtr::vector_map< ClusterNetId, bool > net_is_global_
Definition: clustered_netlist.h:288
vtr::StrongId< cluster_block_id_tag > ClusterBlockId
A unique identifier for a block/primitive in the atom netlist.
Definition: clustered_netlist_fwd.h:17
vtr::vector_map< ClusterPinId, int > pin_logical_index_
Definition: clustered_netlist.h:282
unsigned BitIndex
Definition: atom_netlist_fwd.h:41
ClusterBlockId create_block(const char *name, t_pb *pb, t_logical_block_type_ptr type)
Create or return an existing block in the netlist.
Definition: clustered_netlist.cpp:114
void rebuild_net_refs_impl(const vtr::vector_map< ClusterPinId, ClusterPinId > &pin_id_map) override
Definition: clustered_netlist.cpp:259
vtr::StrongId< cluster_pin_id_tag > ClusterPinId
A unique identifier for a pin in the atom netlist.
Definition: clustered_netlist_fwd.h:29
void clean_pins_impl(const vtr::vector_map< ClusterPinId, ClusterPinId > &pin_id_map) override
Definition: clustered_netlist.cpp:227
t_pb * block_pb(const ClusterBlockId id) const
Returns the physical block.
Definition: clustered_netlist.cpp:19
ClusterNetId block_net(const ClusterBlockId blk_id, const int pin_index) const
Returns the net of the block attached to the specific pin index.
Definition: clustered_netlist.cpp:31