@@ -100,15 +100,122 @@ void build_inter_die_3d_rr_chan(RRGraphBuilder& rr_graph_builder,
100100 }
101101}
102102
103- void add_edges_opin_chanz (const RRGraphView& rr_graph,
104- int layer,
105- int x,
106- int y,
107- const std::vector<vtr::Matrix<int >>& Fc_out,
108- const t_unified_to_parallel_seg_index& seg_index_map,
109- int num_seg_types,
110- t_rr_edge_info_set& rr_edges_to_create,
111- const std::vector<t_bottleneck_link>& interdie_3d_links) {
103+ void add_edges_opin_chanz_per_side (const RRGraphView& rr_graph,
104+ int layer,
105+ int x,
106+ int y,
107+ e_side side,
108+ const std::vector<vtr::Matrix<int >>& Fc_out,
109+ const t_unified_to_parallel_seg_index& seg_index_map,
110+ int num_seg_types,
111+ vtr::NdMatrix<int , 3 >& Fc_zofs,
112+ t_rr_edge_info_set& rr_edges_to_create,
113+ const vtr::NdMatrix<std::vector<t_bottleneck_link>, 2 >& interdie_3d_links) {
114+ const RRSpatialLookup& node_lookup = rr_graph.node_lookup ();
115+ const DeviceGrid& grid = g_vpr_ctx.device ().grid ;
116+
117+ t_physical_tile_type_ptr type = grid.get_physical_type ({x, y, layer});
118+
119+ std::vector<RRNodeId> opin_nodes = node_lookup.find_pin_nodes_at_side (layer, x, y, e_rr_type::OPIN, side);
120+
121+ t_physical_tile_loc sb_loc0, sb_loc1;
122+ switch (side) {
123+ case TOP:
124+ sb_loc0 = {x, y, layer};
125+ sb_loc1 = {x - 1 , y, layer};
126+ break ;
127+
128+ case BOTTOM:
129+ sb_loc0 = {x, y - 1 , layer};
130+ sb_loc1 = {x - 1 , y - 1 , layer};
131+ break ;
132+
133+ case RIGHT:
134+ sb_loc0 = {x, y, layer};
135+ sb_loc1 = {x , y - 1 , layer};
136+ break ;
137+
138+ case LEFT:
139+ sb_loc0 = {x - 1 , y, layer};
140+ sb_loc1 = {x - 1 , y - 1 , layer};
141+ break ;
142+
143+ default :
144+ VTR_ASSERT_SAFE (false );
145+ }
146+
147+ const int grid_width = grid.width ();
148+ const int grid_height = grid.height ();
149+
150+ sb_loc0.x = std::clamp (sb_loc0.x , 0 , grid_width - 1 );
151+ sb_loc0.y = std::clamp (sb_loc0.y , 0 , grid_height - 1 );
152+
153+ sb_loc1.x = std::clamp (sb_loc1.x , 0 , grid_width - 1 );
154+ sb_loc1.y = std::clamp (sb_loc1.y , 0 , grid_height - 1 );
155+
156+ std::vector<std::pair<RRNodeId, short >> selected_chanz_nodes0;
157+ std::vector<std::pair<RRNodeId, short >> selected_chanz_nodes1;
158+
159+ for (int iseg = 0 ; iseg < num_seg_types; iseg++) {
160+ int seg_index = get_parallel_seg_index (iseg, seg_index_map, e_parallel_axis::Z_AXIS);
161+ if (seg_index < 0 ) {
162+ continue ;
163+ }
164+
165+ selected_chanz_nodes0.clear ();
166+ for (size_t track_num = 0 ; track_num < interdie_3d_links[sb_loc0.x ][sb_loc0.y ].size (); track_num++) {
167+ const t_bottleneck_link& bottleneck_link = interdie_3d_links[sb_loc0.x ][sb_loc0.y ][track_num];
168+ if (bottleneck_link.parallel_segment_index == seg_index && bottleneck_link.gather_loc .layer_num == layer) {
169+ RRNodeId node_id = node_lookup.find_node (sb_loc0.layer_num , sb_loc0.x , sb_loc0.y , e_rr_type::CHANZ, track_num);
170+ selected_chanz_nodes0.push_back ({node_id, bottleneck_link.arch_wire_switch });
171+ }
172+ }
173+
174+ selected_chanz_nodes1.clear ();
175+ for (size_t track_num = 0 ; track_num < interdie_3d_links[sb_loc1.x ][sb_loc1.y ].size (); track_num++) {
176+ const t_bottleneck_link& bottleneck_link = interdie_3d_links[sb_loc1.x ][sb_loc1.y ][track_num];
177+ if (bottleneck_link.parallel_segment_index == seg_index && bottleneck_link.gather_loc .layer_num == layer) {
178+ RRNodeId node_id = node_lookup.find_node (sb_loc1.layer_num , sb_loc1.x , sb_loc1.y , e_rr_type::CHANZ, track_num);
179+ selected_chanz_nodes1.push_back ({node_id, bottleneck_link.arch_wire_switch });
180+ }
181+ }
182+
183+ for (RRNodeId opin_node_id : opin_nodes) {
184+ int pin_number = rr_graph.node_pin_num (opin_node_id);
185+ int fc = Fc_out[type->index ][pin_number][iseg];
186+
187+ for (int i = 0 ; i < fc; i++) {
188+
189+ RRNodeId chanz_node_id;
190+ short switch_id;
191+ if (Fc_zofs[sb_loc0.x ][sb_loc0.y ][seg_index] < Fc_zofs[sb_loc1.x ][sb_loc1.y ][seg_index]) {
192+ int chanz_idx = Fc_zofs[sb_loc0.x ][sb_loc0.y ][seg_index];
193+ chanz_node_id = selected_chanz_nodes0[chanz_idx % selected_chanz_nodes0.size ()].first ;
194+ switch_id = selected_chanz_nodes0[chanz_idx % selected_chanz_nodes0.size ()].second ;
195+ Fc_zofs[sb_loc0.x ][sb_loc0.y ][seg_index]++;
196+ } else {
197+ int chanz_idx = Fc_zofs[sb_loc1.x ][sb_loc1.y ][seg_index];
198+ chanz_node_id = selected_chanz_nodes1[chanz_idx % selected_chanz_nodes1.size ()].first ;
199+ switch_id = selected_chanz_nodes1[chanz_idx % selected_chanz_nodes1.size ()].second ;
200+ Fc_zofs[sb_loc1.x ][sb_loc1.y ][seg_index]++;
201+ }
202+
203+ rr_edges_to_create.emplace_back (opin_node_id, chanz_node_id, switch_id, false );
204+ }
205+ }
206+ }
207+
208+ }
209+
210+ void add_edges_opin_chanz_per_block (const RRGraphView& rr_graph,
211+ int layer,
212+ int x,
213+ int y,
214+ const std::vector<vtr::Matrix<int >>& Fc_out,
215+ const t_unified_to_parallel_seg_index& seg_index_map,
216+ int num_seg_types,
217+ t_rr_edge_info_set& rr_edges_to_create,
218+ const std::vector<t_bottleneck_link>& interdie_3d_links) {
112219 const RRSpatialLookup& node_lookup = rr_graph.node_lookup ();
113220 const DeviceGrid& grid = g_vpr_ctx.device ().grid ;
114221
0 commit comments