50
50
# include " serdes_utils.h"
51
51
#endif /* VTR_ENABLE_CAPNPROTO */
52
52
53
+ const int VALID_NEIGHBOR_NUMBER = 3 ;
54
+
53
55
/* when a list of delay/congestion entries at a coordinate in Cost_Entry is boiled down to a single
54
56
* representative entry, this enum is passed-in to specify how that representative entry should be
55
57
* calculated */
@@ -142,6 +144,18 @@ static void fill_in_missing_lookahead_entries(int segment_index, e_rr_type chan_
142
144
/* returns a cost entry in the f_wire_cost_map that is near the specified coordinates (and preferably towards (0,0)) */
143
145
static util::Cost_Entry get_nearby_cost_entry (int from_layer_num, int x, int y, int to_layer_num, int segment_index, int chan_index);
144
146
147
+ /* *
148
+ * @brief Fill in the missing entry in router lookahead map
149
+ * If there is a missing entry in the router lookahead, search among its neighbors in a 3x3 window. If there are `VALID_NEIGHBOR_NUMBER` valid entries,
150
+ * take the average of them and fill in the missing entry.
151
+ * @param from_layer_num The layer num of the source node
152
+ * @param missing_dx Dx of the missing input
153
+ * @param missing_dy Dy of the missing input
154
+ * @param to_layer_num The layer num of the destination point
155
+ * @param segment_index The segment index of the source node
156
+ * @param chan_index The channel index of the source node
157
+ * @return The cost for the missing entry
158
+ */
145
159
static util::Cost_Entry get_nearby_cost_entry_average_neighbour (int from_layer_num,
146
160
int missing_dx,
147
161
int missing_dy,
@@ -641,13 +655,14 @@ static util::Cost_Entry get_nearby_cost_entry_average_neighbour(int from_layer_n
641
655
int to_layer_num,
642
656
int segment_index,
643
657
int chan_index) {
658
+ // Make sure that the given loaction doesn't have a valid entry
644
659
VTR_ASSERT (std::isnan (f_wire_cost_map[from_layer_num][chan_index][segment_index][to_layer_num][missing_dx][missing_dy].delay ));
645
660
VTR_ASSERT (std::isnan (f_wire_cost_map[from_layer_num][chan_index][segment_index][to_layer_num][missing_dx][missing_dy].congestion ));
646
661
647
- int neighbour_num = 0 ;
648
- float neighbour_delay_sum = 0 ;
649
- float neighbour_cong_sum = 0 ;
650
- std::array<int , 3 > window = {-1 , 0 , 1 };
662
+ int neighbour_num = 0 ; // Number of neighbours with valid entry
663
+ float neighbour_delay_sum = 0 ; // Acc of valid delay costs
664
+ float neighbour_cong_sum = 0 ; // Acc of valid congestion costs
665
+ std::array<int , 3 > window = {-1 , 0 , 1 }; // Average window size
651
666
for (int dx : window) {
652
667
int neighbour_x = missing_dx + dx;
653
668
if (neighbour_x < 0 || neighbour_x >= (int )f_wire_cost_map.dim_size (4 )) {
@@ -668,10 +683,12 @@ static util::Cost_Entry get_nearby_cost_entry_average_neighbour(int from_layer_n
668
683
}
669
684
}
670
685
671
- if (neighbour_num >= 3 ) {
686
+ // Store the average only if there are enough number of neighbours with valid entry
687
+ if (neighbour_num >= VALID_NEIGHBOR_NUMBER) {
672
688
return {neighbour_delay_sum / static_cast <float >(neighbour_num),
673
689
neighbour_cong_sum / static_cast <float >(neighbour_num)};
674
690
} else {
691
+ // If there are not enough neighbours with valid entry, retrieve to the previous way of getting the missing cost
675
692
return get_nearby_cost_entry (from_layer_num, missing_dx, missing_dy, to_layer_num, segment_index, chan_index);
676
693
}
677
694
}
0 commit comments