Verilog to Routing - VPR
vpr_context.h
Go to the documentation of this file.
1 #ifndef VPR_CONTEXT_H
2 #define VPR_CONTEXT_H
3 #include <unordered_map>
4 #include <memory>
5 #include <vector>
6 
7 #include "vpr_types.h"
8 #include "vtr_ndmatrix.h"
9 #include "vtr_vector.h"
10 #include "atom_netlist.h"
11 #include "clustered_netlist.h"
12 #include "rr_graph_storage.h"
13 #include "rr_node.h"
14 #include "rr_rc_data.h"
15 #include "tatum/TimingGraph.hpp"
16 #include "tatum/TimingConstraints.hpp"
17 #include "power.h"
18 #include "power_components.h"
19 #include "device_grid.h"
20 #include "clock_network_builders.h"
21 #include "clock_connection_builders.h"
22 #include "route_traceback.h"
23 #include "router_lookahead.h"
24 #include "place_macro.h"
25 #include "compressed_grid.h"
26 #include "metadata_storage.h"
27 
37 struct Context {
38  //Contexts are non-copyable
39  Context() = default;
40  Context(Context&) = delete;
41  Context& operator=(Context&) = delete;
42  virtual ~Context() = default;
43 };
44 
51 struct AtomContext : public Context {
52  /********************************************************************
53  * Atom Netlist
54  ********************************************************************/
55 
58 
61 };
62 
69 struct TimingContext : public Context {
70  /********************************************************************
71  * Timing
72  ********************************************************************/
73 
79  std::shared_ptr<tatum::TimingGraph> graph;
80 
86  std::shared_ptr<tatum::TimingConstraints> constraints;
87 
89 };
90 
91 namespace std {
92 template<>
93 struct hash<std::tuple<int, int, short>> {
94  std::size_t operator()(const std::tuple<int, int, short>& ok) const noexcept {
95  std::size_t seed = std::hash<int>{}(std::get<0>(ok));
96  vtr::hash_combine(seed, std::get<1>(ok));
97  vtr::hash_combine(seed, std::get<2>(ok));
98  return seed;
99  }
100 };
101 } // namespace std
102 
108 struct DeviceContext : public Context {
109  /*********************************************************************
110  * Physical FPGA architecture
111  *********************************************************************/
112 
113  /*
114  * x and y dimensions of the FPGA itself
115  */
116 
119  /*
120  * Empty types
121  */
122 
123  t_physical_tile_type_ptr EMPTY_PHYSICAL_TILE_TYPE;
124  t_logical_block_type_ptr EMPTY_LOGICAL_BLOCK_TYPE;
125 
126  /*
127  * block_types are blocks that can be moved by the placer
128  * such as: I/Os, CLBs, memories, multipliers, etc
129  * Different types of physical block are contained in type descriptors
130  */
131 
132  std::vector<t_physical_tile_type> physical_tile_types;
133  std::vector<t_logical_block_type> logical_block_types;
134 
140 
141  /*******************************************************************
142  * Routing related
143  ********************************************************************/
144 
147 
148  /*
149  * Structures to define the routing architecture of the FPGA.
150  */
151 
152  t_rr_graph_storage rr_nodes; // autogenerated in build_rr_graph
153 
154  std::vector<t_rr_indexed_data> rr_indexed_data; // [0 .. num_rr_indexed_data-1]
155 
157  std::vector<t_rr_rc_data> rr_rc_data;
158 
160  std::vector<std::vector<int>> rr_non_config_node_sets;
161 
163  std::unordered_map<int, int> rr_node_to_non_config_node_set;
164 
166  t_rr_node_indices rr_node_indices; // [0..NUM_RR_TYPES-1][0..grid.width()-1][0..grid.width()-1][0..size-1]
167 
168  std::vector<t_rr_switch_inf> rr_switch_inf; // autogenerated in build_rr_graph based on switch fan-in. [0..(num_rr_switches-1)]
169 
171  std::vector<t_segment_inf> rr_segments;
172 
174  t_arch_switch_inf* arch_switch_inf; // [0..(num_arch_switches-1)]
175 
176  /*
177  * Clock Networks
178  */
179 
180  std::vector<std::unique_ptr<ClockNetwork>> clock_networks;
181  std::vector<std::unique_ptr<ClockConnection>> clock_connections;
182 
191 
210 
219  std::vector<std::map<int, int>> switch_fanin_remap;
220 
221  /*******************************************************************
222  * Architecture
223  ********************************************************************/
224  const t_arch* arch;
225 
226  /*******************************************************************
227  * Clock Network
228  ********************************************************************/
229  t_clock_arch* clock_arch;
230 
237 };
238 
245 struct PowerContext : public Context {
246  /*******************************************************************
247  * Power
248  ********************************************************************/
249  t_solution_inf solution_inf;
250  t_power_output* output;
251  t_power_commonly_used* commonly_used;
252  t_power_tech* tech;
253  t_power_arch* arch;
254  vtr::vector<ClusterNetId, t_net_power> clb_net_power;
255 
257  std::unordered_map<AtomNetId, t_net_power> atom_net_power;
258  t_power_components by_component;
259 };
260 
267 struct ClusteringContext : public Context {
268  /********************************************************************
269  * CLB Netlist
270  ********************************************************************/
271 
274 };
275 
282 struct PlacementContext : public Context {
284  vtr::vector_map<ClusterBlockId, t_block_loc> block_locs;
285 
287  vtr::vector_map<ClusterPinId, int> physical_pins;
288 
290  vtr::Matrix<t_grid_blocks> grid_blocks; //[0..device_ctx.grid.width()-1][0..device_ctx.grid.width()-1]
291 
293  std::vector<t_pl_macro> pl_macros;
294 
301  t_compressed_block_grids compressed_block_grids;
302 
308  std::string placement_id;
309 };
310 
317 struct RoutingContext : public Context {
318  /* [0..num_nets-1] of linked list start pointers. Defines the routing. */
319  vtr::vector<ClusterNetId, t_traceback> trace;
320  vtr::vector<ClusterNetId, std::unordered_set<int>> trace_nodes;
321 
322  vtr::vector<ClusterNetId, std::vector<int>> net_rr_terminals; /* [0..num_nets-1][0..num_pins-1] */
323  vtr::vector<ClusterNetId, uint8_t> is_clock_net; /* [0..num_nets-1] */
324 
325  vtr::vector<ClusterBlockId, std::vector<int>> rr_blk_source; /* [0..num_blocks-1][0..num_class-1] */
326 
327  std::vector<t_rr_node_route_inf> rr_node_route_inf; /* [0..device_ctx.num_rr_nodes-1] */
328 
338  vtr::dynamic_bitset<> non_configurable_bitset; /*[0...device_ctx.num_rr_nodes] */
339 
342 
344  vtr::vector<ClusterNetId, t_bb> route_bb; /* [0..cluster_ctx.clb_nlist.nets().size()-1]*/
345 
346  t_clb_opins_used clb_opins_used_locally; //[0..cluster_ctx.clb_nlist.blocks().size()-1][0..num_class-1]
347 
353  std::string routing_id;
354 
360  vtr::Cache<std::tuple<e_router_lookahead, std::string, std::vector<t_segment_inf>>,
361  RouterLookahead>
363 };
364 
412 class VprContext : public Context {
413  public:
414  const AtomContext& atom() const { return atom_; }
415  AtomContext& mutable_atom() { return atom_; }
416 
417  const DeviceContext& device() const { return device_; }
418  DeviceContext& mutable_device() { return device_; }
419 
420  const TimingContext& timing() const { return timing_; }
421  TimingContext& mutable_timing() { return timing_; }
422 
423  const PowerContext& power() const { return power_; }
424  PowerContext& mutable_power() { return power_; }
425 
426  const ClusteringContext& clustering() const { return clustering_; }
427  ClusteringContext& mutable_clustering() { return clustering_; }
428 
429  const PlacementContext& placement() const { return placement_; }
430  PlacementContext& mutable_placement() { return placement_; }
431 
432  const RoutingContext& routing() const { return routing_; }
433  RoutingContext& mutable_routing() { return routing_; }
434 
435  private:
437 
439 
442 
446 };
447 
448 #endif
Context()=default
Information about the current status of a particular net as pertains to routing.
Definition: vpr_types.h:1367
A Context is collection of state relating to a particular part of VPR.
Definition: vpr_context.h:37
std::vector< t_rr_switch_inf > rr_switch_inf
Definition: vpr_context.h:168
vtr::vector< ClusterNetId, std::unordered_set< int > > trace_nodes
Definition: vpr_context.h:320
std::shared_ptr< tatum::TimingGraph > graph
The current timing graph.
Definition: vpr_context.h:79
std::shared_ptr< tatum::TimingConstraints > constraints
The current timing constraints, as loaded from an SDC file (or set by default).
Definition: vpr_context.h:86
ClusteringContext clustering_
Definition: vpr_context.h:443
std::vector< t_pl_macro > pl_macros
The pl_macros array stores all the placement macros (usually carry chains).
Definition: vpr_context.h:293
const DeviceContext & device() const
Definition: vpr_context.h:417
std::size_t operator()(const std::tuple< int, int, short > &ok) const noexcept
Definition: vpr_context.h:94
std::vector< std::map< int, int > > switch_fanin_remap
switch_fanin_remap is only used for printing out switch fanin stats (the -switch_stats option) ...
Definition: vpr_context.h:219
vtr::vector< ClusterNetId, uint8_t > is_clock_net
Definition: vpr_context.h:323
t_power_components by_component
Definition: vpr_context.h:258
t_logical_block_type_ptr EMPTY_LOGICAL_BLOCK_TYPE
Definition: vpr_context.h:124
std::string read_rr_graph_filename
Name of rrgraph file read (if any).
Definition: vpr_context.h:236
std::vector< std::unique_ptr< ClockConnection > > clock_connections
Definition: vpr_context.h:181
TimingContext timing_
Definition: vpr_context.h:440
vtr::Matrix< t_grid_blocks > grid_blocks
Clustered block associated with each grid location (i.e. inverse of block_locs)
Definition: vpr_context.h:290
vtr::vector< ClusterNetId, t_bb > route_bb
Limits area within which each net must be routed.
Definition: vpr_context.h:344
Definition: vpr_context.h:91
vtr::Cache< std::tuple< e_router_lookahead, std::string, std::vector< t_segment_inf > >, RouterLookahead > cached_router_lookahead_
Cache of router lookahead object.
Definition: vpr_context.h:362
vtr::dynamic_bitset non_configurable_bitset
Information about whether a node is part of a non-configurable set.
Definition: vpr_context.h:338
std::string routing_id
SHA256 digest of the .route file.
Definition: vpr_context.h:353
This is a core file that defines the major data types used by VPR.
Definition: device_grid.h:17
MetadataStorage< int > rr_node_metadata
Attributes for each rr_node.
Definition: vpr_context.h:198
vtr::vector< ClusterNetId, std::vector< int > > net_rr_terminals
Definition: vpr_context.h:322
t_clock_arch * clock_arch
Definition: vpr_context.h:229
t_solution_inf solution_inf
Definition: vpr_context.h:249
std::vector< std::vector< int > > rr_non_config_node_sets
Sets of non-configurably connected nodes.
Definition: vpr_context.h:160
t_power_commonly_used * commonly_used
Definition: vpr_context.h:251
std::unordered_map< AtomNetId, t_net_power > atom_net_power
Atom net power info.
Definition: vpr_context.h:257
t_clb_opins_used clb_opins_used_locally
Definition: vpr_context.h:346
vtr::vector< ClusterNetId, t_traceback > trace
Definition: vpr_context.h:319
std::string placement_id
SHA256 digest of the .place file.
Definition: vpr_context.h:308
const PowerContext & power() const
Definition: vpr_context.h:423
std::vector< t_segment_inf > rr_segments
Wire segment types in RR graph.
Definition: vpr_context.h:171
The AtomLookup class describes the mapping between components in the AtomNetlist and other netlists/e...
Definition: atom_lookup.h:20
AtomNetlist nlist
Atom netlist.
Definition: vpr_context.h:57
This file defines the ClusteredNetlist class in the ClusteredContext created during pre-placement sta...
bool has_multiple_equivalent_tiles
Boolean that indicates whether the architecture implements an N:M physical tiles to logical blocks ma...
Definition: vpr_context.h:139
Definition: vpr_types.h:999
Definition: atom_netlist.h:80
t_power_output * output
Definition: vpr_context.h:250
t_rr_graph_storage rr_nodes
Definition: vpr_context.h:152
std::vector< t_rr_node_route_inf > rr_node_route_inf
Definition: vpr_context.h:327
Channel width data.
Definition: vpr_types.h:1440
TimingContext & mutable_timing()
Definition: vpr_context.h:421
Context & operator=(Context &)=delete
const t_arch * arch
Definition: vpr_context.h:224
RoutingContext & mutable_routing()
Definition: vpr_context.h:433
This object encapsulates VPR&#39;s state.
Definition: vpr_context.h:412
vtr::vector_map< ClusterBlockId, t_block_loc > block_locs
Clustered block placement locations.
Definition: vpr_context.h:284
vtr::vector< ClusterBlockId, std::vector< int > > rr_blk_source
Definition: vpr_context.h:325
t_physical_tile_type_ptr EMPTY_PHYSICAL_TILE_TYPE
Definition: vpr_context.h:123
PlacementContext & mutable_placement()
Definition: vpr_context.h:430
vtr::vector< ClusterBlockId, std::vector< std::vector< int > > > t_clb_opins_used
Definition: vpr_types.h:1506
std::vector< std::unique_ptr< ClockNetwork > > clock_networks
Definition: vpr_context.h:180
const AtomContext & atom() const
Definition: vpr_context.h:414
PowerContext power_
Definition: vpr_context.h:441
ClusteringContext & mutable_clustering()
Definition: vpr_context.h:427
t_power_arch * arch
Definition: vpr_context.h:253
std::unordered_map< int, int > rr_node_to_non_config_node_set
Reverse look-up from RR node to non-configurably connected node set (index into rr_nonconf_node_sets)...
Definition: vpr_context.h:163
State relating the device.
Definition: vpr_context.h:108
DeviceContext device_
Definition: vpr_context.h:436
vtr::vector_map< ClusterPinId, int > physical_pins
Clustered pin placement mapping with physical pin.
Definition: vpr_context.h:287
Definition: clustered_netlist.h:120
virtual ~Context()=default
ClusteredNetlist clb_nlist
New netlist class derived from Netlist.
Definition: vpr_context.h:273
State relating to clustering.
Definition: vpr_context.h:267
RoutingContext routing_
Definition: vpr_context.h:445
PlacementContext placement_
Definition: vpr_context.h:444
std::vector< t_physical_tile_type > physical_tile_types
Definition: vpr_context.h:132
vtr::vector< ClusterNetId, t_net_power > clb_net_power
Definition: vpr_context.h:254
t_timing_analysis_profile_info stats
Definition: vpr_context.h:88
int num_arch_switches
Definition: vpr_context.h:173
const PlacementContext & placement() const
Definition: vpr_context.h:429
AtomContext atom_
Definition: vpr_context.h:438
State relating to the atom-level netlist.
Definition: vpr_context.h:51
DeviceGrid grid
Definition: vpr_context.h:117
DeviceContext & mutable_device()
Definition: vpr_context.h:418
PowerContext & mutable_power()
Definition: vpr_context.h:424
State relating to power analysis.
Definition: vpr_context.h:245
t_arch_switch_inf * arch_switch_inf
Definition: vpr_context.h:174
State relating to placement.
Definition: vpr_context.h:282
const ClusteringContext & clustering() const
Definition: vpr_context.h:426
const RoutingContext & routing() const
Definition: vpr_context.h:432
t_power_tech * tech
Definition: vpr_context.h:252
t_compressed_block_grids compressed_block_grids
Compressed grid space for each block type.
Definition: vpr_context.h:301
std::array< vtr::NdMatrix< std::vector< int >, 3 >, NUM_RR_TYPES > t_rr_node_indices
Definition: vpr_types.h:1303
AtomContext & mutable_atom()
Definition: vpr_context.h:415
int virtual_clock_network_root_idx
rr_node idx that connects to the input of all clock network wires
Definition: vpr_context.h:190
AtomLookup lookup
Mappings to/from the Atom Netlist to physically described .blif models.
Definition: vpr_context.h:60
std::vector< t_rr_rc_data > rr_rc_data
Fly-weighted Resistance/Capacitance data for RR Nodes.
Definition: vpr_context.h:157
State relating to routing.
Definition: vpr_context.h:317
t_rr_node_indices rr_node_indices
The indicies of rr nodes of a given type at a specific x,y grid location.
Definition: vpr_context.h:166
std::vector< t_logical_block_type > logical_block_types
Definition: vpr_context.h:133
const TimingContext & timing() const
Definition: vpr_context.h:420
t_chan_width chan_width
chan_width is for x|y-directed channels; i.e. between rows
Definition: vpr_context.h:146
t_net_routing_status net_status
Information about current routing status of each net.
Definition: vpr_context.h:341
std::vector< t_rr_indexed_data > rr_indexed_data
Definition: vpr_context.h:154
This file defines the AtomNetlist class used to store and manipulate the primitive (or atom) netlist...
MetadataStorage< std::tuple< int, int, short > > rr_edge_metadata
Attributes for each rr_edge.
Definition: vpr_context.h:209
State relating to timing.
Definition: vpr_context.h:69