@@ -128,7 +128,7 @@ static int vpr_to_phy_track(const int itrack,
128128 const int chan_num,
129129 const int seg_num,
130130 const t_chan_seg_details* seg_details,
131- const enum e_directionality directionality);
131+ const e_directionality directionality);
132132
133133/* *
134134 * @brief Identifies and labels all mux endpoints at a given channel segment coordinate.
@@ -189,9 +189,9 @@ std::vector<int> get_seg_track_counts(int num_sets,
189189 // Scale factor so we can divide by any length and still use integers
190190 double scale = 1 ;
191191 int freq_sum = 0 ;
192- for (size_t i = 0 ; i < segment_inf. size (); ++i ) {
193- scale *= segment_inf[i] .length ;
194- freq_sum += segment_inf[i] .frequency ;
192+ for (const t_segment_inf& seg_inf : segment_inf) {
193+ scale *= seg_inf .length ;
194+ freq_sum += seg_inf .frequency ;
195195 }
196196 const double reduce = scale * freq_sum;
197197
@@ -1082,10 +1082,10 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
10821082 const t_sb_connection_map* sb_conn_map) {
10831083 int to_chan, to_sb;
10841084 std::vector<int > conn_tracks;
1085- bool from_is_sblock, is_behind, Fs_clipped;
1085+ bool Fs_clipped;
10861086 e_side to_side;
10871087
1088- /* check whether a custom switch block will be used */
1088+ // check whether a custom switch block will be used
10891089 bool custom_switch_block = false ;
10901090 if (sb_conn_map != nullptr ) {
10911091 custom_switch_block = true ;
@@ -1134,9 +1134,9 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
11341134 continue ;
11351135 }
11361136
1137- /* Figure out if we are at a sblock */
1138- from_is_sblock = is_sblock (from_chan, from_seg, sb_seg, from_track,
1139- from_seg_details, directionality);
1137+ // Figure out if we are at a sblock
1138+ bool from_is_sblock = is_sblock (from_chan, from_seg, sb_seg, from_track,
1139+ from_seg_details, directionality);
11401140 if (sb_seg == end_sb_seg || sb_seg == start_sb_seg) {
11411141 /* end of wire must be an sblock */
11421142 from_is_sblock = true ;
@@ -1173,9 +1173,9 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
11731173 if (to_seg_details[0 ].length () == 0 )
11741174 continue ;
11751175
1176- /* Figure out whether the switch block at the current sb_seg coordinate is *behind*
1177- * the target channel segment (with respect to VPR coordinate system) */
1178- is_behind = false ;
1176+ // Figure out whether the switch block at the current sb_seg coordinate is *behind*
1177+ // the target channel segment (with respect to VPR coordinate system)
1178+ bool is_behind = false ;
11791179 if (to_type == from_type) {
11801180 if (sb_seg == start) {
11811181 is_behind = true ;
@@ -1296,12 +1296,10 @@ static int get_bidir_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
12961296 const enum e_directionality directionality,
12971297 RRNodeId from_rr_node,
12981298 t_rr_edge_info_set& rr_edges_to_create) {
1299- unsigned iconn;
1300- int to_track, to_switch, num_conn, to_x, to_y, i;
1301- bool to_is_sblock;
1299+ int to_x, to_y;
13021300 short switch_types[2 ];
13031301
1304- /* x, y coords for get_rr_node lookups */
1302+ // x, y coords for get_rr_node lookups
13051303 if (e_rr_type::CHANX == to_type) {
13061304 to_x = to_seg;
13071305 to_y = to_chan;
@@ -1311,27 +1309,25 @@ static int get_bidir_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
13111309 to_y = to_seg;
13121310 }
13131311
1314- /* Go through the list of tracks we can connect to */
1315- num_conn = 0 ;
1316- for (iconn = 0 ; iconn < conn_tracks.size (); ++iconn) {
1317- to_track = conn_tracks[iconn];
1312+ // Go through the list of tracks we can connect to
1313+ int num_conn = 0 ;
1314+ for (int to_track : conn_tracks) {
13181315 RRNodeId to_node = rr_graph_builder.node_lookup ().find_node (layer, to_x, to_y, to_type, to_track);
13191316
13201317 if (!to_node) {
13211318 continue ;
13221319 }
13231320
13241321 /* Get the switches for any edges between the two tracks */
1325- to_switch = seg_details[to_track].arch_wire_switch ();
1322+ int to_switch = seg_details[to_track].arch_wire_switch ();
13261323
1327- to_is_sblock = is_sblock (to_chan, to_seg, to_sb, to_track, seg_details,
1328- directionality);
1324+ bool to_is_sblock = is_sblock (to_chan, to_seg, to_sb, to_track, seg_details, directionality);
13291325 get_switch_type (from_is_sblock, to_is_sblock, from_switch, to_switch,
13301326 switch_override,
13311327 switch_types);
13321328
1333- /* There are up to two switch edges allowed from track to track */
1334- for (i = 0 ; i < 2 ; ++i) {
1329+ // There are up to two switch edges allowed from track to track
1330+ for (int i = 0 ; i < 2 ; ++i) {
13351331 /* If the switch_type entry is empty, skip it */
13361332 if (UNDEFINED == switch_types[i]) {
13371333 continue ;
@@ -1365,7 +1361,7 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
13651361
13661362 // Coordinate to index into the SB map
13671363 SwitchblockLookupKey sb_coord (tile_x, tile_y, layer, from_side, to_side);
1368- if (sb_conn_map.count (sb_coord) > 0 ) {
1364+ if (sb_conn_map.contains (sb_coord)) {
13691365 // Reference to the connections vector which lists all destination wires for a given source wire
13701366 // at a specific coordinate sb_coord
13711367 const std::vector<t_switchblock_edge>& sb_edges = sb_conn_map.at (sb_coord);
@@ -1549,24 +1545,22 @@ static int get_unidir_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
15491545}
15501546
15511547bool is_sblock (const int chan, int wire_seg, const int sb_seg, const int track, const t_chan_seg_details* seg_details, const enum e_directionality directionality) {
1552- int length, ofs, fac;
1553-
1554- fac = 1 ;
1548+ int fac = 1 ;
15551549 if (UNI_DIRECTIONAL == directionality) {
15561550 fac = 2 ;
15571551 }
15581552
1559- length = seg_details[track].length ();
1553+ int length = seg_details[track].length ();
15601554
1561- /* Make sure they gave us correct start */
1555+ // Make sure they gave us correct start
15621556 wire_seg = get_seg_start (seg_details, track, chan, wire_seg);
15631557
1564- ofs = sb_seg - wire_seg + 1 ; /* Offset 0 is behind us, so add 1 */
1558+ int ofs = sb_seg - wire_seg + 1 ; // Offset 0 is behind us, so add 1
15651559
15661560 VTR_ASSERT (ofs >= 0 );
15671561 VTR_ASSERT (ofs < (length + 1 ));
15681562
1569- /* If unidir segment that is going backwards, we need to flip the ofs */
1563+ // If unidir segment that is going backwards, we need to flip the ofs
15701564 if ((ofs % fac) > 0 ) {
15711565 ofs = length - ofs;
15721566 }
@@ -1661,28 +1655,21 @@ static int vpr_to_phy_track(const int itrack,
16611655 const int chan_num,
16621656 const int seg_num,
16631657 const t_chan_seg_details* seg_details,
1664- const enum e_directionality directionality) {
1665- int group_start, group_size;
1666- int vpr_offset_for_first_phy_track;
1667- int vpr_offset, phy_offset;
1668- int phy_track;
1669- int fac;
1658+ const e_directionality directionality) {
16701659
1671- /* Assign in pairs if unidir. */
1672- fac = 1 ;
1660+ // Assign in pairs if unidir.
1661+ int fac = 1 ;
16731662 if (UNI_DIRECTIONAL == directionality) {
16741663 fac = 2 ;
16751664 }
16761665
1677- group_start = seg_details[itrack].group_start ();
1678- group_size = seg_details[itrack].group_size ();
1666+ int group_start = seg_details[itrack].group_start ();
1667+ int group_size = seg_details[itrack].group_size ();
16791668
1680- vpr_offset_for_first_phy_track = (chan_num + seg_num - 1 )
1681- % (group_size / fac);
1682- vpr_offset = (itrack - group_start) / fac;
1683- phy_offset = (vpr_offset_for_first_phy_track + vpr_offset)
1684- % (group_size / fac);
1685- phy_track = group_start + (fac * phy_offset) + (itrack - group_start) % fac;
1669+ int vpr_offset_for_first_phy_track = (chan_num + seg_num - 1 ) % (group_size / fac);
1670+ int vpr_offset = (itrack - group_start) / fac;
1671+ int phy_offset = (vpr_offset_for_first_phy_track + vpr_offset) % (group_size / fac);
1672+ int phy_track = group_start + (fac * phy_offset) + (itrack - group_start) % fac;
16861673
16871674 return phy_track;
16881675}
@@ -2047,7 +2034,7 @@ static void label_incoming_wires(const int chan_num,
20472034
20482035 /* Alloc the list of labels for the tracks */
20492036 labels.resize (max_chan_width);
2050- std::fill (labels. begin (), labels. end () , UN_SET);
2037+ std::ranges:: fill (labels, UN_SET);
20512038
20522039 int num_ending = 0 ;
20532040 int num_passing = 0 ;
@@ -2134,12 +2121,12 @@ static int should_create_switchblock(const DeviceGrid& grid, int layer_num, int
21342121 x_coord = from_chan_coord;
21352122 }
21362123
2137- auto blk_type = grid.get_physical_type ({x_coord, y_coord, layer_num});
2124+ t_physical_tile_type_ptr blk_type = grid.get_physical_type ({x_coord, y_coord, layer_num});
21382125 int width_offset = grid.get_width_offset ({x_coord, y_coord, layer_num});
21392126 int height_offset = grid.get_height_offset ({x_coord, y_coord, layer_num});
21402127
21412128 e_sb_type sb_type = blk_type->switchblock_locations [width_offset][height_offset];
2142- auto switch_override = blk_type->switchblock_switch_overrides [width_offset][height_offset];
2129+ int switch_override = blk_type->switchblock_switch_overrides [width_offset][height_offset];
21432130
21442131 if (sb_type == e_sb_type::FULL) {
21452132 return switch_override;
0 commit comments