|
9 | 9 |
|
10 | 10 | /** |
11 | 11 | * @brief s_grid_tile is the minimum tile of the fpga |
12 | | - * @note This struct shouldn't be directly accessed by other functions. Use helper function in DeviceGrid instead. |
| 12 | + * @note This struct shouldn't be directly accessed by other functions. Use the helper functions in DeviceGrid instead. |
13 | 13 | */ |
14 | 14 | struct t_grid_tile { |
15 | 15 | t_physical_tile_type_ptr type = nullptr; ///<Pointer to type descriptor, NULL for illegal |
@@ -38,32 +38,12 @@ class DeviceGrid { |
38 | 38 | ///@brief Return the height of the grid at the specified layer |
39 | 39 | size_t height() const { return grid_.dim_size(2); } |
40 | 40 |
|
41 | | - ///@brief Given t_grid_tile, return the x coordinate of the tile on the given layer |
42 | | - inline int get_grid_loc_x(const t_grid_tile*& grid_loc) const { |
43 | | - int layer_num = std::floor(static_cast<int>(grid_loc - &grid_.get(0)) / (width() * height())); |
44 | | - auto diff = grid_loc - &grid_.get(layer_num * height() * width()); |
45 | | - |
46 | | - return diff / grid_.dim_size(2); |
47 | | - } |
48 | | - |
49 | | - ///@brief Given t_grid_tile, return the y coordinate of the tile on the given layer |
50 | | - inline int get_grid_loc_y(const t_grid_tile*& grid_loc) const { |
51 | | - int layer_num = std::floor(static_cast<int>(grid_loc - &grid_.get(0)) / (width() * height())); |
52 | | - auto diff = grid_loc - &grid_.get(layer_num * height() * width()); |
53 | | - |
54 | | - return diff % grid_.dim_size(2); |
55 | | - } |
56 | | - |
57 | | - ///@brief Return the nth t_grid_tile on the given layer of the flattened grid |
58 | | - inline const t_grid_tile* get_grid_locs_grid_loc(int n) const { |
59 | | - return &grid_.get(n); |
60 | | - } |
61 | | - |
62 | 41 | ///@brief Return the size of the flattened grid on the given layer |
63 | 42 | inline size_t grid_size() const { |
64 | 43 | return grid_.size(); |
65 | 44 | } |
66 | 45 |
|
| 46 | + ///@brief deallocate members of DeviceGrid |
67 | 47 | void clear(); |
68 | 48 |
|
69 | 49 | /** |
@@ -98,20 +78,41 @@ class DeviceGrid { |
98 | 78 | return grid_[layer_num][x][y].meta; |
99 | 79 | } |
100 | 80 |
|
| 81 | + ///@brief Given t_grid_tile, return the x coordinate of the tile on the given layer - Used by serializer functions |
| 82 | + inline int get_grid_loc_x(const t_grid_tile*& grid_loc) const { |
| 83 | + int layer_num = std::floor(static_cast<int>(grid_loc - &grid_.get(0)) / (width() * height())); |
| 84 | + auto diff = grid_loc - &grid_.get(layer_num * height() * width()); |
| 85 | + |
| 86 | + return diff / grid_.dim_size(2); |
| 87 | + } |
| 88 | + |
| 89 | + ///@brief Given t_grid_tile, return the y coordinate of the tile on the given layer - Used by serializer functions |
| 90 | + inline int get_grid_loc_y(const t_grid_tile*& grid_loc) const { |
| 91 | + int layer_num = std::floor(static_cast<int>(grid_loc - &grid_.get(0)) / (width() * height())); |
| 92 | + auto diff = grid_loc - &grid_.get(layer_num * height() * width()); |
| 93 | + |
| 94 | + return diff % grid_.dim_size(2); |
| 95 | + } |
| 96 | + |
| 97 | + ///@brief Return the nth t_grid_tile on the given layer of the flattened grid - Used by serializer functions |
| 98 | + inline const t_grid_tile* get_grid_locs_grid_loc(int n) const { |
| 99 | + return &grid_.get(n); |
| 100 | + } |
| 101 | + |
101 | 102 | private: |
102 | 103 | ///@brief count_instances() counts the number of each tile type on each layer and store it in instance_counts_. It is called in the constructor. |
103 | 104 | void count_instances(); |
104 | 105 |
|
105 | 106 | std::string name_; |
106 | 107 |
|
107 | 108 | /** |
108 | | - * @brief grid_ is a of 3D grids. |
| 109 | + * @brief grid_ is a 3D matrix that represents the grid of the FPGA chip. |
109 | 110 | * @note The first dimension is the layer number (grid_[0] corresponds to the bottom layer), the second dimension is the x coordinate, and the third dimension is the y coordinate. |
110 | 111 | * @note Note that vtr::Matrix operator[] returns and intermediate type |
111 | | - * @note which can be used or indexing in the second dimension, allowing |
| 112 | + * @note which can be used for indexing in the second dimension, allowing |
112 | 113 | * @note traditional 2-d indexing to be used |
113 | 114 | */ |
114 | | - vtr::NdMatrix<t_grid_tile, 3> grid_; |
| 115 | + vtr::NdMatrix<t_grid_tile, 3> grid_; //This stores the grid of complex blocks. It is a a 3D matrix: [0..num_layers-1][0..grid.width()-1][0..grid_height()-1] |
115 | 116 |
|
116 | 117 | ///@brief instance_counts_ stores the number of each tile type on each layer. It is initialized in count_instances(). |
117 | 118 | std::vector<std::map<t_physical_tile_type_ptr, size_t>> instance_counts_; /* [layer_num][physical_tile_type_ptr] */ |
|
0 commit comments