Skip to content

Commit 59c833a

Browse files
committed
equivalent: delete pin_physical_index from clustered netlist
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent f10da39 commit 59c833a

13 files changed

+110
-125
lines changed

vpr/src/base/check_netlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int check_connections_to_global_clb_pins(ClusterNetId net_id, int verbosi
9494
auto logical_type = cluster_ctx.clb_nlist.block_type(blk_id);
9595
auto physical_type = pick_best_physical_type(logical_type);
9696

97-
int log_index = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
97+
int log_index = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
9898
int pin_index = get_physical_pin(physical_type, logical_type, log_index);
9999

100100
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored

vpr/src/base/clustered_netlist.cpp

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ t_logical_block_type_ptr ClusteredNetlist::block_type(const ClusterBlockId id) c
3030
return block_types_[id];
3131
}
3232

33-
ClusterNetId ClusteredNetlist::block_net(const ClusterBlockId blk_id, const int phys_pin_index) const {
34-
auto pin_id = block_pin(blk_id, phys_pin_index);
33+
ClusterNetId ClusteredNetlist::block_net(const ClusterBlockId blk_id, const int logical_pin_index) const {
34+
auto pin_id = block_pin(blk_id, logical_pin_index);
3535

3636
if (pin_id) {
3737
return pin_net(pin_id);
@@ -50,11 +50,11 @@ int ClusteredNetlist::block_pin_net_index(const ClusterBlockId blk_id, const int
5050
return OPEN;
5151
}
5252

53-
ClusterPinId ClusteredNetlist::block_pin(const ClusterBlockId blk, const int phys_pin_index) const {
53+
ClusterPinId ClusteredNetlist::block_pin(const ClusterBlockId blk, const int logical_pin_index) const {
5454
VTR_ASSERT_SAFE(valid_block_id(blk));
55-
VTR_ASSERT_SAFE_MSG(phys_pin_index >= 0 && phys_pin_index < static_cast<ssize_t>(block_logical_pins_[blk].size()), "Physical pin index must be in range");
55+
VTR_ASSERT_SAFE_MSG(logical_pin_index >= 0 && logical_pin_index < static_cast<ssize_t>(block_logical_pins_[blk].size()), "Logical pin index must be in range");
5656

57-
return block_logical_pins_[blk][phys_pin_index];
57+
return block_logical_pins_[blk][logical_pin_index];
5858
}
5959

6060
bool ClusteredNetlist::block_contains_primary_input(const ClusterBlockId blk) const {
@@ -75,23 +75,17 @@ bool ClusteredNetlist::block_contains_primary_output(const ClusterBlockId blk) c
7575
* Pins
7676
*
7777
*/
78-
int ClusteredNetlist::pin_physical_index(const ClusterPinId id) const {
79-
VTR_ASSERT_SAFE(valid_pin_id(id));
80-
81-
return pin_physical_index_[id];
82-
}
83-
8478
int ClusteredNetlist::pin_logical_index(const ClusterPinId pin_id) const {
8579
VTR_ASSERT_SAFE(valid_pin_id(pin_id));
8680

8781
return pin_logical_index_[pin_id];
8882
}
8983

90-
int ClusteredNetlist::net_pin_physical_index(const ClusterNetId net_id, int net_pin_index) const {
84+
int ClusteredNetlist::net_pin_logical_index(const ClusterNetId net_id, int net_pin_index) const {
9185
auto pin_id = net_pin(net_id, net_pin_index);
9286

9387
if (pin_id) {
94-
return pin_physical_index(pin_id);
88+
return pin_logical_index(pin_id);
9589
}
9690

9791
return OPEN; //No valid pin found
@@ -141,20 +135,6 @@ ClusterBlockId ClusteredNetlist::create_block(const char* name, t_pb* pb, t_logi
141135
return blk_id;
142136
}
143137

144-
void ClusteredNetlist::set_pin_physical_index(const ClusterPinId pin, const int phys_pin_index) {
145-
VTR_ASSERT_SAFE(valid_pin_id(pin));
146-
auto blk = pin_block(pin);
147-
148-
int old_phys_pin_index = pin_physical_index(pin);
149-
150-
//Invalidate old mapping
151-
block_logical_pins_[blk][old_phys_pin_index] = ClusterPinId::INVALID();
152-
153-
//Update mappings
154-
pin_physical_index_[pin] = phys_pin_index;
155-
block_logical_pins_[blk][phys_pin_index] = pin;
156-
}
157-
158138
ClusterPortId ClusteredNetlist::create_port(const ClusterBlockId blk_id, const std::string name, BitIndex width, PortType type) {
159139
ClusterPortId port_id = find_port(blk_id, name);
160140
if (!port_id) {
@@ -175,7 +155,6 @@ ClusterPortId ClusteredNetlist::create_port(const ClusterBlockId blk_id, const s
175155
ClusterPinId ClusteredNetlist::create_pin(const ClusterPortId port_id, BitIndex port_bit, const ClusterNetId net_id, const PinType pin_type_, int pin_index, bool is_const) {
176156
ClusterPinId pin_id = Netlist::create_pin(port_id, port_bit, net_id, pin_type_, is_const);
177157

178-
pin_physical_index_.push_back(pin_index);
179158
pin_logical_index_.push_back(pin_index);
180159

181160
ClusterBlockId block_id = port_block(port_id);
@@ -249,7 +228,7 @@ void ClusteredNetlist::clean_ports_impl(const vtr::vector_map<ClusterPortId, Clu
249228

250229
void ClusteredNetlist::clean_pins_impl(const vtr::vector_map<ClusterPinId, ClusterPinId>& pin_id_map) {
251230
//Update all the pin values
252-
pin_physical_index_ = clean_and_reorder_values(pin_physical_index_, pin_id_map);
231+
pin_logical_index_ = clean_and_reorder_values(pin_logical_index_, pin_id_map);
253232
}
254233

255234
void ClusteredNetlist::clean_nets_impl(const vtr::vector_map<ClusterNetId, ClusterNetId>& net_id_map) {
@@ -263,8 +242,8 @@ void ClusteredNetlist::rebuild_block_refs_impl(const vtr::vector_map<ClusterPinI
263242
for (auto blk : blocks()) {
264243
block_logical_pins_[blk] = std::vector<ClusterPinId>(get_max_num_pins(block_type(blk)), ClusterPinId::INVALID()); //Reset
265244
for (auto pin : block_pins(blk)) {
266-
int phys_pin_index = pin_physical_index(pin);
267-
block_logical_pins_[blk][phys_pin_index] = pin;
245+
int logical_pin_index = pin_logical_index(pin);
246+
block_logical_pins_[blk][logical_pin_index] = pin;
268247
}
269248
}
270249
}
@@ -290,7 +269,6 @@ void ClusteredNetlist::shrink_to_fit_impl() {
290269
block_logical_pins_.shrink_to_fit();
291270

292271
//Pin data
293-
pin_physical_index_.shrink_to_fit();
294272
pin_logical_index_.shrink_to_fit();
295273

296274
//Net data
@@ -318,7 +296,7 @@ bool ClusteredNetlist::validate_port_sizes_impl(size_t /*num_ports*/) const {
318296
}
319297

320298
bool ClusteredNetlist::validate_pin_sizes_impl(size_t num_pins) const {
321-
if (pin_physical_index_.size() != num_pins) {
299+
if (pin_logical_index_.size() != num_pins) {
322300
return false;
323301
}
324302
return true;

vpr/src/base/clustered_netlist.h

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868
* Pins
6969
* ----
7070
* The only piece of unique pin information is:
71-
* physical_pin_index_
71+
* logical_pin_index_
7272
*
73-
* Example of physical_pin_index_
73+
* Example of logical_pin_index_
7474
* ---------------------
75-
* Given a ClusterPinId, physical_pin_index_ will return the index of the pin within its block
76-
* relative to the t_logical_block_type (physical description of the block).
75+
* Given a ClusterPinId, logical_pin_index_ will return the index of the pin within its block
76+
* relative to the t_logical_block_type (logical description of the block).
7777
*
7878
* +-----------+
7979
* 0-->|O X|-->3
@@ -83,7 +83,7 @@
8383
*
8484
* The index skips over unused pins, e.g. CLB has 6 pins (3 in, 3 out, numbered [0...5]), where
8585
* the first two ins, and last two outs are used. Indices [0,1] represent the ins, and [4,5]
86-
* represent the outs. Indices [2,3] are unused. Therefore, physical_pin_index_[92] = 5.
86+
* represent the outs. Indices [2,3] are unused. Therefore, logical_pin_index_[92] = 5.
8787
*
8888
* Nets
8989
* ----
@@ -134,8 +134,8 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi
134134
//Returns the count on the net of the block attached
135135
int block_pin_net_index(const ClusterBlockId blk_id, const int pin_index) const;
136136

137-
//Returns the logical pin Id associated with the specified block and physical pin index
138-
ClusterPinId block_pin(const ClusterBlockId blk, const int phys_pin_index) const;
137+
//Returns the logical pin Id associated with the specified block and logical pin index
138+
ClusterPinId block_pin(const ClusterBlockId blk, const int logical_pin_index) const;
139139

140140
//Returns true if the specified block contains a primary input (e.g. BLIF .input primitive)
141141
bool block_contains_primary_input(const ClusterBlockId blk) const;
@@ -147,20 +147,16 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi
147147
* Pins
148148
*/
149149

150-
//Returns the physical pin index (i.e. pin index on the
151-
//t_physical_tile_type) of the specified logical pin
152-
int pin_physical_index(const ClusterPinId id) const;
153-
154150
//Returns the logical pin index (i.e. pin index on the
155151
//t_logical_block_type) of the cluster pin
156152
int pin_logical_index(const ClusterPinId pin_id) const;
157153

158154
//Finds the net_index'th net pin (e.g. the 6th pin of the net) and
159-
//returns the physical pin index (i.e. pin index on the t_logical_block_type)
155+
//returns the logical pin index (i.e. pin index on the t_logical_block_type)
160156
//of the block to which the pin belongs
161157
// net_id : The net
162158
// net_pin_index : The index of the pin in the net
163-
int net_pin_physical_index(const ClusterNetId net_id, int net_pin_index) const;
159+
int net_pin_logical_index(const ClusterNetId net_id, int net_pin_index) const;
164160

165161
/*
166162
* Nets
@@ -194,11 +190,6 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi
194190
// is_const : Indicates whether the pin holds a constant value (e. g. vcc/gnd)
195191
ClusterPinId create_pin(const ClusterPortId port_id, BitIndex port_bit, const ClusterNetId net_id, const PinType pin_type, int pin_index, bool is_const = false);
196192

197-
//Sets the mapping of a ClusterPinId to the block's type descriptor's pin index
198-
// pin_id : The pin to be set
199-
// index : The new index to set the pin to
200-
void set_pin_physical_index(const ClusterPinId pin_id, const int index);
201-
202193
//Create an empty, or return an existing net in the netlist
203194
// name : The unique name of the net
204195
ClusterNetId create_net(const std::string name);
@@ -253,12 +244,9 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi
253244
vtr::vector_map<ClusterBlockId, std::vector<ClusterPinId>> block_logical_pins_; //The logical pin associated with each physical tile pin
254245

255246
//Pins
256-
vtr::vector_map<ClusterPinId, int> pin_physical_index_; //The physical pin index (i.e. pin index
257-
//in t_physical_tile_type) corresponding
258-
//to the clustered pin
259-
vtr::vector_map<ClusterPinId, int> pin_logical_index_; //The logical pin index of this block (i.e. pin index
260-
//in t_logical_block_type) corresponding
261-
//to the clustered pin
247+
vtr::vector_map<ClusterPinId, int> pin_logical_index_; //The logical pin index of this block (i.e. pin index
248+
//in t_logical_block_type) corresponding
249+
//to the clustered pin
262250

263251
//Nets
264252
vtr::vector_map<ClusterNetId, bool> net_is_ignored_; //Boolean mapping indicating if the net is ignored

vpr/src/base/read_netlist.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
971971
//Asserts the ClusterBlockId is the same when ClusterNetId & pin BitIndex is provided
972972
VTR_ASSERT(blk_id == clb_nlist.pin_block(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
973973
//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]));
974+
VTR_ASSERT(j == clb_nlist.pin_logical_index(*(clb_nlist.net_pins(clb_net_id).begin() + count[clb_net_id])));
975+
VTR_ASSERT(j == clb_nlist.net_pin_logical_index(clb_net_id, count[clb_net_id]));
976976

977977
// nets connecting to global pins are marked as global nets
978978
if (tile_type->is_pin_global[physical_pin]) {
@@ -986,8 +986,8 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
986986

987987
} else {
988988
VTR_ASSERT(DRIVER == tile_type->class_inf[tile_type->pin_class[physical_pin]].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));
989+
VTR_ASSERT(j == clb_nlist.pin_logical_index(*(clb_nlist.net_pins(clb_net_id).begin())));
990+
VTR_ASSERT(j == clb_nlist.net_pin_logical_index(clb_net_id, 0));
991991
}
992992
}
993993
}

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 = cluster_ctx.clb_nlist.net_pin_physical_index(inet, pin_counter);
381+
int pin_index = net_pin_tile_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_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ struct PlacementContext : public Context {
248248
//Clustered block placement locations
249249
vtr::vector_map<ClusterBlockId, t_block_loc> block_locs;
250250

251+
//Clustered pin placement mapping with physical pin
252+
vtr::vector_map<ClusterPinId, int> physical_pins;
253+
251254
//Clustered block associated with each grid location (i.e. inverse of block_locs)
252255
vtr::Matrix<t_grid_blocks> grid_blocks; //[0..device_ctx.grid.width()-1][0..device_ctx.grid.width()-1]
253256

vpr/src/place/place.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ void try_place(const t_placer_opts& placer_opts,
487487

488488
initial_placement(placer_opts.pad_loc_type, placer_opts.pad_loc_file.c_str());
489489

490+
// Update physical pin values
491+
for (auto block_id : cluster_ctx.clb_nlist.blocks()) {
492+
place_sync_external_block_connections(block_id);
493+
}
494+
490495
init_draw_coords((float)width_fac);
491496
//Enables fast look-up of atom pins connect to CLB pins
492497
ClusteredPinAtomPinsLookup netlist_pin_lookup(cluster_ctx.clb_nlist, pb_gpin_lookup);
@@ -1385,7 +1390,7 @@ static void update_net_bb(const ClusterNetId net,
13851390
}
13861391
} else {
13871392
//For large nets, update bounding box incrementally
1388-
int iblk_pin = cluster_ctx.clb_nlist.pin_physical_index(blk_pin);
1393+
int iblk_pin = pin_tile_index(blk_pin);
13891394

13901395
t_physical_tile_type_ptr blk_type = physical_tile_type(blk);
13911396
int pin_width_offset = blk_type->pin_width_offset[iblk_pin];
@@ -1491,8 +1496,8 @@ static float comp_td_point_to_point_delay(const PlaceDelayModel* delay_model, Cl
14911496
ClusterBlockId source_block = cluster_ctx.clb_nlist.pin_block(source_pin);
14921497
ClusterBlockId sink_block = cluster_ctx.clb_nlist.pin_block(sink_pin);
14931498

1494-
int source_block_ipin = cluster_ctx.clb_nlist.pin_physical_index(source_pin);
1495-
int sink_block_ipin = cluster_ctx.clb_nlist.pin_physical_index(sink_pin);
1499+
int source_block_ipin = cluster_ctx.clb_nlist.pin_logical_index(source_pin);
1500+
int sink_block_ipin = cluster_ctx.clb_nlist.pin_logical_index(sink_pin);
14961501

14971502
int source_x = place_ctx.block_locs[source_block].loc.x;
14981503
int source_y = place_ctx.block_locs[source_block].loc.y;
@@ -1799,7 +1804,7 @@ static void alloc_and_load_net_pin_indices() {
17991804
continue;
18001805
netpin = 0;
18011806
for (auto pin_id : cluster_ctx.clb_nlist.net_pins(net_id)) {
1802-
int pin_index = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
1807+
int pin_index = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
18031808
ClusterBlockId block_id = cluster_ctx.clb_nlist.pin_block(pin_id);
18041809
net_pin_indices[block_id][pin_index] = netpin;
18051810
netpin++;
@@ -1836,7 +1841,7 @@ static void get_bb_from_scratch(ClusterNetId net_id, t_bb* coords, t_bb* num_on_
18361841
auto& grid = device_ctx.grid;
18371842

18381843
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
1839-
pnum = cluster_ctx.clb_nlist.net_pin_physical_index(net_id, 0);
1844+
pnum = net_pin_tile_index(net_id, 0);
18401845
VTR_ASSERT(pnum >= 0);
18411846
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
18421847
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
@@ -1855,7 +1860,7 @@ static void get_bb_from_scratch(ClusterNetId net_id, t_bb* coords, t_bb* num_on_
18551860

18561861
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
18571862
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
1858-
pnum = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
1863+
pnum = pin_tile_index(pin_id);
18591864
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
18601865
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
18611866

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

19972002
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
1998-
pnum = cluster_ctx.clb_nlist.net_pin_physical_index(net_id, 0);
2003+
pnum = net_pin_tile_index(net_id, 0);
19992004
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
20002005
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
20012006

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

20072012
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
20082013
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
2009-
pnum = cluster_ctx.clb_nlist.pin_physical_index(pin_id);
2014+
pnum = pin_tile_index(pin_id);
20102015
x = place_ctx.block_locs[bnum].loc.x + physical_tile_type(bnum)->pin_width_offset[pnum];
20112016
y = place_ctx.block_locs[bnum].loc.y + physical_tile_type(bnum)->pin_height_offset[pnum];
20122017

vpr/src/place/place_macro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static bool net_is_driven_by_direct(ClusterNetId clb_net) {
495495
auto& cluster_ctx = g_vpr_ctx.clustering();
496496

497497
ClusterBlockId block_id = cluster_ctx.clb_nlist.net_driver_block(clb_net);
498-
int pin_index = cluster_ctx.clb_nlist.net_pin_physical_index(clb_net, 0);
498+
int pin_index = cluster_ctx.clb_nlist.net_pin_logical_index(clb_net, 0);
499499

500500
auto direct = f_idirect_from_blk_pin[cluster_ctx.clb_nlist.block_type(block_id)->index][pin_index];
501501

0 commit comments

Comments
 (0)