Skip to content

Commit 3b67601

Browse files
add grid_block.h
1 parent 1ecf07c commit 3b67601

File tree

5 files changed

+93
-74
lines changed

5 files changed

+93
-74
lines changed

vpr/src/base/blk_loc_registry.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44
#include "clustered_netlist_fwd.h"
55
#include "vtr_vector_map.h"
66
#include "vpr_types.h"
7+
#include "grid_block.h"
78

89
struct t_block_loc;
910

11+
/**
12+
* @class BlkLocRegistry contains information about the placement of clustered blocks.
13+
* More specifically:
14+
* 1) block_locs stores the location where each clustered blocks is placed at.
15+
* 2) grid_blocks stores which blocks (if any) are placed at a given location.
16+
* 3) physical_pins stores the mapping between the pins of a clustered block and
17+
* the pins of the physical tile where the clustered blocks is placed.
18+
*
19+
*/
1020
class BlkLocRegistry {
1121
public:
1222
BlkLocRegistry() = default;

vpr/src/base/grid_block.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#ifndef VTR_GRID_BLOCK_H
2+
#define VTR_GRID_BLOCK_H
3+
4+
#include "clustered_netlist_fwd.h"
5+
#include "physical_types.h"
6+
#include "vpr_types.h"
7+
8+
#include <vector>
9+
10+
/* Defining macros for the placement_ctx t_grid_blocks. Assumes that ClusterBlockId's won't exceed positive 32-bit integers */
11+
constexpr auto EMPTY_BLOCK_ID = ClusterBlockId(-1);
12+
constexpr auto INVALID_BLOCK_ID = ClusterBlockId(-2);
13+
14+
///@brief Stores the clustered blocks placed at a particular grid location
15+
struct t_grid_blocks {
16+
int usage; ///<How many valid blocks are in use at this location
17+
18+
/**
19+
* @brief The clustered blocks associated with this grid location.
20+
*
21+
* Index range: [0..device_ctx.grid[x_loc][y_loc].type->capacity]
22+
*/
23+
std::vector<ClusterBlockId> blocks;
24+
25+
/**
26+
* @brief Test if a subtile at a grid location is occupied by a block.
27+
*
28+
* Returns true if the subtile corresponds to the passed-in id is not
29+
* occupied by a block at this grid location. The subtile id serves
30+
* as the z-dimensional offset in the grid indexing.
31+
*/
32+
inline bool subtile_empty(size_t isubtile) const {
33+
return blocks[isubtile] == EMPTY_BLOCK_ID;
34+
}
35+
};
36+
37+
class GridBlock {
38+
public:
39+
GridBlock() = default;
40+
41+
GridBlock(size_t width, size_t height, size_t layers) {
42+
grid_blocks_.resize({layers, width, height});
43+
}
44+
45+
inline void initialized_grid_block_at_location(const t_physical_tile_loc& loc, int num_sub_tiles) {
46+
grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.resize(num_sub_tiles, EMPTY_BLOCK_ID);
47+
}
48+
49+
inline void set_block_at_location(const t_pl_loc& loc, ClusterBlockId blk_id) {
50+
grid_blocks_[loc.layer][loc.x][loc.y].blocks[loc.sub_tile] = blk_id;
51+
}
52+
53+
inline ClusterBlockId block_at_location(const t_pl_loc& loc) const {
54+
return grid_blocks_[loc.layer][loc.x][loc.y].blocks[loc.sub_tile];
55+
}
56+
57+
inline size_t num_blocks_at_location(const t_physical_tile_loc& loc) const {
58+
return grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.size();
59+
}
60+
61+
inline int set_usage(const t_physical_tile_loc loc, int usage) {
62+
return grid_blocks_[loc.layer_num][loc.x][loc.y].usage = usage;
63+
}
64+
65+
inline int get_usage(const t_physical_tile_loc loc) const {
66+
return grid_blocks_[loc.layer_num][loc.x][loc.y].usage;
67+
}
68+
69+
inline bool is_sub_tile_empty(const t_physical_tile_loc loc, int sub_tile) const {
70+
return grid_blocks_[loc.layer_num][loc.x][loc.y].subtile_empty(sub_tile);
71+
}
72+
73+
inline void clear() {
74+
grid_blocks_.clear();
75+
}
76+
77+
private:
78+
vtr::NdMatrix<t_grid_blocks, 3> grid_blocks_;
79+
};
80+
81+
#endif //VTR_GRID_BLOCK_H

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ enum class ScreenUpdatePriority {
9595
/* Used to avoid floating-point errors when comparing values close to 0 */
9696
#define EPSILON 1.e-15
9797

98-
#define FIRST_ITER_WIRELENTH_LIMIT 0.85 /* If used wirelength exceeds this value in first iteration of routing, do not route */
99-
100-
/* Defining macros for the placement_ctx t_grid_blocks. Assumes that ClusterBlockId's won't exceed positive 32-bit integers */
101-
constexpr auto EMPTY_BLOCK_ID = ClusterBlockId(-1);
102-
constexpr auto INVALID_BLOCK_ID = ClusterBlockId(-2);
103-
10498
/*
10599
* Files
106100
*/
@@ -840,74 +834,6 @@ struct t_block_loc {
840834
bool is_fixed = false;
841835
};
842836

843-
///@brief Stores the clustered blocks placed at a particular grid location
844-
struct t_grid_blocks {
845-
int usage; ///<How many valid blocks are in use at this location
846-
847-
/**
848-
* @brief The clustered blocks associated with this grid location.
849-
*
850-
* Index range: [0..device_ctx.grid[x_loc][y_loc].type->capacity]
851-
*/
852-
std::vector<ClusterBlockId> blocks;
853-
854-
/**
855-
* @brief Test if a subtile at a grid location is occupied by a block.
856-
*
857-
* Returns true if the subtile corresponds to the passed-in id is not
858-
* occupied by a block at this grid location. The subtile id serves
859-
* as the z-dimensional offset in the grid indexing.
860-
*/
861-
inline bool subtile_empty(size_t isubtile) const {
862-
return blocks[isubtile] == EMPTY_BLOCK_ID;
863-
}
864-
};
865-
866-
class GridBlock {
867-
public:
868-
GridBlock() = default;
869-
870-
GridBlock(size_t width, size_t height, size_t layers) {
871-
grid_blocks_.resize({layers, width, height});
872-
}
873-
874-
inline void initialized_grid_block_at_location(const t_physical_tile_loc& loc, int num_sub_tiles) {
875-
grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.resize(num_sub_tiles, EMPTY_BLOCK_ID);
876-
}
877-
878-
inline void set_block_at_location(const t_pl_loc& loc, ClusterBlockId blk_id) {
879-
grid_blocks_[loc.layer][loc.x][loc.y].blocks[loc.sub_tile] = blk_id;
880-
}
881-
882-
inline ClusterBlockId block_at_location(const t_pl_loc& loc) const {
883-
return grid_blocks_[loc.layer][loc.x][loc.y].blocks[loc.sub_tile];
884-
}
885-
886-
inline size_t num_blocks_at_location(const t_physical_tile_loc& loc) const {
887-
return grid_blocks_[loc.layer_num][loc.x][loc.y].blocks.size();
888-
}
889-
890-
inline int set_usage(const t_physical_tile_loc loc, int usage) {
891-
return grid_blocks_[loc.layer_num][loc.x][loc.y].usage = usage;
892-
}
893-
894-
inline int get_usage(const t_physical_tile_loc loc) const {
895-
return grid_blocks_[loc.layer_num][loc.x][loc.y].usage;
896-
}
897-
898-
inline bool is_sub_tile_empty(const t_physical_tile_loc loc, int sub_tile) const {
899-
return grid_blocks_[loc.layer_num][loc.x][loc.y].subtile_empty(sub_tile);
900-
}
901-
902-
inline void clear() {
903-
grid_blocks_.clear();
904-
}
905-
906-
private:
907-
vtr::NdMatrix<t_grid_blocks, 3> grid_blocks_;
908-
};
909-
910-
911837
///@brief Names of various files
912838
struct t_file_name_opts {
913839
std::string ArchFile;

vpr/src/place/move_transactions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "globals.h"
55
#include "place_util.h"
6+
#include "grid_block.h"
67
#include "vtr_assert.h"
78

89
t_pl_blocks_to_be_moved::t_pl_blocks_to_be_moved(size_t max_blocks){

vpr/src/place/move_transactions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "clustered_netlist_utils.h"
66

77
class BlkLocRegistry;
8+
class GridBlock;
89

910
enum class e_block_move_result {
1011
VALID, //Move successful

0 commit comments

Comments
 (0)