Skip to content

Commit 1ecf07c

Browse files
add blk_loc_registry.cpp/.h
1 parent a6ffb7b commit 1ecf07c

File tree

9 files changed

+101
-49
lines changed

9 files changed

+101
-49
lines changed

vpr/src/base/blk_loc_registry.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
#include "blk_loc_registry.h"
3+
#include "globals.h"
4+
5+
const vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::block_locs() const {
6+
return block_locs_;
7+
}
8+
9+
vtr::vector_map<ClusterBlockId, t_block_loc>& BlkLocRegistry::mutable_block_locs() {
10+
return block_locs_;
11+
}
12+
13+
const GridBlock& BlkLocRegistry::grid_blocks() const {
14+
return grid_blocks_;
15+
}
16+
17+
GridBlock& BlkLocRegistry::mutable_grid_blocks() {
18+
return grid_blocks_;
19+
}
20+
21+
const vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::physical_pins() const {
22+
return physical_pins_;
23+
}
24+
25+
vtr::vector_map<ClusterPinId, int>& BlkLocRegistry::mutable_physical_pins() {
26+
return physical_pins_;
27+
}
28+
29+
int BlkLocRegistry::tile_pin_index(const ClusterPinId pin) const {
30+
return physical_pins_[pin];
31+
}
32+
33+
int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const {
34+
auto& cluster_ctx = g_vpr_ctx.clustering();
35+
36+
// Get the logical pin index of pin within its logical block type
37+
ClusterPinId pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index);
38+
39+
return this->tile_pin_index(pin_id);
40+
}

vpr/src/base/blk_loc_registry.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#ifndef VTR_BLK_LOC_REGISTRY_H
2+
#define VTR_BLK_LOC_REGISTRY_H
3+
4+
#include "clustered_netlist_fwd.h"
5+
#include "vtr_vector_map.h"
6+
#include "vpr_types.h"
7+
8+
struct t_block_loc;
9+
10+
class BlkLocRegistry {
11+
public:
12+
BlkLocRegistry() = default;
13+
~BlkLocRegistry() = default;
14+
BlkLocRegistry(const BlkLocRegistry&) = delete;
15+
BlkLocRegistry& operator=(const BlkLocRegistry&) = default;
16+
BlkLocRegistry(BlkLocRegistry&&) = delete;
17+
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;
18+
19+
private:
20+
///@brief Clustered block placement locations
21+
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;
22+
23+
///@brief Clustered block associated with each grid location (i.e. inverse of block_locs)
24+
GridBlock grid_blocks_;
25+
26+
///@brief Clustered pin placement mapping with physical pin
27+
vtr::vector_map<ClusterPinId, int> physical_pins_;
28+
29+
public:
30+
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const;
31+
vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs();
32+
33+
const GridBlock& grid_blocks() const;
34+
GridBlock& mutable_grid_blocks();
35+
36+
const vtr::vector_map<ClusterPinId, int>& physical_pins() const;
37+
vtr::vector_map<ClusterPinId, int>& mutable_physical_pins();
38+
39+
///@brief Returns the physical pin of the tile, related to the given ClusterPinId
40+
int tile_pin_index(const ClusterPinId pin) const;
41+
42+
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
43+
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
44+
};
45+
46+
#endif //VTR_BLK_LOC_REGISTRY_H

vpr/src/base/vpr_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "noc_traffic_flows.h"
3434
#include "noc_routing.h"
3535
#include "tatum/report/TimingPath.hpp"
36+
#include "blk_loc_registry.h"
3637

3738
#ifndef NO_SERVER
3839

vpr/src/base/vpr_types.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,3 @@ void t_cluster_placement_stats::free_primitives() {
558558
}
559559
}
560560
}
561-
562-
int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const {
563-
auto& cluster_ctx = g_vpr_ctx.clustering();
564-
565-
// Get the logical pin index of pin within its logical block type
566-
ClusterPinId pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index);
567-
568-
return this->tile_pin_index(pin_id);
569-
}

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -907,41 +907,6 @@ class GridBlock {
907907
vtr::NdMatrix<t_grid_blocks, 3> grid_blocks_;
908908
};
909909

