@@ -54,7 +54,7 @@ bool is_macro_constrained(const t_pl_macro& pl_macro) {
54
54
}
55
55
56
56
/* Returns PartitionRegion of where the head of the macro could go*/
57
- PartitionRegion update_macro_head_pr (const t_pl_macro& pl_macro) {
57
+ PartitionRegion update_macro_head_pr (const t_pl_macro& pl_macro, const PartitionRegion& grid_pr ) {
58
58
PartitionRegion macro_head_pr;
59
59
bool is_member_constrained = false ;
60
60
int num_constrained_members = 0 ;
@@ -105,6 +105,9 @@ PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro) {
105
105
}
106
106
}
107
107
108
+ // intersect to ensure the head pr does not go outside of grid dimensions
109
+ macro_head_pr = intersection (macro_head_pr, grid_pr);
110
+
108
111
// if the intersection is empty, no way to place macro members together, give an error
109
112
if (macro_head_pr.empty ()) {
110
113
VPR_ERROR (VPR_ERROR_PLACE, " \n Feasible floorplanning constraints could not be calculated for the placement macro.\n " );
@@ -113,7 +116,7 @@ PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro) {
113
116
return macro_head_pr;
114
117
}
115
118
116
- PartitionRegion update_macro_member_pr (PartitionRegion& head_pr, const t_pl_offset& offset) {
119
+ PartitionRegion update_macro_member_pr (PartitionRegion& head_pr, const t_pl_offset& offset, const PartitionRegion& grid_pr ) {
117
120
std::vector<Region> block_regions = head_pr.get_partition_region ();
118
121
PartitionRegion macro_pr;
119
122
@@ -139,20 +142,38 @@ PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offs
139
142
macro_pr.add_to_part_region (modified_reg);
140
143
}
141
144
145
+ // intersect to ensure the head pr does not go outside of grid dimensions
146
+ macro_pr = intersection (macro_pr, grid_pr);
147
+
148
+ // if the intersection is empty, no way to place macro members together, give an error
149
+ if (macro_pr.empty ()) {
150
+ VPR_ERROR (VPR_ERROR_PLACE, " \n Feasible floorplanning constraints could not be calculated for the placement macro.\n " );
151
+ }
152
+
142
153
return macro_pr;
143
154
}
144
155
145
156
void propagate_place_constraints () {
146
157
auto & place_ctx = g_vpr_ctx.placement ();
147
158
auto & floorplanning_ctx = g_vpr_ctx.mutable_floorplanning ();
159
+ auto & device_ctx = g_vpr_ctx.device ();
160
+
161
+ // Create a PartitionRegion with grid dimensions
162
+ // Will be used to check that updated PartitionRegions are within grid bounds
163
+ int width = device_ctx.grid .width () - 1 ;
164
+ int height = device_ctx.grid .height () - 1 ;
165
+ Region grid_reg;
166
+ grid_reg.set_region_rect (0 , 0 , width, height);
167
+ PartitionRegion grid_pr;
168
+ grid_pr.add_to_part_region (grid_reg);
148
169
149
170
for (auto pl_macro : place_ctx.pl_macros ) {
150
171
if (is_macro_constrained (pl_macro)) {
151
172
/*
152
173
* Update the PartitionRegion for the head of the macro
153
174
* based on the constraints of all blocks contained in the macro
154
175
*/
155
- PartitionRegion macro_head_pr = update_macro_head_pr (pl_macro);
176
+ PartitionRegion macro_head_pr = update_macro_head_pr (pl_macro, grid_pr );
156
177
157
178
// Update PartitionRegions of all members of the macro
158
179
for (size_t imember = 0 ; imember < pl_macro.members .size (); imember++) {
@@ -163,7 +184,7 @@ void propagate_place_constraints() {
163
184
if (imember == 0 ) {
164
185
floorplanning_ctx.cluster_constraints [iblk] = macro_head_pr;
165
186
} else { // Update macro member PR
166
- PartitionRegion macro_pr = update_macro_member_pr (macro_head_pr, offset);
187
+ PartitionRegion macro_pr = update_macro_member_pr (macro_head_pr, offset, grid_pr );
167
188
floorplanning_ctx.cluster_constraints [iblk] = macro_pr;
168
189
}
169
190
}
0 commit comments