diff --git a/vpr/src/base/region.cpp b/vpr/src/base/region.cpp index 2035a57e717..ed5b79c068b 100644 --- a/vpr/src/base/region.cpp +++ b/vpr/src/base/region.cpp @@ -81,20 +81,36 @@ bool do_regions_intersect(Region r1, Region r2) { Region intersection(const Region& r1, const Region& r2) { Region intersect; + vtr::Rect r1_rect = r1.get_region_rect(); + vtr::Rect r2_rect = r2.get_region_rect(); + vtr::Rect intersect_rect; - /** - * If the subtiles of the two regions don't match, there is no intersection. - * If they do match, the intersection function if used to get the overlap of the two regions' rectangles. - * If there is no overlap, an empty rectangle will be returned. + /* + * If the subtiles of two regions match (i.e. they both have no subtile specified, or the same subtile specified), + * the regions are intersected. The resulting intersection region will have a rectangle that reflects their overlap, + * (it will be empty if there is no overlap), and a subtile that is the same as that of both regions. + * + * If one of the two regions has a subtile specified, and the other does not, the regions are intersected. + * The resulting intersection region will have a rectangle that reflects their overlap (it will be empty if there is + * no overlap), and a subtile that is the same as the subtile of the region with the specific subtile assigned. + * + * If none of the above cases are true (i.e. the regions both have subtiles specified, but the subtiles do not + * match each other) then the intersection is not performed and a region with an empty rectangle is returned. + * This is because there can be no overlap in this case since the regions are constrained to two separate subtiles. */ if (r1.get_sub_tile() == r2.get_sub_tile()) { intersect.set_sub_tile(r1.get_sub_tile()); - vtr::Rect r1_rect = r1.get_region_rect(); - vtr::Rect r2_rect = r2.get_region_rect(); - vtr::Rect intersect_rect; + intersect_rect = intersection(r1_rect, r2_rect); + intersect.set_region_rect(intersect_rect.xmin(), intersect_rect.ymin(), intersect_rect.xmax(), intersect_rect.ymax()); + } else if (r1.get_sub_tile() == NO_SUBTILE && r2.get_sub_tile() != NO_SUBTILE) { + intersect.set_sub_tile(r2.get_sub_tile()); intersect_rect = intersection(r1_rect, r2_rect); + intersect.set_region_rect(intersect_rect.xmin(), intersect_rect.ymin(), intersect_rect.xmax(), intersect_rect.ymax()); + } else if (r1.get_sub_tile() != NO_SUBTILE && r2.get_sub_tile() == NO_SUBTILE) { + intersect.set_sub_tile(r1.get_sub_tile()); + intersect_rect = intersection(r1_rect, r2_rect); intersect.set_region_rect(intersect_rect.xmin(), intersect_rect.ymin(), intersect_rect.xmax(), intersect_rect.ymax()); } diff --git a/vpr/src/place/initial_placement.cpp b/vpr/src/place/initial_placement.cpp index d5662af4f47..8bda8f3d3a2 100644 --- a/vpr/src/place/initial_placement.cpp +++ b/vpr/src/place/initial_placement.cpp @@ -47,9 +47,9 @@ static t_physical_tile_type_ptr pick_placement_type(t_logical_block_type_ptr log vtr::vector assign_block_scores(); //Sort the blocks according to how difficult they are to place, prior to initial placement -std::vector sort_blocks(vtr::vector block_scores); +std::vector sort_blocks(const vtr::vector& block_scores); -void print_sorted_blocks(std::vector sorted_blocks, vtr::vector block_scores); +void print_sorted_blocks(const std::vector& sorted_blocks, const vtr::vector& block_scores); static int get_free_sub_tile(std::vector>& free_locations, int itype, std::vector possible_sub_tiles) { for (int sub_tile : possible_sub_tiles) { @@ -359,6 +359,12 @@ vtr::vector assign_block_scores() { block_scores.resize(blocks.size()); + /* + * For the blocks with no floorplan constraints, and the blocks that are not part of macros, + * the block scores will remain at their default values assigned by the constructor + * (macro_size = 0; floorplan_constraints = 0; num_equivalent_tiles =1; + */ + //go through all blocks and store floorplan constraints and num equivalent tiles for (auto blk_id : blocks) { if (is_cluster_constrained(blk_id)) { @@ -380,7 +386,7 @@ vtr::vector assign_block_scores() { return block_scores; } -std::vector sort_blocks(vtr::vector block_scores) { +std::vector sort_blocks(const vtr::vector& block_scores) { auto& cluster_ctx = g_vpr_ctx.clustering(); auto blocks = cluster_ctx.clb_nlist.blocks(); @@ -400,7 +406,7 @@ std::vector sort_blocks(vtr::vector sorted_blocks, vtr::vector block_scores) { +void print_sorted_blocks(const std::vector& sorted_blocks, const vtr::vector& block_scores) { VTR_LOG("\nPrinting sorted blocks: \n"); for (unsigned int i = 0; i < sorted_blocks.size(); i++) { VTR_LOG("Block_Id: %zu, Macro size: %d, Num floorplan constraints: %d, Num equivalent tiles %d \n", sorted_blocks[i], block_scores[sorted_blocks[i]].macro_size, block_scores[sorted_blocks[i]].floorplan_constraints, block_scores[sorted_blocks[i]].num_equivalent_tiles);