@@ -148,18 +148,17 @@ static bool is_loc_legal(const t_pl_loc& loc,
148148 t_logical_block_type_ptr block_type);
149149
150150/* *
151- * @brief Helper function to choose a subtile in specified location if compatible and available one exits .
151+ * @brief Helper function to choose a subtile in specified location if the type is compatible and an available one exists .
152152 *
153- * @param centroid The centroid location at which the subtile will be selected using its x,y, and layer.
154- * @param block_type Logical block type of the macro head member.
155- * @param block_loc_registry Placement block location information. To be filled with the location
156- * where pl_macro is placed.
157- * @param pr The PartitionRegion of the macro head member - represents its floorplanning constraints, is the size of
158- * the whole chip if the macro is not constrained.
159- * @param rng A random number generator to select subtile from available and compatible ones.
153+ * @param centroid The centroid location at which the subtile will be selected using its x, y, and layer.
154+ * @param block_type Logical block type we would like to place here.
155+ * @param block_loc_registry Information on where other blocks have been placed.
156+ * @param pr The PartitionRegion of the block we are trying to place - represents its floorplanning constraints;
157+ * it is the size of the whole chip if the block is not constrained.
158+ * @param rng A random number generator to select a subtile from the available and compatible ones.
160159 *
161- * @return False if location on chip, legal, but no available subtile found. True otherwise. False leads us to
162- * neighbour placement currently.
160+ * @return True if the location is on the chip, legal, and at least one available subtile is found at that location;
161+ * false otherwise.
163162 */
164163static bool find_subtile_in_location (t_pl_loc& centroid,
165164 t_logical_block_type_ptr block_type,
@@ -367,13 +366,13 @@ bool find_subtile_in_location(t_pl_loc& centroid,
367366 vtr::RngContainer& rng) {
368367 // check if the location is on chip and legal, if yes try to update subtile
369368 if (is_loc_on_chip ({centroid.x , centroid.y , centroid.layer }) && is_loc_legal (centroid, pr, block_type)) {
370- // finding the subtile location
369+ // find the compatible subtiles
371370 const auto & device_ctx = g_vpr_ctx.device ();
372371 const auto & compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [block_type->index ];
373372 const auto & type = device_ctx.grid .get_physical_type ({centroid.x , centroid.y , centroid.layer });
374373 const auto & compatible_sub_tiles = compressed_block_grid.compatible_sub_tile_num (type->index );
375374
376- // filter out occupied subtiles
375+ // filter out the occupied subtiles
377376 const GridBlock& grid_blocks = blk_loc_registry.grid_blocks ();
378377 std::vector<int > available_sub_tiles;
379378 available_sub_tiles.reserve (compatible_sub_tiles.size ());
@@ -384,16 +383,13 @@ bool find_subtile_in_location(t_pl_loc& centroid,
384383 }
385384 }
386385
387- // If there is at least one available subtile, update the centroid. Otherwise, sincel location
388- // is legal and on chip but no subtile found, return false for trying neighbour placement.
389386 if (!available_sub_tiles.empty ()) {
390387 centroid.sub_tile = available_sub_tiles[rng.irand ((int )available_sub_tiles.size () - 1 )];
391- } else {
392- return false ;
388+ return true ;
393389 }
394390 }
395391
396- return true ;
392+ return false ;
397393}
398394
399395static bool find_centroid_neighbor (t_pl_loc& centroid_loc,
@@ -607,14 +603,14 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
607603 t_pl_loc centroid_loc (OPEN, OPEN, OPEN, OPEN);
608604 std::vector<ClusterBlockId> unplaced_blocks_to_update_their_score;
609605
610- bool try_neighbour_due_to_subtile = false ;
606+ bool found_legal_subtile = false ;
611607
612608 if (!flat_placement_info.valid ) {
613609 // If a flat placement is not provided, use the centroid of connected
614610 // blocks which have already been placed.
615611 unplaced_blocks_to_update_their_score = find_centroid_loc (pl_macro, centroid_loc, blk_loc_registry);
616- if (! find_subtile_in_location (centroid_loc, block_type, blk_loc_registry, pr, rng)) {
617- try_neighbour_due_to_subtile = true ;
612+ if (find_subtile_in_location (centroid_loc, block_type, blk_loc_registry, pr, rng)) {
613+ found_legal_subtile = true ;
618614 }
619615 } else {
620616 // If a flat placement is provided, use the flat placement to get the
@@ -628,8 +624,8 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
628624 if (!is_loc_on_chip ({centroid_loc.x , centroid_loc.y , centroid_loc.layer }) ||
629625 !is_loc_legal (centroid_loc, pr, block_type)) {
630626 unplaced_blocks_to_update_their_score = find_centroid_loc (pl_macro, centroid_loc, blk_loc_registry);
631- if (! find_subtile_in_location (centroid_loc, block_type, blk_loc_registry, pr, rng)) {
632- try_neighbour_due_to_subtile = true ;
627+ if (find_subtile_in_location (centroid_loc, block_type, blk_loc_registry, pr, rng)) {
628+ found_legal_subtile = true ;
633629 }
634630 }
635631 }
@@ -641,7 +637,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
641637
642638 // centroid suggestion was either occupied or does not match block type
643639 // try to find a near location that meet these requirements
644- if (!is_loc_legal (centroid_loc, pr, block_type) || try_neighbour_due_to_subtile ) {
640+ if (!found_legal_subtile ) {
645641 bool neighbor_legal_loc = find_centroid_neighbor (centroid_loc, block_type, false , blk_loc_registry, rng);
646642 if (!neighbor_legal_loc) { // no neighbor candidate found
647643 return false ;
0 commit comments