1212
1313#pragma once
1414
15+ #include < cmath>
1516#include " ap_netlist.h"
17+ #include " physical_types.h"
1618#include " vtr_vector.h"
1719
1820/* *
@@ -94,6 +96,44 @@ struct PartialPlacement {
9496 }
9597 }
9698
99+ /* *
100+ * @brief Get the location of the physical tile that contains the given
101+ * AP block.
102+ *
103+ * VTR uses an integer grid. In AP, we consider a tile at (1,1) to be
104+ * centered at (1.5,1.5). When converting from doubles back to integer
105+ * tiles, we simply take the floor, so the tile above would receive all
106+ * points from [(1,1) to (2,2)). When converting fixed blocks from the
107+ * integral VPR grid to the AP locations, we should therefore add (0.5,0.5)
108+ * to them so they are centered in their grid tiles (assuming the tiles are
109+ * 1x1).
110+ *
111+ * FIXME: Ideally this should return an ID to the tile, not a location.
112+ * This is important since there is a distinction between the two.
113+ * We know a block will be at that tile, but it would not be at the
114+ * corner of the block (likely it would be at the center).
115+ */
116+ inline t_physical_tile_loc get_containing_tile_loc (APBlockId blk_id) const {
117+ // We take the floor here since we want to know which tile contains this
118+ // block. On a grid, if the block is located at x=0.99999, it would still
119+ // be in the first tile. This is because we assume that the blocks will
120+ // ultimately end up in the center of the tile, not at the top left
121+ // corner of it. The physical tile loc is just a way of identifying that
122+ // tile.
123+ // TODO: This may be a bit more complicated than this. This assumes that
124+ // all tiles are 1x1, but it could be the case that this is on
125+ // the edge of a much larger block. In reality this should try
126+ // to go into the tile where it is closest to the center. What
127+ // is written here is not necessarily wrong, but it may put blocks
128+ // which on are the edge of large blocks into the large blocks.
129+ // However, this may not even matter if the partial legalizer is
130+ // doing its job!
131+ int tile_x_loc = std::floor (block_x_locs[blk_id]);
132+ int tile_y_loc = std::floor (block_y_locs[blk_id]);
133+ int tile_layer = std::floor (block_layer_nums[blk_id]);
134+ return t_physical_tile_loc (tile_x_loc, tile_y_loc, tile_layer);
135+ }
136+
97137 /* *
98138 * @brief Verify the block_x_locs and block_y_locs vectors
99139 *
@@ -108,7 +148,7 @@ struct PartialPlacement {
108148 */
109149 bool verify_locs (const APNetlist& netlist,
110150 size_t grid_width,
111- size_t grid_height );
151+ size_t grid_height) const ;
112152
113153 /* *
114154 * @brief Verify the block_layer_nums vector
@@ -121,7 +161,8 @@ struct PartialPlacement {
121161 * @param netlist The APNetlist used to generate this placement
122162 * @param grid_num_layers The number of layers in the device grid
123163 */
124- bool verify_layer_nums (const APNetlist & netlist , size_t grid_num_layers );
164+ bool verify_layer_nums (const APNetlist& netlist,
165+ size_t grid_num_layers) const ;
125166
126167 /* *
127168 * @brief Verify the sub_tiles
@@ -131,7 +172,7 @@ struct PartialPlacement {
131172 *
132173 * @param netlist The APNetlist used to generate this placement
133174 */
134- bool verify_sub_tiles (const APNetlist & netlist );
175+ bool verify_sub_tiles (const APNetlist& netlist) const ;
135176
136177 /* *
137178 * @brief Verify the entire partial placement object
@@ -146,6 +187,6 @@ struct PartialPlacement {
146187 bool verify (const APNetlist& netlist,
147188 size_t grid_width,
148189 size_t grid_height,
149- size_t grid_num_layers );
190+ size_t grid_num_layers) const ;
150191};
151192
0 commit comments