3535#include < unordered_map>
3636#include < limits>
3737#include < numeric>
38+ #include < set>
39+ #include < unordered_set>
3840
3941#include " vtr_ndmatrix.h"
4042#include " vtr_hash.h"
@@ -454,6 +456,28 @@ struct t_class_range {
454456 int total_num () const {
455457 return high - low + 1 ;
456458 }
459+
460+ t_class_range () = default ;
461+
462+ t_class_range (int low_class_num, int high_class_num)
463+ : low(low_class_num)
464+ , high(high_class_num) {}
465+ };
466+
467+ // Struct to hold the pin ranges for a specific sub block
468+ struct t_pin_range {
469+ int low = 0 ;
470+ int high = 0 ;
471+ // Returns the total number of pins
472+ int total_num () const {
473+ return high - low + 1 ;
474+ }
475+
476+ t_pin_range () = default ;
477+
478+ t_pin_range (int low_class_num, int high_class_num)
479+ : low(low_class_num)
480+ , high(high_class_num) {}
457481};
458482
459483enum e_power_wire_type {
@@ -617,14 +641,21 @@ struct t_physical_tile_type {
617641
618642 std::vector<t_class> class_inf; /* [0..num_class-1] */
619643
620- std::unordered_map<int , t_class> internal_class_inf;
644+ // Primitive class is refered to a classes that are in the primitive blocks. These classes are
645+ // used during flat-routing to route the nets.
646+ // The starting number of primitive classes
647+ int primitive_class_starting_idx = -1 ;
648+ std::unordered_map<int , t_class> primitive_class_inf; // [primitive_class_num] -> primitive_class_inf
621649
622- std::vector<int > pin_width_offset; // [0..num_pins-1]
623- std::vector<int > pin_height_offset; // [0..num_pins-1]
624- std::vector<int > pin_class; // [0..num_pins-1]
625- std::unordered_map<int , int > internal_pin_class;
626- std::vector<bool > is_ignored_pin; // [0..num_pins-1]
627- std::vector<bool > is_pin_global; // [0..num_pins-1]
650+ std::vector<int > pin_width_offset; // [0..num_pins-1]
651+ std::vector<int > pin_height_offset; // [0..num_pins-1]
652+ std::vector<int > pin_class; // [0..num_pins-1]
653+ std::unordered_map<int , int > primitive_pin_class; // [primitive_pin_num] -> primitive_class_num
654+ std::vector<bool > is_ignored_pin; // [0..num_pins-1]
655+ std::vector<bool > is_pin_global; // [0..num_pins-1]
656+
657+ std::unordered_map<int , std::unordered_map<t_logical_block_type_ptr, t_pb_graph_pin*>> on_tile_pin_num_to_pb_pin; // [root_pin_physical_num][logical_block] -> t_pb_graph_pin*
658+ std::unordered_map<int , t_pb_graph_pin*> pin_num_to_pb_pin; // [intra_tile_pin_physical_num] -> t_pb_graph_pin
628659
629660 std::vector<t_fc_specification> fc_specs;
630661
@@ -730,10 +761,10 @@ struct t_sub_tile {
730761 // />E.g.: capacity can range from 4 to 7, meaning that there are four placeable sub tiles
731762 // /> at a physical location, and compatible netlist blocks can be placed at sub_tile
732763 // /> indices ranging from 4 to 7.
733- t_class_range class_range;
764+ t_class_range class_range; // Range of the root-level classes
734765
735- std::vector<std::unordered_map<t_logical_block_type_ptr, int >> starting_internal_class_idx;
736- std::vector<std::unordered_map<t_logical_block_type_ptr, int >> starting_internal_pin_idx;
766+ std::vector<std::unordered_map<t_logical_block_type_ptr, t_class_range >> primitive_class_range; // [rel_cap][logical_block_ptr] -> class_range
767+ std::vector<std::unordered_map<t_logical_block_type_ptr, t_pin_range >> intra_pin_range; // [rel_cap][logical_block_ptr] -> intra_pin_range
737768
738769 int num_phy_pins = 0 ;
739770
@@ -832,7 +863,7 @@ struct t_physical_tile_port {
832863 * the logical block. The key of this map is the logical number of the pin, and the value is a pointer to the
833864 * corresponding pb_graph_pin
834865 *
835- * pb_pin_to_class_logical_num_mapping : Maps each pin to its corresponding class's logical number. To retrieve the actual class, use this number as an
866+ * primitive_pb_pin_to_logical_class_num_mapping : Maps each pin to its corresponding class's logical number. To retrieve the actual class, use this number as an
836867 * index to logical_class_inf.
837868 *
838869 * logical_class_inf: Contains all the classes inside the logical block. The index of each class is the logical number associate with the class.
@@ -859,9 +890,10 @@ struct t_logical_block_type {
859890 std::vector<t_physical_tile_type_ptr> equivalent_tiles; // />List of physical tiles at which one could
860891 // />place this type of netlist block.
861892
862- std::unordered_map<int , const t_pb_graph_pin*> pin_logical_num_to_pb_pin_mapping; /* pin_logical_num_to_pb_pin_mapping[pin logical number] -> pb_graph_pin ptr} */
863- std::unordered_map<const t_pb_graph_pin*, int > pb_pin_to_class_logical_num_mapping; /* pb_pin_to_class_logical_num_mapping[pb_graph_pin ptr] -> class logical number */
864- std::vector<t_class> logical_class_inf; /* logical_class_inf[class_logical_number] -> class */
893+ std::unordered_map<int , t_pb_graph_pin*> pin_logical_num_to_pb_pin_mapping; /* pin_logical_num_to_pb_pin_mapping[pin logical number] -> pb_graph_pin ptr} */
894+ std::unordered_map<const t_pb_graph_pin*, int > primitive_pb_pin_to_logical_class_num_mapping; /* primitive_pb_pin_to_logical_class_num_mapping[pb_graph_pin ptr] -> class logical number */
895+ std::vector<t_class> primitive_logical_class_inf; /* primitive_logical_class_inf[class_logical_number] -> class */
896+ std::unordered_map<const t_pb_graph_node*, t_class_range> pb_graph_node_class_range;
865897
866898 // Is this t_logical_block_type empty?
867899 bool is_empty () const ;
@@ -944,6 +976,8 @@ struct t_pb_type {
944976 t_pin_to_pin_annotation* annotations = nullptr ; /* [0..num_annotations-1] */
945977 int num_annotations = 0 ;
946978
979+ int index_in_logical_block = 0 ; /* assign a unique id to each pb_type in a logical block */
980+
947981 /* Power related members */
948982 t_pb_type_power* pb_type_power = nullptr ;
949983
@@ -1185,6 +1219,8 @@ class t_pb_graph_node {
11851219 * */
11861220 std::vector<int > illegal_modes;
11871221
1222+ t_pin_range pin_num_range;
1223+
11881224 t_pb_graph_pin** input_pins; /* [0..num_input_ports-1] [0..num_port_pins-1]*/
11891225 t_pb_graph_pin** output_pins; /* [0..num_output_ports-1] [0..num_port_pins-1]*/
11901226 t_pb_graph_pin** clock_pins; /* [0..num_clock_ports-1] [0..num_port_pins-1]*/
@@ -1260,6 +1296,9 @@ class t_pb_graph_pin {
12601296 int pin_number = 0 ;
12611297 std::vector<t_pb_graph_edge*> input_edges; /* [0..num_input_edges] */
12621298 int num_input_edges = 0 ;
1299+ // This map is initialized only if flat_routing is enabled
1300+ std::unordered_map<const t_pb_graph_pin*, int > sink_pin_edge_idx_map; /* [t_pb_graph_pin*] -> edge_idx - This is the index of the corresponding edge stored in output_edges vector */
1301+
12631302 std::vector<t_pb_graph_edge*> output_edges; /* [0..num_output_edges] */
12641303 int num_output_edges = 0 ;
12651304
@@ -1277,6 +1316,13 @@ class t_pb_graph_pin {
12771316 float tco_max = std::numeric_limits<float >::quiet_NaN(); /* For sequential logic elements the maximum clock to output time */
12781317 t_pb_graph_pin* associated_clock_pin = nullptr ; /* For sequentail elements, the associated clock */
12791318
1319+ /* This member is used when flat-routing and has_choking_spot are enabled.
1320+ * It is used to identify choke points.
1321+ * This is only valid for IPINs, and it only contain the pins that are reachable to the pin by a forwarding path.
1322+ * It doesn't take into account feed-back connection.
1323+ * */
1324+ std::unordered_set<int > connected_sinks_ptc; /* ptc numbers of sinks which are directly or indirectly connected to this pin */
1325+
12801326 /* combinational timing information */
12811327 int num_pin_timing = 0 ; /* Number of ipin to opin timing edges*/
12821328 std::vector<t_pb_graph_pin*> pin_timing; /* timing edge sink pins [0..num_pin_timing-1]*/
@@ -1360,6 +1406,8 @@ class t_pb_graph_edge {
13601406 int * pack_pattern_indices;
13611407 bool infer_pattern;
13621408
1409+ int switch_type_idx = OPEN; /* architecture switch id of the edge - used when flat_routing is enabled */
1410+
13631411 // class member functions
13641412 public:
13651413 // Returns true is this edge is annotated with the given pattern_index
@@ -1573,7 +1621,7 @@ struct t_arch_switch_inf {
15731621 public:
15741622 static constexpr int UNDEFINED_FANIN = -1 ;
15751623
1576- char * name = nullptr ;
1624+ std::string name;
15771625 float R = 0 .;
15781626 float Cin = 0 .;
15791627 float Cout = 0 .;
@@ -1584,6 +1632,8 @@ struct t_arch_switch_inf {
15841632 e_power_buffer_type power_buffer_type = POWER_BUFFER_TYPE_AUTO;
15851633 float power_buffer_size = 0 .;
15861634
1635+ bool intra_tile = false ;
1636+
15871637 public:
15881638 // Returns the type of switch
15891639 SwitchType type () const ;
@@ -1644,7 +1694,7 @@ struct t_rr_switch_inf {
16441694 float Tdel = 0 .;
16451695 float mux_trans_size = 0 .;
16461696 float buf_size = 0 .;
1647- const char * name = nullptr ;
1697+ std::string name;
16481698 e_power_buffer_type power_buffer_type = POWER_BUFFER_TYPE_UNDEFINED;
16491699 float power_buffer_size = 0 .;
16501700
0 commit comments