8
8
// for comparing floats
9
9
#include " vtr_math.h"
10
10
11
+ #include < limits>
12
+
11
13
namespace {
12
14
13
15
void set_type_tile_to_empty (const int x, const int y,
@@ -46,6 +48,7 @@ void set_tile_type_at_loc(const int x_anchor, const int y_anchor,
46
48
}
47
49
}
48
50
51
+
49
52
TEST_CASE (" test_compressed_grid" , " [vpr_compressed_grid]" ) {
50
53
// test device grid name
51
54
std::string device_grid_name = " test" ;
@@ -64,54 +67,86 @@ TEST_CASE("test_compressed_grid", "[vpr_compressed_grid]") {
64
67
// create the test device grid (10x10)
65
68
auto test_grid = vtr::NdMatrix<t_grid_tile, 3 >({1 , test_grid_width, test_grid_height});
66
69
67
- t_logical_block_type EMPTY_LOGICAL_BLOCK_TYPE = get_empty_logical_type ();
68
- EMPTY_LOGICAL_BLOCK_TYPE.index = 0 ;
70
+ auto & logical_block_types = g_vpr_ctx.mutable_device ().logical_block_types ;
71
+ logical_block_types.clear ();
72
+
69
73
70
74
t_physical_tile_type empty_tile;
71
75
empty_tile.name = empty_tile_name;
72
76
empty_tile.height = 1 ;
73
77
empty_tile.width = 1 ;
78
+ empty_tile.sub_tiles .emplace_back ();
79
+
80
+ t_logical_block_type EMPTY_LOGICAL_BLOCK_TYPE = get_empty_logical_type ();
81
+ EMPTY_LOGICAL_BLOCK_TYPE.index = 0 ;
82
+ EMPTY_LOGICAL_BLOCK_TYPE.equivalent_tiles .push_back (&empty_tile);
83
+ logical_block_types.push_back (EMPTY_LOGICAL_BLOCK_TYPE);
74
84
75
85
g_vpr_ctx.mutable_device ().EMPTY_PHYSICAL_TILE_TYPE = &empty_tile;
76
86
87
+ empty_tile.sub_tiles .back ().index = 0 ;
88
+ empty_tile.sub_tiles .back ().equivalent_sites .push_back (&EMPTY_LOGICAL_BLOCK_TYPE);
89
+
90
+
77
91
// create an io physical tile and assign its parameters
78
92
t_physical_tile_type io_tile;
79
93
io_tile.name = io_tile_name;
80
94
io_tile.height = 1 ;
81
95
io_tile.width = 1 ;
96
+ io_tile.sub_tiles .emplace_back ();
82
97
83
98
t_logical_block_type io_logical_type;
84
99
io_logical_type.index = 1 ;
85
100
io_logical_type.equivalent_tiles .push_back (&io_tile);
101
+ logical_block_types.push_back (io_logical_type);
102
+
103
+ io_tile.sub_tiles .back ().index = 0 ;
104
+ io_tile.sub_tiles .back ().equivalent_sites .push_back (&io_logical_type);
86
105
87
106
// create a small tile and assign its parameters
88
107
t_physical_tile_type small_tile;
89
108
small_tile.name = small_tile_name;
90
109
small_tile.height = 1 ;
91
110
small_tile.width = 1 ;
111
+ small_tile.sub_tiles .emplace_back ();
92
112
93
113
t_logical_block_type small_logical_type;
94
114
small_logical_type.index = 2 ;
95
115
small_logical_type.equivalent_tiles .push_back (&small_tile);
116
+ logical_block_types.push_back (small_logical_type);
117
+
118
+ small_tile.sub_tiles .back ().index = 0 ;
119
+ small_tile.sub_tiles .back ().equivalent_sites .push_back (&small_logical_type);
96
120
97
121
// create a small tile and assign its parameters
98
122
t_physical_tile_type tall_tile;
99
123
tall_tile.name = tall_tile_name;
100
124
tall_tile.height = 4 ;
101
125
tall_tile.width = 1 ;
126
+ tall_tile.sub_tiles .emplace_back ();
102
127
103
128
t_logical_block_type tall_logical_type;
104
129
tall_logical_type.index = 3 ;
105
130
tall_logical_type.equivalent_tiles .push_back (&tall_tile);
131
+ logical_block_types.push_back (tall_logical_type);
132
+
133
+
134
+ tall_tile.sub_tiles .back ().index = 0 ;
135
+ tall_tile.sub_tiles .back ().equivalent_sites .push_back (&tall_logical_type);
106
136
107
137
t_physical_tile_type large_tile;
108
138
large_tile.name = large_tile_name;
109
139
large_tile.height = 3 ;
110
140
large_tile.width = 3 ;
141
+ large_tile.sub_tiles .emplace_back ();
111
142
112
143
t_logical_block_type large_logical_type;
113
144
large_logical_type.index = 4 ;
114
145
large_logical_type.equivalent_tiles .push_back (&large_tile);
146
+ logical_block_types.push_back (large_logical_type);
147
+
148
+ large_tile.sub_tiles .back ().index = 0 ;
149
+ large_tile.sub_tiles .back ().equivalent_sites .push_back (&large_logical_type);
115
150
116
151
117
152
for (int x = 0 ; x < test_grid_width; x++) {
@@ -140,19 +175,92 @@ TEST_CASE("test_compressed_grid", "[vpr_compressed_grid]") {
140
175
}
141
176
}
142
177
143
- auto & logical_block_types = g_vpr_ctx.mutable_device ().logical_block_types ;
144
- logical_block_types.clear ();
145
-
146
178
auto & grid = g_vpr_ctx.mutable_device ().grid ;
147
179
grid = DeviceGrid (" test_device_grid" , test_grid);
148
180
149
181
std::vector<t_compressed_block_grid> compressed_grids = create_compressed_block_grids ();
150
182
151
- echo_compressed_grids (" havij" , compressed_grids);
183
+ SECTION (" Check compressed grid sizes" ) {
184
+ REQUIRE (compressed_grids[io_logical_type.index ].compressed_to_grid_x [0 ].size () == 100 );
185
+ REQUIRE (compressed_grids[io_logical_type.index ].compressed_to_grid_y [0 ].size () == 100 );
186
+
187
+ REQUIRE (compressed_grids[small_logical_type.index ].compressed_to_grid_x [0 ].size () == 98 );
188
+ REQUIRE (compressed_grids[small_logical_type.index ].compressed_to_grid_y [0 ].size () == 98 );
152
189
153
- // SECTION("All routers are seperated by one or more grid spaces") {
154
- // // in this test, the routers will be on the 4 corners of the FPGA
155
- // }
190
+ REQUIRE (compressed_grids[tall_logical_type.index ].compressed_to_grid_x [0 ].size () == 9 );
191
+ REQUIRE (compressed_grids[tall_logical_type.index ].compressed_to_grid_y [0 ].size () == 18 );
192
+
193
+ REQUIRE (compressed_grids[large_logical_type.index ].compressed_to_grid_x [0 ].size () == 5 );
194
+ REQUIRE (compressed_grids[large_logical_type.index ].compressed_to_grid_y [0 ].size () == 7 );
195
+ }
196
+
197
+ SECTION (" Exact mapped locations in the compressed grids" ) {
198
+ t_physical_tile_loc comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({25 , 33 , 0 });
199
+ t_physical_tile_loc grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
200
+ REQUIRE (grid_loc == t_physical_tile_loc{25 , 33 , 0 });
201
+
202
+ comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({76 , 7 , 0 });
203
+ grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
204
+ REQUIRE (grid_loc == t_physical_tile_loc{76 , 7 , 0 });
205
+
206
+ comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({59 , 85 , 0 });
207
+ grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
208
+ REQUIRE (grid_loc == t_physical_tile_loc{59 , 85 , 0 });
209
+
210
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({7 , 5 , 0 });
211
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
212
+ REQUIRE (grid_loc == t_physical_tile_loc{7 , 5 , 0 });
213
+
214
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({77 , 40 , 0 });
215
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
216
+ REQUIRE (grid_loc == t_physical_tile_loc{77 , 40 , 0 });
217
+
218
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({37 , 85 , 0 });
219
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
220
+ REQUIRE (grid_loc == t_physical_tile_loc{37 , 85 , 0 });
221
+
222
+ comp_loc = compressed_grids[small_logical_type.index ].grid_loc_to_compressed_loc_approx ({2 , 3 , 0 });
223
+ grid_loc = compressed_grids[small_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
224
+ REQUIRE (grid_loc == t_physical_tile_loc{2 , 3 , 0 });
225
+
226
+ comp_loc = compressed_grids[small_logical_type.index ].grid_loc_to_compressed_loc_approx ({17 , 3 , 0 });
227
+ grid_loc = compressed_grids[small_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
228
+ REQUIRE (grid_loc == t_physical_tile_loc{17 , 3 , 0 });
229
+ }
230
+
231
+ SECTION (" Closest mapped location in the compressed grids" ) {
232
+ t_physical_tile_loc comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({25 , 33 , 0 });
233
+ t_physical_tile_loc grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
234
+ REQUIRE (grid_loc == t_physical_tile_loc{25 , 33 , 0 });
235
+
236
+ comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({99 , 10 , 0 });
237
+ grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
238
+ REQUIRE (grid_loc == t_physical_tile_loc{76 , 7 , 0 });
239
+
240
+ comp_loc = compressed_grids[large_logical_type.index ].grid_loc_to_compressed_loc_approx ({51 , 79 , 0 });
241
+ grid_loc = compressed_grids[large_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
242
+ REQUIRE (grid_loc == t_physical_tile_loc{59 , 85 , 0 });
243
+
244
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({1 , 6 , 0 });
245
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
246
+ REQUIRE (grid_loc == t_physical_tile_loc{7 , 5 , 0 });
247
+
248
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({81 , 38 , 0 });
249
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
250
+ REQUIRE (grid_loc == t_physical_tile_loc{77 , 40 , 0 });
251
+
252
+ comp_loc = compressed_grids[tall_logical_type.index ].grid_loc_to_compressed_loc_approx ({34 , 83 , 0 });
253
+ grid_loc = compressed_grids[tall_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
254
+ REQUIRE (grid_loc == t_physical_tile_loc{37 , 85 , 0 });
255
+
256
+ comp_loc = compressed_grids[small_logical_type.index ].grid_loc_to_compressed_loc_approx ({0 , 0 , 0 });
257
+ grid_loc = compressed_grids[small_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
258
+ REQUIRE (grid_loc == t_physical_tile_loc{1 , 1 , 0 });
259
+
260
+ comp_loc = compressed_grids[small_logical_type.index ].grid_loc_to_compressed_loc_approx ({99 , 99 , 0 });
261
+ grid_loc = compressed_grids[small_logical_type.index ].compressed_loc_to_grid_loc (comp_loc);
262
+ REQUIRE (grid_loc == t_physical_tile_loc{98 , 98 , 0 });
263
+ }
156
264
157
265
}
158
266
0 commit comments