@@ -35,7 +35,8 @@ static std::vector<t_logical_block_type_ptr> grid_overused_resources(const Devic
35
35
static bool grid_satisfies_instance_counts (const DeviceGrid& grid, const std::map<t_logical_block_type_ptr, size_t >& instance_counts, float maximum_utilization);
36
36
static DeviceGrid build_device_grid (const t_grid_def& grid_def, size_t width, size_t height, bool warn_out_of_range = true , const std::vector<t_logical_block_type_ptr>& limiting_resources = std::vector<t_logical_block_type_ptr>());
37
37
38
- static void CheckGrid (const DeviceGrid& grid);
38
+ // /@brief Check grid is valid
39
+ static void check_grid (const DeviceGrid& grid);
39
40
40
41
static void set_grid_block_type (int priority,
41
42
const t_physical_tile_type* type,
@@ -545,7 +546,7 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
545
546
546
547
auto device_grid = DeviceGrid (grid_def.name , grid, limiting_resources);
547
548
548
- CheckGrid (device_grid);
549
+ check_grid (device_grid);
549
550
550
551
return device_grid;
551
552
}
@@ -615,8 +616,8 @@ static void set_grid_block_type(int priority,
615
616
priority, type->name .c_str ());
616
617
}
617
618
618
- // Mark all the grid tiles 'covered' by this block with the appropriate type
619
- // and width/height offsets
619
+ // Mark all the grid tiles 'covered' by this block with the appropriate type
620
+ // and width/height offsets
620
621
std::set<TypeLocation> root_blocks_to_rip_up;
621
622
auto & device_ctx = g_vpr_ctx.device ();
622
623
for (size_t x = x_root; x < x_root + type->width ; ++x) {
@@ -654,9 +655,9 @@ static void set_grid_block_type(int priority,
654
655
}
655
656
}
656
657
657
- // Rip-up any invalidated blocks
658
+ // Rip-up any invalidated blocks
658
659
for (auto invalidated_root : root_blocks_to_rip_up) {
659
- // Mark all the grid locations used by this root block as empty
660
+ // Mark all the grid locations used by this root block as empty
660
661
for (size_t x = invalidated_root.x ; x < invalidated_root.x + invalidated_root.type ->width ; ++x) {
661
662
int x_offset = x - invalidated_root.x ;
662
663
for (size_t y = invalidated_root.y ; y < invalidated_root.y + invalidated_root.type ->height ; ++y) {
@@ -690,65 +691,53 @@ static void set_grid_block_type(int priority,
690
691
}
691
692
}
692
693
693
- // /@brief Check grid is valid
694
- static void CheckGrid (const DeviceGrid& grid) {
695
- for (int layer_num = 0 ; layer_num < grid.get_num_layers (); layer_num++) { // Check each die individually
696
- for (int i = 0 ; i < (int )grid.width (); ++i) {
697
- for (int j = 0 ; j < (int )grid.height (); ++j) {
698
- const t_physical_tile_loc tile_loc (i, j, layer_num);
699
- const auto & type = grid.get_physical_type (tile_loc);
700
- int width_offset = grid.get_width_offset (tile_loc);
701
- int height_offset = grid.get_height_offset (tile_loc);
702
- if (nullptr == type) {
703
- VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has no type.\n " , i, j, layer_num);
704
- }
694
+ static void check_grid (const DeviceGrid& grid) {
695
+ for (const t_physical_tile_loc tile_loc : grid.all_locations ()) {
696
+ const t_physical_tile_type_ptr type = grid.get_physical_type (tile_loc);
697
+ int width_offset = grid.get_width_offset (tile_loc);
698
+ int height_offset = grid.get_height_offset (tile_loc);
699
+ if (nullptr == type) {
700
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has no type.\n " , tile_loc.layer_num , tile_loc.x , tile_loc.y );
701
+ }
705
702
706
- if ((grid.get_width_offset (tile_loc) < 0 )
707
- || (grid.get_width_offset (tile_loc) >= type->width )) {
708
- VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has invalid width offset (%d).\n " ,
709
- i,
710
- j,
711
- layer_num,
712
- width_offset);
713
- }
714
- if ((grid.get_height_offset (tile_loc) < 0 )
715
- || (grid.get_height_offset (tile_loc) >= type->height )) {
716
- VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has invalid height offset (%d).\n " ,
717
- i,
718
- j,
719
- layer_num,
720
- height_offset);
721
- }
703
+ if ((grid.get_width_offset (tile_loc) < 0 ) || (grid.get_width_offset (tile_loc) >= type->width )) {
704
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has invalid width offset (%d).\n " ,
705
+ tile_loc.layer_num , tile_loc.x , tile_loc.y ,
706
+ width_offset);
707
+ }
708
+ if ((grid.get_height_offset (tile_loc) < 0 ) || (grid.get_height_offset (tile_loc) >= type->height )) {
709
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Grid Location (%d,%d,%d) has invalid height offset (%d).\n " ,
710
+ tile_loc.layer_num , tile_loc.x , tile_loc.y ,
711
+ height_offset);
712
+ }
722
713
723
- // Verify that type and width/height offsets are correct (e.g. for dimension > 1 blocks)
724
- if (grid.get_width_offset (tile_loc) == 0 && grid.get_height_offset (tile_loc) == 0 ) {
725
- // From the root block check that all other blocks are correct
726
- for (int x = i; x < i + type->width ; ++x) {
727
- int x_offset = x - i;
728
- for (int y = j; y < j + type->height ; ++y) {
729
- int y_offset = y - j;
730
- const t_physical_tile_loc tile_loc_offset (x, y, layer_num);
731
- const auto & tile_type = grid.get_physical_type (tile_loc_offset);
732
- int tile_width_offset = grid.get_width_offset (tile_loc_offset);
733
- int tile_height_offset = grid.get_height_offset (tile_loc_offset);
734
- if (tile_type != type) {
735
- VPR_FATAL_ERROR (VPR_ERROR_OTHER,
736
- " Grid Location (%d,%d,%d) should have type '%s' (based on root location) but has type '%s'\n " ,
737
- i, j, layer_num, type->name .c_str (), type->name .c_str ());
738
- }
739
-
740
- if (tile_width_offset != x_offset) {
741
- VPR_FATAL_ERROR (VPR_ERROR_OTHER,
742
- " Grid Location (%d,%d,%d) of type '%s' should have width offset '%d' (based on root location) but has '%d'\n " ,
743
- i, j, layer_num, type->name .c_str (), x_offset, tile_width_offset);
744
- }
745
-
746
- if (tile_height_offset != y_offset) {
747
- VPR_FATAL_ERROR (VPR_ERROR_OTHER,
748
- " Grid Location (%d,%d,%d) of type '%s' should have height offset '%d' (based on root location) but has '%d'\n " ,
749
- i, j, layer_num, type->name .c_str (), y_offset, tile_height_offset);
750
- }
751
- }
714
+ // Verify that type and width/height offsets are correct (e.g. for dimension > 1 blocks)
715
+ if (grid.get_width_offset (tile_loc) == 0 && grid.get_height_offset (tile_loc) == 0 ) {
716
+ // From the root block check that all other blocks are correct
717
+ for (int x = tile_loc.x ; x < tile_loc.x + type->width ; ++x) {
718
+ int x_offset = x - tile_loc.x ;
719
+ for (int y = tile_loc.y ; y < tile_loc.y + type->height ; ++y) {
720
+ int y_offset = y - tile_loc.y ;
721
+ const t_physical_tile_loc tile_loc_offset (x, y, tile_loc.layer_num );
722
+ const auto & tile_type = grid.get_physical_type (tile_loc_offset);
723
+ int tile_width_offset = grid.get_width_offset (tile_loc_offset);
724
+ int tile_height_offset = grid.get_height_offset (tile_loc_offset);
725
+ if (tile_type != type) {
726
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER,
727
+ " Grid Location (%d,%d,%d) should have type '%s' (based on root location) but has type '%s'\n " ,
728
+ tile_loc.layer_num , tile_loc.x , tile_loc.y , type->name .c_str (), type->name .c_str ());
729
+ }
730
+
731
+ if (tile_width_offset != x_offset) {
732
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER,
733
+ " Grid Location (%d,%d,%d) of type '%s' should have width offset '%d' (based on root location) but has '%d'\n " ,
734
+ tile_loc.layer_num , tile_loc.x , tile_loc.y , type->name .c_str (), x_offset, tile_width_offset);
735
+ }
736
+
737
+ if (tile_height_offset != y_offset) {
738
+ VPR_FATAL_ERROR (VPR_ERROR_OTHER,
739
+ " Grid Location (%d,%d,%d) of type '%s' should have height offset '%d' (based on root location) but has '%d'\n " ,
740
+ tile_loc.layer_num , tile_loc.x , tile_loc.y , type->name .c_str (), y_offset, tile_height_offset);
752
741
}
753
742
}
754
743
}
0 commit comments