Skip to content

Commit cb2043b

Browse files
acomodikmurray
authored andcommitted
equivalent: addressed review comments
Deleted usage of the following utility functions as their functionality was not required anymore: - `int find_clb_pb_pin(ClusterBlockId clb, int clb_pin);` - `int find_pb_pin_clb_pin(ClusterBlockId clb, int pb_pin);` In fact they were returning different values depending on the `nets_and_pins_synced_to_z_coordinate` boolean which is currently unused. Added comments to newly introduced utility functions and changed name to have higher understendability Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 902bdf2 commit cb2043b

File tree

8 files changed

+25
-100
lines changed

8 files changed

+25
-100
lines changed

vpr/src/base/read_route.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void process_global_blocks(std::ifstream& fp, ClusterNetId inet, const ch
378378
x, y, place_ctx.block_locs[bnum].loc.x, place_ctx.block_locs[bnum].loc.y);
379379
}
380380

381-
int pin_index = net_pin_tile_index(inet, pin_counter);
381+
int pin_index = net_pin_to_tile_pin_index(inet, pin_counter);
382382
if (physical_tile_type(bnum)->pin_class[pin_index] != atoi(tokens[7].c_str())) {
383383
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
384384
"The pin class %d of %lu net does not match given ",

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,11 @@ struct t_place_region {
625625
* x: x-coordinate
626626
* y: y-coordinate
627627
* z: occupancy coordinate
628-
* is_fixed: true if this block's position is fixed by the user and shouldn't be moved during annealing
629-
* nets_and_pins_synced_to_z_coordinate: true if the associated clb's pins have been synced to the z location (i.e. after placement) */
628+
* is_fixed: true if this block's position is fixed by the user and shouldn't be moved during annealing */
630629
struct t_block_loc {
631630
t_pl_loc loc;
632631

633632
bool is_fixed = false;
634-
bool nets_and_pins_synced_to_z_coordinate = false;
635633
};
636634

637635
/* Stores the clustered blocks placed at a particular grid location */

vpr/src/place/place.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ static void update_net_bb(const ClusterNetId net,
13901390
}
13911391
} else {
13921392
//For large nets, update bounding box incrementally
1393-
int iblk_pin = pin_tile_index(blk_pin);
1393+
int iblk_pin = tile_pin_index(blk_pin);
13941394

13951395
t_physical_tile_type_ptr blk_type = physical_tile_type(blk);
13961396
int pin_width_offset = blk_type->pin_width_offset[iblk_pin];
@@ -1841,7 +1841,7 @@ static void get_bb_from_scratch(ClusterNetId net_id, t_bb* coords, t_bb* num_on_
18411841
auto& grid = device_ctx.grid;
18421842

18431843
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
1844-
pnum = net_pin_tile_index(net_id, 0);
1844+
pnum = net_pin_to_tile_pin_index(net_id, 0);
18451845
VTR_ASSERT(pnum >= 0);
18461846
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
18471847
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
@@ -1860,7 +1860,7 @@ static void get_bb_from_scratch(ClusterNetId net_id, t_bb* coords, t_bb* num_on_
18601860

18611861
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
18621862
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
1863-
pnum = pin_tile_index(pin_id);
1863+
pnum = tile_pin_index(pin_id);
18641864
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
18651865
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
18661866

@@ -2000,7 +2000,7 @@ static void get_non_updateable_bb(ClusterNetId net_id, t_bb* bb_coord_new) {
20002000
auto& device_ctx = g_vpr_ctx.device();
20012001

20022002
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
2003-
pnum = net_pin_tile_index(net_id, 0);
2003+
pnum = net_pin_to_tile_pin_index(net_id, 0);
20042004
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
20052005
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
20062006

@@ -2011,7 +2011,7 @@ static void get_non_updateable_bb(ClusterNetId net_id, t_bb* bb_coord_new) {
20112011

20122012
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
20132013
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
2014-
pnum = pin_tile_index(pin_id);
2014+
pnum = tile_pin_index(pin_id);
20152015
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
20162016
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
20172017

vpr/src/route/check_route.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void check_sink(int inode, ClusterNetId net_id, bool* pin_done) {
190190
unsigned int ipin = 1;
191191
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
192192
if (cluster_ctx.clb_nlist.pin_block(pin_id) == bnum) {
193-
int pin_index = pin_tile_index(pin_id);
193+
int pin_index = tile_pin_index(pin_id);
194194
int iclass = type->pin_class[pin_index];
195195
if (iclass == ptc_num) {
196196
/* Could connect to same pin class on the same clb more than once. Only *
@@ -245,7 +245,7 @@ static void check_source(int inode, ClusterNetId net_id) {
245245
}
246246

247247
//Get the driver pin's index in the block
248-
auto physical_pin = net_pin_tile_index(net_id, 0);
248+
auto physical_pin = net_pin_to_tile_pin_index(net_id, 0);
249249

250250
int iclass = type->pin_class[physical_pin];
251251

vpr/src/route/route_common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static vtr::vector<ClusterNetId, std::vector<int>> load_net_rr_terminals(const t
10541054
/* In the routing graph, each (x, y) location has unique pins on it
10551055
* so when there is capacity, blocks are packed and their pin numbers
10561056
* are offset to get their actual rr_node */
1057-
int phys_pin = pin_tile_index(pin_id);
1057+
int phys_pin = tile_pin_index(pin_id);
10581058

10591059
int iclass = type->pin_class[phys_pin];
10601060

@@ -1538,7 +1538,7 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
15381538

15391539
for (auto pin_id : cluster_ctx.clb_nlist.net_pins(net_id)) {
15401540
ClusterBlockId block_id = cluster_ctx.clb_nlist.pin_block(pin_id);
1541-
int pin_index = pin_tile_index(pin_id);
1541+
int pin_index = tile_pin_index(pin_id);
15421542
int iclass = physical_tile_type(block_id)->pin_class[pin_index];
15431543

15441544
fprintf(fp, "Block %s (#%zu) at (%d,%d), Pin class %d.\n",

vpr/src/timing/clb_delay_calc.inl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ inline ClbDelayCalc::ClbDelayCalc()
1010
: intra_lb_pb_pin_lookup_(g_vpr_ctx.device().logical_block_types) {}
1111

1212
inline float ClbDelayCalc::clb_input_to_internal_sink_delay(const ClusterBlockId block_id, const int pin_index, int internal_sink_pin, DelayType delay_type) const {
13-
int pb_ipin = find_clb_pb_pin(block_id, pin_index);
14-
return trace_delay(block_id, pb_ipin, internal_sink_pin, delay_type);
13+
return trace_delay(block_id, pin_index, internal_sink_pin, delay_type);
1514
}
1615

1716
inline float ClbDelayCalc::internal_src_to_clb_output_delay(const ClusterBlockId block_id, const int pin_index, int internal_src_pin, DelayType delay_type) const {
18-
int pb_opin = find_clb_pb_pin(block_id, pin_index);
19-
return trace_delay(block_id, internal_src_pin, pb_opin, delay_type);
17+
return trace_delay(block_id, internal_src_pin, pin_index, delay_type);
2018
}
2119

2220
inline float ClbDelayCalc::internal_src_to_internal_sink_delay(const ClusterBlockId clb, int internal_src_pin, int internal_sink_pin, DelayType delay_type) const {

vpr/src/util/vpr_utils.cpp

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -505,67 +505,13 @@ std::tuple<ClusterNetId, int, int> find_pb_route_clb_input_net_pin(ClusterBlockI
505505
return std::make_tuple(ClusterNetId::INVALID(), -1, -1);
506506
}
507507

508-
//To account for capacity > 1 blocks we need to convert the pb_pin to the clb pin
509-
int clb_pin = find_pb_pin_clb_pin(clb, curr_pb_pin_id);
510-
VTR_ASSERT(clb_pin >= 0);
511-
512-
//clb_pin should be a top-level CLB input
513-
ClusterNetId clb_net_idx = cluster_ctx.clb_nlist.block_net(clb, clb_pin);
514-
int clb_net_pin_idx = cluster_ctx.clb_nlist.block_pin_net_index(clb, clb_pin);
508+
//curr_pb_pin should be a top-level CLB input
509+
ClusterNetId clb_net_idx = cluster_ctx.clb_nlist.block_net(clb, curr_pb_pin_id);
510+
int clb_net_pin_idx = cluster_ctx.clb_nlist.block_pin_net_index(clb, curr_pb_pin_id);
515511
VTR_ASSERT(clb_net_idx != ClusterNetId::INVALID());
516512
VTR_ASSERT(clb_net_pin_idx >= 0);
517513

518-
return std::tuple<ClusterNetId, int, int>(clb_net_idx, clb_pin, clb_net_pin_idx);
519-
}
520-
521-
//Return the pb pin index corresponding to the pin clb_pin on block clb
522-
// Given a clb_pin index on a this function will return the corresponding
523-
// pin index on the pb_type (accounting for the possible z-coordinate offset).
524-
int find_clb_pb_pin(ClusterBlockId clb, int clb_pin) {
525-
auto& place_ctx = g_vpr_ctx.placement();
526-
527-
auto type = physical_tile_type(clb);
528-
VTR_ASSERT_MSG(clb_pin < type->num_pins, "Must be a valid top-level pin");
529-
530-
int pb_pin = -1;
531-
if (place_ctx.block_locs[clb].nets_and_pins_synced_to_z_coordinate) {
532-
//Pins have been offset by z-coordinate, need to remove offset
533-
534-
VTR_ASSERT(type->num_pins % type->capacity == 0);
535-
int num_basic_block_pins = type->num_pins / type->capacity;
536-
/* Logical location and physical location is offset by z * max_num_block_pins */
537-
538-
pb_pin = clb_pin - place_ctx.block_locs[clb].loc.z * num_basic_block_pins;
539-
} else {
540-
pb_pin = clb_pin;
541-
}
542-
543-
VTR_ASSERT(pb_pin >= 0);
544-
545-
return pb_pin;
546-
}
547-
548-
//Inverse of find_clb_pb_pin()
549-
int find_pb_pin_clb_pin(ClusterBlockId clb, int pb_pin) {
550-
auto& place_ctx = g_vpr_ctx.placement();
551-
552-
auto type = physical_tile_type(clb);
553-
554-
int clb_pin = -1;
555-
if (place_ctx.block_locs[clb].nets_and_pins_synced_to_z_coordinate) {
556-
//Pins have been offset by z-coordinate, need to remove offset
557-
VTR_ASSERT(type->num_pins % type->capacity == 0);
558-
int num_basic_block_pins = type->num_pins / type->capacity;
559-
/* Logical location and physical location is offset by z * max_num_block_pins */
560-
561-
clb_pin = pb_pin + place_ctx.block_locs[clb].loc.z * num_basic_block_pins;
562-
} else {
563-
//No offset
564-
clb_pin = pb_pin;
565-
}
566-
VTR_ASSERT(clb_pin >= 0);
567-
568-
return clb_pin;
514+
return std::tuple<ClusterNetId, int, int>(clb_net_idx, curr_pb_pin_id, clb_net_pin_idx);
569515
}
570516

571517
bool is_clb_external_pin(ClusterBlockId blk_id, int pb_pin_id) {
@@ -2108,7 +2054,6 @@ void place_sync_external_block_connections(ClusterBlockId iblk) {
21082054
auto& cluster_ctx = g_vpr_ctx.clustering();
21092055
auto& clb_nlist = cluster_ctx.clb_nlist;
21102056
auto& place_ctx = g_vpr_ctx.mutable_placement();
2111-
VTR_ASSERT_MSG(place_ctx.block_locs[iblk].nets_and_pins_synced_to_z_coordinate == false, "Block net and pins must not be already synced");
21122057

21132058
auto physical_tile = physical_tile_type(iblk);
21142059
auto logical_block = clb_nlist.block_type(iblk);
@@ -2130,9 +2075,6 @@ void place_sync_external_block_connections(ClusterBlockId iblk) {
21302075
place_ctx.physical_pins.insert(pin, new_physical_pin_index);
21312076
}
21322077
}
2133-
2134-
//Mark the block as synced
2135-
//place_ctx.block_locs[iblk].nets_and_pins_synced_to_z_coordinate = true;
21362078
}
21372079

21382080
int get_max_num_pins(t_logical_block_type_ptr logical_block) {
@@ -2210,16 +2152,16 @@ int get_physical_pin(t_physical_tile_type_ptr physical_tile,
22102152
return result->second.pin;
22112153
}
22122154

2213-
int net_pin_tile_index(const ClusterNetId net_id, int net_pin_index) {
2155+
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) {
22142156
auto& cluster_ctx = g_vpr_ctx.clustering();
22152157

22162158
// Get the logical pin index of pin within it's logical block type
22172159
auto pin_id = cluster_ctx.clb_nlist.net_pin(net_id, net_pin_index);
22182160

2219-
return pin_tile_index(pin_id);
2161+
return tile_pin_index(pin_id);
22202162
}
22212163

2222-
int pin_tile_index(const ClusterPinId pin) {
2164+
int tile_pin_index(const ClusterPinId pin) {
22232165
auto& place_ctx = g_vpr_ctx.placement();
22242166

22252167
return place_ctx.physical_pins[pin];

vpr/src/util/vpr_utils.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,6 @@ std::vector<AtomPinId> find_clb_pin_sink_atom_pins(ClusterBlockId clb, int logic
8585

8686
std::tuple<ClusterNetId, int, int> find_pb_route_clb_input_net_pin(ClusterBlockId clb, int sink_pb_route_id);
8787

88-
//Return the pb pin index corresponding to the pin clb_pin on block clb,
89-
//acounting for the effect of 'z' position > 0.
90-
//
91-
// Note that a CLB pin index does not (neccessarily) map directly to the pb_route index representing the first stage
92-
// of internal routing in the block, since a block may have capacity > 1 (e.g. IOs)
93-
//
94-
// In the clustered netlist blocks with capacity > 1 may have their 'z' position > 0, and their clb pin indicies offset
95-
// by the number of pins on the type (c.f. post_place_sync()).
96-
//
97-
// This offset is not mirrored in the t_pb or pb graph, so we need to recover the basic pin index before processing
98-
// further -- which is what this function does.
99-
int find_clb_pb_pin(ClusterBlockId clb, int clb_pin);
100-
101-
//Return the clb_pin corresponding to the pb_pin on the specified block
102-
int find_pb_pin_clb_pin(ClusterBlockId clb, int pb_pin);
103-
10488
//Returns the port matching name within pb_gnode
10589
const t_port* find_pb_graph_port(const t_pb_graph_node* pb_gnode, std::string port_name);
10690

@@ -180,8 +164,11 @@ int get_physical_pin(t_physical_tile_type_ptr physical_tile,
180164
t_logical_block_type_ptr logical_block,
181165
int pin);
182166

183-
int net_pin_tile_index(const ClusterNetId net_id, int net_pin_index);
184-
int pin_tile_index(const ClusterPinId pin);
167+
//Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index
168+
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index);
169+
170+
//Returns the physical pin of the tile, related to the given ClusterPinId
171+
int tile_pin_index(const ClusterPinId pin);
185172

186173
int max_pins_per_grid_tile();
187174

0 commit comments

Comments
 (0)