Skip to content

Commit e20ede4

Browse files
committed
equivalent: delete physical_tile_type(t_logical_block_type) function
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent f30bed6 commit e20ede4

File tree

11 files changed

+102
-72
lines changed

11 files changed

+102
-72
lines changed

vpr/src/base/SetupGrid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ float calculate_device_utilization(const DeviceGrid& grid, std::map<t_logical_bl
668668
continue;
669669
}
670670

671-
t_physical_tile_type_ptr type = physical_tile_type(kv.first);
671+
t_physical_tile_type_ptr type = pick_random_physical_type(kv.first);
672672

673673
size_t count = kv.second;
674674

vpr/src/base/check_netlist.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ static int check_connections_to_global_clb_pins(ClusterNetId net_id, int verbosi
9191
int global_to_non_global_connection_count = 0;
9292
for (auto pin_id : cluster_ctx.clb_nlist.net_pins(net_id)) {
9393
ClusterBlockId blk_id = cluster_ctx.clb_nlist.pin_block(pin_id);
94-
int pin_index = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
95-
9694
auto logical_type = cluster_ctx.clb_nlist.block_type(blk_id);
97-
auto physical_type = physical_tile_type(logical_type);
95+
auto physical_type = pick_random_physical_type(logical_type);
96+
97+
int log_index = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
98+
int pin_index = get_physical_pin(physical_type, logical_type, log_index);
99+
98100
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored
99-
&& !is_io_type(physical_tile_type(logical_type))) {
101+
&& !is_io_type(physical_type)) {
100102
VTR_LOGV_WARN(verbosity > 2,
101103
"Global net '%s' connects to non-global architecture pin '%s' (netlist pin '%s')\n",
102104
cluster_ctx.clb_nlist.net_name(net_id).c_str(),

vpr/src/base/clustered_netlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int ClusteredNetlist::block_pin_net_index(const ClusterBlockId blk_id, const int
5252

5353
ClusterPinId ClusteredNetlist::block_pin(const ClusterBlockId blk, const int phys_pin_index) const {
5454
VTR_ASSERT_SAFE(valid_block_id(blk));
55-
VTR_ASSERT_SAFE_MSG(phys_pin_index >= 0 && phys_pin_index < physical_tile_type(block_type(blk))->num_pins, "Physical pin index must be in range");
55+
VTR_ASSERT_SAFE_MSG(phys_pin_index >= 0 && phys_pin_index < pick_random_physical_type(block_type(blk))->num_pins, "Physical pin index must be in range");
5656

5757
return block_logical_pins_[blk][phys_pin_index];
5858
}

vpr/src/base/read_netlist.cpp

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,6 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
860860

861861
ext_nhash = alloc_hash_table();
862862

863-
t_physical_tile_type_ptr tile_type;
864863
t_logical_block_type_ptr block_type;
865864

866865
/* Assumes that complex block pins are ordered inputs, outputs, globals */
@@ -951,43 +950,44 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
951950
for (auto blk_id : clb_nlist.blocks()) {
952951
block_type = clb_nlist.block_type(blk_id);
953952
// XXX Use pin mapping here! To check that all the possible pins can be used in the correct tile!
954-
tile_type = physical_tile_type(block_type);
955-
for (j = 0; j < tile_type->num_pins; j++) {
956-
//Iterate through each pin of the block, and see if there is a net allocated/used for it
957-
clb_net_id = clb_nlist.block_net(blk_id, j);
958-
959-
if (clb_net_id != ClusterNetId::INVALID()) {
960-
//Verify old and new CLB netlists have the same # of pins per net
961-
if (RECEIVER == tile_type->class_inf[tile_type->pin_class[j]].type) {
962-
count[clb_net_id]++;
963-
964-
if (count[clb_net_id] > (int)clb_nlist.net_sinks(clb_net_id).size()) {
965-
VPR_FATAL_ERROR(VPR_ERROR_NET_F,
966-
"net %s #%d inconsistency, expected %d terminals but encountered %d terminals, it is likely net terminal is disconnected in netlist file.\n",
967-
clb_nlist.net_name(clb_net_id).c_str(), size_t(clb_net_id), count[clb_net_id],
968-
clb_nlist.net_sinks(clb_net_id).size());
969-
}
953+
for (const auto& tile_type : block_type->equivalent_tiles) {
954+
for (j = 0; j < tile_type->num_pins; j++) {
955+
//Iterate through each pin of the block, and see if there is a net allocated/used for it
956+
clb_net_id = clb_nlist.block_net(blk_id, j);
970957

971-
//Asserts the ClusterBlockId is the same when ClusterNetId & pin BitIndex is provided
972-
VTR_ASSERT(blk_id == clb_nlist.pin_block(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
973-
//Asserts the block's pin index is the same
974-
VTR_ASSERT(j == clb_nlist.pin_physical_index(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
975-
VTR_ASSERT(j == clb_nlist.net_pin_physical_index(clb_net_id, count[clb_net_id]));
958+
if (clb_net_id != ClusterNetId::INVALID()) {
959+
//Verify old and new CLB netlists have the same # of pins per net
960+
if (RECEIVER == tile_type->class_inf[tile_type->pin_class[j]].type) {
961+
count[clb_net_id]++;
976962

977-
// nets connecting to global pins are marked as global nets
978-
if (tile_type->is_pin_global[j]) {
979-
clb_nlist.set_net_is_global(clb_net_id, true);
980-
}
963+
if (count[clb_net_id] > (int)clb_nlist.net_sinks(clb_net_id).size()) {
964+
VPR_FATAL_ERROR(VPR_ERROR_NET_F,
965+
"net %s #%d inconsistency, expected %d terminals but encountered %d terminals, it is likely net terminal is disconnected in netlist file.\n",
966+
clb_nlist.net_name(clb_net_id).c_str(), size_t(clb_net_id), count[clb_net_id],
967+
clb_nlist.net_sinks(clb_net_id).size());
968+
}
981969

982-
if (tile_type->is_ignored_pin[j]) {
983-
clb_nlist.set_net_is_ignored(clb_net_id, true);
984-
}
985-
/* Error check performed later to ensure no mixing of ignored and non ignored signals */
970+
//Asserts the ClusterBlockId is the same when ClusterNetId & pin BitIndex is provided
971+
VTR_ASSERT(blk_id == clb_nlist.pin_block(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
972+
//Asserts the block's pin index is the same
973+
VTR_ASSERT(j == clb_nlist.pin_physical_index(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
974+
VTR_ASSERT(j == clb_nlist.net_pin_physical_index(clb_net_id, count[clb_net_id]));
986975

987-
} else {
988-
VTR_ASSERT(DRIVER == tile_type->class_inf[tile_type->pin_class[j]].type);
989-
VTR_ASSERT(j == clb_nlist.pin_physical_index(*(clb_nlist.net_pins(clb_net_id).begin())));
990-
VTR_ASSERT(j == clb_nlist.net_pin_physical_index(clb_net_id, 0));
976+
// nets connecting to global pins are marked as global nets
977+
if (tile_type->is_pin_global[j]) {
978+
clb_nlist.set_net_is_global(clb_net_id, true);
979+
}
980+
981+
if (tile_type->is_ignored_pin[j]) {
982+
clb_nlist.set_net_is_ignored(clb_net_id, true);
983+
}
984+
/* Error check performed later to ensure no mixing of ignored and non ignored signals */
985+
986+
} else {
987+
VTR_ASSERT(DRIVER == tile_type->class_inf[tile_type->pin_class[j]].type);
988+
VTR_ASSERT(j == clb_nlist.pin_physical_index(*(clb_nlist.net_pins(clb_net_id).begin())));
989+
VTR_ASSERT(j == clb_nlist.net_pin_physical_index(clb_net_id, 0));
990+
}
991991
}
992992
}
993993
}
@@ -999,8 +999,11 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
999999
for (auto pin_id : clb_nlist.net_sinks(net_id)) {
10001000
bool is_ignored_net = clb_nlist.net_is_ignored(net_id);
10011001
block_type = clb_nlist.block_type(clb_nlist.pin_block(pin_id));
1002-
tile_type = physical_tile_type(block_type);
1003-
if (tile_type->is_ignored_pin[clb_nlist.pin_physical_index(pin_id)] != is_ignored_net) {
1002+
auto tile_type = pick_random_physical_type(block_type);
1003+
int log_pin = clb_nlist.pin_logical_index(pin_id);
1004+
int phy_pin = get_physical_pin(tile_type, block_type, log_pin);
1005+
1006+
if (tile_type->is_ignored_pin[phy_pin] != is_ignored_net) {
10041007
VTR_LOG_WARN(
10051008
"Netlist connects net %s to both global and non-global pins.\n",
10061009
clb_nlist.net_name(net_id).c_str());

vpr/src/base/read_place.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void read_user_pad_loc(const char* pad_loc_file) {
161161
hash_table = alloc_hash_table();
162162
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
163163
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
164-
if (is_io_type(physical_tile_type(logical_block))) {
164+
if (is_io_type(pick_random_physical_type(logical_block))) {
165165
insert_in_hash_table(hash_table, cluster_ctx.clb_nlist.block_name(blk_id).c_str(), size_t(blk_id));
166166
place_ctx.block_locs[blk_id].loc.x = OPEN; /* Mark as not seen yet. */
167167
}
@@ -268,7 +268,7 @@ void read_user_pad_loc(const char* pad_loc_file) {
268268

269269
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
270270
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
271-
auto type = physical_tile_type(logical_block);
271+
auto type = pick_random_physical_type(logical_block);
272272
if (is_io_type(type) && place_ctx.block_locs[blk_id].loc.x == OPEN) {
273273
vpr_throw(VPR_ERROR_PLACE_F, pad_loc_file, 0,
274274
"IO block %s location was not specified in the pad file.\n", cluster_ctx.clb_nlist.block_name(blk_id).c_str());

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,11 +2730,9 @@ void deselect_all() {
27302730
static void draw_reset_blk_color(ClusterBlockId blk_id) {
27312731
auto& cluster_ctx = g_vpr_ctx.clustering();
27322732

2733-
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
2734-
27352733
t_draw_state* draw_state = get_draw_state_vars();
27362734

2737-
draw_state->block_color[blk_id] = get_block_type_color(physical_tile_type(logical_block));
2735+
draw_state->block_color[blk_id] = get_block_type_color(physical_tile_type(blk_id));
27382736
}
27392737

27402738
/**

vpr/src/place/initial_placement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static void initial_placement_blocks(int* free_locations, enum e_pad_loc_type pa
273273
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
274274

275275
/* Don't do IOs if the user specifies IOs; we'll read those locations later. */
276-
if (!(is_io_type(physical_tile_type(logical_block)) && pad_loc_type == USER)) {
276+
if (!(is_io_type(pick_random_physical_type(logical_block)) && pad_loc_type == USER)) {
277277
/* Randomly select a free location of the appropriate type for blk_id.
278278
* We have a linearized list of all the free locations that can
279279
* accommodate a block of that type in free_locations[itype].
@@ -304,7 +304,7 @@ static void initial_placement_blocks(int* free_locations, enum e_pad_loc_type pa
304304
place_ctx.block_locs[blk_id].loc = to;
305305

306306
//Mark IOs as fixed if specifying a (fixed) random placement
307-
if (is_io_type(physical_tile_type(logical_block)) && pad_loc_type == RANDOM) {
307+
if (is_io_type(pick_random_physical_type(logical_block)) && pad_loc_type == RANDOM) {
308308
place_ctx.block_locs[blk_id].is_fixed = true;
309309
}
310310

vpr/src/place/uniform_move_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ e_create_move UniformMoveGenerator::propose_move(t_pl_blocks_to_be_moved& blocks
1818

1919
t_pl_loc to;
2020

21-
auto type = pick_random_placement_type(cluster_from_type);
21+
auto type = pick_random_physical_type(cluster_from_type);
2222

2323
if (!find_to_loc_uniform(type, rlim, from, to)) {
2424
return e_create_move::ABORT;

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,10 +1032,7 @@ static vtr::vector<ClusterNetId, std::vector<int>> load_net_rr_terminals(const t
10321032
* are offset to get their actual rr_node */
10331033
node_block_pin = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
10341034

1035-
auto pin_directs_map = type->tile_block_pin_directs_map;
1036-
auto map = pin_directs_map[logical_block->index];
1037-
1038-
auto orig_phys_pin = map[t_logical_pin(node_block_pin)].pin;
1035+
int orig_phys_pin = get_physical_pin(type, logical_block, node_block_pin);
10391036

10401037
VTR_ASSERT(type->num_pins % type->capacity == 0);
10411038
int max_num_block_pins = type->num_pins / type->capacity;

vpr/src/util/vpr_utils.cpp

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ std::vector<AtomPinId> find_clb_pin_connected_atom_pins(ClusterBlockId clb, int
318318

319319
auto logical_block = clb_nlist.block_type(clb);
320320

321-
if (is_opin(log_pin, physical_tile_type(logical_block))) {
321+
if (is_opin(log_pin, pick_random_physical_type(logical_block))) {
322322
//output
323323
AtomPinId driver = find_clb_pin_driver_atom_pin(clb, log_pin, pb_gpin_lookup);
324324
if (driver) {
@@ -624,20 +624,6 @@ bool is_empty_type(t_logical_block_type_ptr type) {
624624
return type == device_ctx.EMPTY_LOGICAL_BLOCK_TYPE;
625625
}
626626

627-
t_physical_tile_type_ptr physical_tile_type(t_logical_block_type_ptr logical_block_type) {
628-
auto& device_ctx = g_vpr_ctx.device();
629-
auto& physical_tiles = device_ctx.physical_tile_types;
630-
631-
// Loop through the ordered map to get tiles in a decreasing priority order
632-
for (auto& physical_tiles_ids : logical_block_type->physical_tiles_priority) {
633-
for (auto tile_id : physical_tiles_ids.second) {
634-
return &physical_tiles[tile_id];
635-
}
636-
}
637-
638-
VPR_THROW(VPR_ERROR_OTHER, "No corresponding physical tile type found for logical block type %s\n", logical_block_type->name);
639-
}
640-
641627
t_physical_tile_type_ptr physical_tile_type(ClusterBlockId blk) {
642628
auto& place_ctx = g_vpr_ctx.placement();
643629
auto& device_ctx = g_vpr_ctx.device();
@@ -2176,7 +2162,7 @@ bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_
21762162
return std::find(equivalent_tiles.begin(), equivalent_tiles.end(), physical_tile) != equivalent_tiles.end();
21772163
}
21782164

2179-
t_physical_tile_type_ptr pick_random_placement_type(t_logical_block_type_ptr logical_block) {
2165+
t_physical_tile_type_ptr pick_random_physical_type(t_logical_block_type_ptr logical_block) {
21802166
auto equivalent_tiles = logical_block->equivalent_tiles;
21812167

21822168
size_t num_equivalent_tiles = equivalent_tiles.size();
@@ -2189,6 +2175,44 @@ t_physical_tile_type_ptr pick_random_placement_type(t_logical_block_type_ptr log
21892175
return equivalent_tiles[index];
21902176
}
21912177

2178+
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
2179+
t_logical_block_type_ptr logical_block,
2180+
int pin) {
2181+
t_physical_pin physical_pin(pin);
2182+
2183+
auto direct_map = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
2184+
auto result = direct_map.find(physical_pin);
2185+
2186+
if (result == direct_map.inverse_end()) {
2187+
VTR_LOG_WARN(
2188+
"Couldn't find the corresponding logical pin of the physical pin %d."
2189+
"Physical Tile: %s, Logical Block: %s.\n",
2190+
pin, physical_tile->name, logical_block->name);
2191+
return OPEN;
2192+
}
2193+
2194+
return result->second.pin;
2195+
}
2196+
2197+
int get_physical_pin(t_physical_tile_type_ptr physical_tile,
2198+
t_logical_block_type_ptr logical_block,
2199+
int pin) {
2200+
t_logical_pin logical_pin(pin);
2201+
2202+
auto direct_map = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
2203+
auto result = direct_map.find(logical_pin);
2204+
2205+
if (result == direct_map.end()) {
2206+
VTR_LOG_WARN(
2207+
"Couldn't find the corresponding physical pin of the logical pin %d."
2208+
"Physical Tile: %s, Logical Block: %s.\n",
2209+
pin, physical_tile->name, logical_block->name);
2210+
return OPEN;
2211+
}
2212+
2213+
return result->second.pin;
2214+
}
2215+
21922216
void pretty_print_uint(const char* prefix, size_t value, int num_digits, int scientific_precision) {
21932217
//Print as integer if it will fit in the width, other wise scientific
21942218
if (value <= std::pow(10, num_digits) - 1) {

0 commit comments

Comments
 (0)