Skip to content

Commit 9ddf089

Browse files
test grid_loc_to_compressed_loc_approx_round_up() and grid_loc_to_compressed_loc_approx_round_down()
1 parent 58f4545 commit 9ddf089

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

vpr/test/test_compressed_grid.cpp

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ TEST_CASE("test_compressed_grid", "[vpr_compressed_grid]") {
228228
REQUIRE(grid_loc == t_physical_tile_loc{17, 3, 0});
229229
}
230230

231-
SECTION("Closest mapped location in the compressed grids") {
231+
SECTION("Round to the nearest mapped location in the compressed grid") {
232232
t_physical_tile_loc comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx({25, 33, 0});
233233
t_physical_tile_loc grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
234234
REQUIRE(grid_loc == t_physical_tile_loc{25, 33, 0});
@@ -262,6 +262,74 @@ TEST_CASE("test_compressed_grid", "[vpr_compressed_grid]") {
262262
REQUIRE(grid_loc == t_physical_tile_loc{98, 98, 0});
263263
}
264264

265+
SECTION("Round down to the closest mapped location in the compressed grid") {
266+
t_physical_tile_loc comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({25, 33, 0});
267+
t_physical_tile_loc grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
268+
REQUIRE(grid_loc == t_physical_tile_loc{25, 33, 0});
269+
270+
comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({99, 10, 0});
271+
grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
272+
REQUIRE(grid_loc == t_physical_tile_loc{76, 7, 0});
273+
274+
comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({51, 79, 0});
275+
grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
276+
REQUIRE(grid_loc == t_physical_tile_loc{42, 72, 0});
277+
278+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({1, 6, 0});
279+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
280+
REQUIRE(grid_loc == t_physical_tile_loc{7, 5, 0});
281+
282+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({81, 38, 0});
283+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
284+
REQUIRE(grid_loc == t_physical_tile_loc{77, 35, 0});
285+
286+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({34, 83, 0});
287+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
288+
REQUIRE(grid_loc == t_physical_tile_loc{27, 80, 0});
289+
290+
comp_loc = compressed_grids[small_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({0, 0, 0});
291+
grid_loc = compressed_grids[small_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
292+
REQUIRE(grid_loc == t_physical_tile_loc{1, 1, 0});
293+
294+
comp_loc = compressed_grids[small_logical_type.index].grid_loc_to_compressed_loc_approx_round_down({99, 99, 0});
295+
grid_loc = compressed_grids[small_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
296+
REQUIRE(grid_loc == t_physical_tile_loc{98, 98, 0});
297+
}
298+
299+
SECTION("Round up to the closest mapped location in the compressed grid") {
300+
t_physical_tile_loc comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({25, 33, 0});
301+
t_physical_tile_loc grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
302+
REQUIRE(grid_loc == t_physical_tile_loc{25, 33, 0});
303+
304+
comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({99, 10, 0});
305+
grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
306+
REQUIRE(grid_loc == t_physical_tile_loc{76, 20, 0});
307+
308+
comp_loc = compressed_grids[large_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({51, 79, 0});
309+
grid_loc = compressed_grids[large_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
310+
REQUIRE(grid_loc == t_physical_tile_loc{59, 85, 0});
311+
312+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({1, 6, 0});
313+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
314+
REQUIRE(grid_loc == t_physical_tile_loc{7, 10, 0});
315+
316+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({81, 38, 0});
317+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
318+
REQUIRE(grid_loc == t_physical_tile_loc{87, 40, 0});
319+
320+
comp_loc = compressed_grids[tall_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({34, 83, 0});
321+
grid_loc = compressed_grids[tall_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
322+
REQUIRE(grid_loc == t_physical_tile_loc{37, 85, 0});
323+
324+
comp_loc = compressed_grids[small_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({0, 0, 0});
325+
grid_loc = compressed_grids[small_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
326+
REQUIRE(grid_loc == t_physical_tile_loc{1, 1, 0});
327+
328+
comp_loc = compressed_grids[small_logical_type.index].grid_loc_to_compressed_loc_approx_round_up({99, 99, 0});
329+
grid_loc = compressed_grids[small_logical_type.index].compressed_loc_to_grid_loc(comp_loc);
330+
REQUIRE(grid_loc == t_physical_tile_loc{98, 98, 0});
331+
}
332+
265333
}
266334

267335
} // namespace

0 commit comments

Comments
 (0)