@@ -45,17 +45,16 @@ void add_inter_die_3d_edges(RRGraphBuilder& rr_graph_builder,
4545}
4646
4747void build_inter_die_3d_rr_chan (RRGraphBuilder& rr_graph_builder,
48- const int x_coord,
49- const int y_coord,
48+ int x_coord,
49+ int y_coord,
5050 const std::vector<t_bottleneck_link>& interdie_3d_links,
51- const int const_index_offset) {
51+ int const_index_offset) {
5252 auto & mutable_device_ctx = g_vpr_ctx.mutable_device ();
53- const size_t num_layers = g_vpr_ctx.device ().grid .get_num_layers ();
5453
5554 // 3D connections within the switch blocks use some CHANZ nodes to allow a single 3D connection to be driven
5655 // by multiple tracks in the source layer, and drives multiple tracks in the destination layer.
5756 // These nodes have already been added to RRGraph builder, this function will go through all added nodes
58- // with specific location (layer, x_coord, y_coord) and sets their attributes.
57+ // with specific location (x_coord, y_coord) and sets their attributes.
5958
6059 // These nodes have the following attributes:
6160 // 1) type: CHANZ
@@ -66,8 +65,12 @@ void build_inter_die_3d_rr_chan(RRGraphBuilder& rr_graph_builder,
6665 for (int track_num = 0 ; /* no condition*/ ; track_num++) {
6766 // Try to find a node with the current track_num
6867
69- RRNodeId node = rr_graph_builder.node_lookup ().find_node (0 , x_coord, y_coord, e_rr_type::CHANZ, track_num);
70- for (size_t layer = 1 ; layer < num_layers; layer++) {
68+ const t_bottleneck_link& link = interdie_3d_links[track_num];
69+ const char layer_low = std::min (link.gather_loc .layer_num , link.scatter_loc .layer_num );
70+ const char layer_high = std::max (link.gather_loc .layer_num , link.scatter_loc .layer_num );
71+
72+ RRNodeId node = rr_graph_builder.node_lookup ().find_node (layer_low, x_coord, y_coord, e_rr_type::CHANZ, track_num);
73+ for (size_t layer = layer_low; layer <= layer_high; layer++) {
7174 VTR_ASSERT (node == rr_graph_builder.node_lookup ().find_node (layer, x_coord, y_coord, e_rr_type::CHANZ, track_num));
7275 }
7376
@@ -77,9 +80,7 @@ void build_inter_die_3d_rr_chan(RRGraphBuilder& rr_graph_builder,
7780 break ;
7881 }
7982
80- // TODO: layer numbers should be extracted from link info
81- rr_graph_builder.set_node_layer (node, 0 , 1 );
82-
83+ rr_graph_builder.set_node_layer (node, layer_low, layer_high);
8384 rr_graph_builder.set_node_coordinates (node, x_coord, y_coord, x_coord, y_coord);
8485 // TODO: the index doesn't make any sense. We need to an RRIndexedDataId for CHANZ nodes
8586 rr_graph_builder.set_node_cost_index (node, RRIndexedDataId (const_index_offset));
@@ -90,10 +91,10 @@ void build_inter_die_3d_rr_chan(RRGraphBuilder& rr_graph_builder,
9091
9192 rr_graph_builder.set_node_type (node, e_rr_type::CHANZ);
9293 rr_graph_builder.set_node_track_num (node, track_num);
93- if (interdie_3d_links[track_num] .scatter_loc .layer_num > interdie_3d_links[track_num] .gather_loc .layer_num ) {
94+ if (link .scatter_loc .layer_num > link .gather_loc .layer_num ) {
9495 rr_graph_builder.set_node_direction (node, Direction::INC);
9596 } else {
96- VTR_ASSERT_SAFE (interdie_3d_links[track_num] .scatter_loc .layer_num < interdie_3d_links[track_num] .gather_loc .layer_num );
97+ VTR_ASSERT_SAFE (link .scatter_loc .layer_num < link .gather_loc .layer_num );
9798 rr_graph_builder.set_node_direction (node, Direction::DEC);
9899 }
99100 }
0 commit comments