910-
class BlkLocRegistry {
911-
public:
912-
BlkLocRegistry() = default;
913-
~BlkLocRegistry() = default;
914-
BlkLocRegistry(const BlkLocRegistry&) = delete;
915-
BlkLocRegistry& operator=(const BlkLocRegistry&) = default;
916-
BlkLocRegistry(BlkLocRegistry&&) = delete;
917-
BlkLocRegistry& operator=(BlkLocRegistry&&) = delete;
918-
919-
private:
920-
///@brief Clustered block placement locations
921-
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs_;
922-
923-
///@brief Clustered block associated with each grid location (i.e. inverse of block_locs)
924-
GridBlock grid_blocks_;
925-
926-
///@brief Clustered pin placement mapping with physical pin
927-
vtr::vector_map<ClusterPinId, int> physical_pins_;
928-
929-
public:
930-
inline const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs() const { return block_locs_; }
931-
inline vtr::vector_map<ClusterBlockId, t_block_loc>& mutable_block_locs() { return block_locs_; }
932-
933-
inline const GridBlock& grid_blocks() const { return grid_blocks_; }
934-
inline GridBlock& mutable_grid_blocks() { return grid_blocks_; }
935-
936-
inline const vtr::vector_map<ClusterPinId, int>& physical_pins() const { return physical_pins_; }
937-
inline vtr::vector_map<ClusterPinId, int>& mutable_physical_pins() { return physical_pins_; }
938-
939-
///@brief Returns the physical pin of the tile, related to the given ClusterPinId
940-
inline int tile_pin_index(const ClusterPinId pin) const { return physical_pins_[pin]; }
941-
942-
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
943-
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
944-
};
945910

946911
///@brief Names of various files
947912
struct t_file_name_opts {

vpr/src/place/initial_noc_placement.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
#include "initial_noc_placment.h"
3+
4+
#include "vpr_types.h"
35
#include "initial_placement.h"
46
#include "noc_place_utils.h"
57
#include "noc_place_checkpoint.h"

vpr/src/place/initial_noc_placment.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

2-
#ifndef VTR_INITIAL_NOC_PLACMENT_H
3-
#define VTR_INITIAL_NOC_PLACMENT_H
2+
#ifndef VTR_INITIAL_NOC_PLACEMENT_H
3+
#define VTR_INITIAL_NOC_PLACEMENT_H
44

5-
#include "vpr_types.h"
5+
struct t_noc_opts;
6+
struct t_placer_opts;
7+
class BlkLocRegistry;
68

79
/**
810
* @brief Randomly places NoC routers, then runs a quick simulated annealing
@@ -17,4 +19,4 @@ void initial_noc_placement(const t_noc_opts& noc_opts,
1719
const t_placer_opts& placer_opts,
1820
BlkLocRegistry& blk_loc_registry);
1921

20-
#endif //VTR_INITIAL_NOC_PLACMENT_H
22+
#endif //VTR_INITIAL_NOC_PLACEMENT_H

vpr/src/place/move_transactions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifndef VPR_MOVE_TRANSACTIONS_H
22
#define VPR_MOVE_TRANSACTIONS_H
3+
34
#include "vpr_types.h"
45
#include "clustered_netlist_utils.h"
56

7+
class BlkLocRegistry;
8+
69
enum class e_block_move_result {
710
VALID, //Move successful
811
ABORT, //Unable to perform move
@@ -30,7 +33,7 @@ struct t_pl_moved_block {
3033
* placement. *
3134
* Store the information on the blocks to be moved in a swap during *
3235
* placement, in the form of array of structs instead of struct with *
33-
* arrays for cache effifiency *
36+
* arrays for cache efficiency *
3437
*
3538
* moved blocks: a list of moved blocks data structure with *
3639
* information on the move. *

vpr/src/place/move_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#ifndef VPR_MOVE_UTILS_H
22
#define VPR_MOVE_UTILS_H
3+
34
#include "vpr_types.h"
45
#include "move_transactions.h"
56
#include "compressed_grid.h"
67

78
class PlacerState;
9+
class BlkLocRegistry;
810

911
/* Cut off for incremental bounding box updates. *
1012
* 4 is fastest -- I checked. */

0 commit comments

Comments
 (0)