Skip to content

Commit 12cc989

Browse files
committed
Implement initial explicit ports.
This implements part one of verilog-to-routing#1063 Signed-off-by: Keith Rothman <[email protected]>
1 parent 35f796d commit 12cc989

File tree

10 files changed

+220
-91
lines changed

10 files changed

+220
-91
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ enum class e_sb_type {
524524

525525
};
526526

527+
enum class e_capacity_type {
528+
DUPLICATE, // Capacity duplicates ports.
529+
EXPLICIT // Capacity increases the number of logical tiles, but does not
530+
// modify the physical ports.
531+
};
532+
527533
constexpr int NO_SWITCH = -1;
528534
constexpr int DEFAULT_SWITCH = -2;
529535

@@ -578,6 +584,7 @@ struct t_physical_tile_type {
578584
int num_clock_pins = 0;
579585

580586
int capacity = 0;
587+
e_capacity_type capacity_type = e_capacity_type::DUPLICATE;
581588

582589
int width = 0;
583590
int height = 0;
@@ -626,18 +633,20 @@ struct t_physical_tile_type {
626633
* vtr::bimap container.
627634
*/
628635
struct t_logical_pin {
636+
int z_index = -1;
629637
int pin = -1;
630638

631-
t_logical_pin(int value) {
639+
t_logical_pin(int z_index_value, int value) {
640+
z_index = z_index_value;
632641
pin = value;
633642
}
634643

635644
bool operator==(const t_logical_pin o) const {
636-
return pin == o.pin;
645+
return z_index == o.z_index && pin == o.pin;
637646
}
638647

639648
bool operator<(const t_logical_pin o) const {
640-
return pin < o.pin;
649+
return std::make_pair(z_index, pin) < std::make_pair(o.z_index, o.pin);
641650
}
642651
};
643652

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 163 additions & 51 deletions
Large diffs are not rendered by default.

vpr/src/base/ShowSetup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void printClusteredNetlistStats() {
7979
num_blocks_type[logical_block->index]++;
8080
if (is_io_type(physical_tile)) {
8181
for (j = 0; j < logical_block->pb_type->num_pins; j++) {
82-
int physical_pin = get_physical_pin(physical_tile, logical_block, j);
82+
int physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, logical_block, j);
8383
auto pin_class = physical_tile->pin_class[physical_pin];
8484
auto class_inf = physical_tile->class_inf[pin_class];
8585

vpr/src/base/check_netlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int check_connections_to_global_clb_pins(ClusterNetId net_id, int verbosi
9898
auto physical_type = pick_best_physical_type(logical_type);
9999

100100
int log_index = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
101-
int pin_index = get_physical_pin(physical_type, logical_type, log_index);
101+
int pin_index = get_physical_pin(physical_type, /*z_index=*/0, logical_type, log_index);
102102

103103
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored
104104
&& !is_io_type(physical_type)) {

vpr/src/base/read_netlist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
951951
block_type = clb_nlist.block_type(blk_id);
952952
auto tile_type = pick_best_physical_type(block_type);
953953
for (j = 0; j < block_type->pb_type->num_pins; j++) {
954-
int physical_pin = get_physical_pin(tile_type, block_type, j);
954+
int physical_pin = get_physical_pin(tile_type, /*z_index=*/0, block_type, j);
955955

956956
//Iterate through each pin of the block, and see if there is a net allocated/used for it
957957
clb_net_id = clb_nlist.block_net(blk_id, j);
@@ -1001,7 +1001,7 @@ static void load_external_nets_and_cb(ClusteredNetlist& clb_nlist) {
10011001
block_type = clb_nlist.block_type(clb_nlist.pin_block(pin_id));
10021002
auto tile_type = pick_best_physical_type(block_type);
10031003
int logical_pin = clb_nlist.pin_logical_index(pin_id);
1004-
int physical_pin = get_physical_pin(tile_type, block_type, logical_pin);
1004+
int physical_pin = get_physical_pin(tile_type, /*z_index=*/0, block_type, logical_pin);
10051005

10061006
if (tile_type->is_ignored_pin[physical_pin] != is_ignored_net) {
10071007
VTR_LOG_WARN(

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type, ClusterBlockId b
26642664
continue;
26652665

26662666
auto physical_tile = physical_tile_type(blk_id);
2667-
int physical_pin = get_physical_pin(physical_tile, type, k);
2667+
int physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, type, k);
26682668

26692669
iclass = physical_tile->pin_class[physical_pin];
26702670

vpr/src/pack/output_clustering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void print_stats() {
6262
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
6363
auto physical_tile = pick_best_physical_type(logical_block);
6464
for (ipin = 0; ipin < logical_block->pb_type->num_pins; ipin++) {
65-
int physical_pin = get_physical_pin(physical_tile, logical_block, ipin);
65+
int physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, logical_block, ipin);
6666
auto pin_class = physical_tile->pin_class[physical_pin];
6767
auto pin_class_inf = physical_tile->class_inf[pin_class];
6868

vpr/src/place/place_macro.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static void find_all_the_macro(int* num_of_macro, std::vector<ClusterBlockId>& p
8282

8383
num_blk_pins = cluster_ctx.clb_nlist.block_type(blk_id)->pb_type->num_pins;
8484
for (to_iblk_pin = 0; to_iblk_pin < num_blk_pins; to_iblk_pin++) {
85-
int to_physical_pin = get_physical_pin(physical_tile, logical_block, to_iblk_pin);
85+
int to_physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, logical_block, to_iblk_pin);
8686

8787
to_net_id = cluster_ctx.clb_nlist.block_net(blk_id, to_iblk_pin);
8888
to_idirect = f_idirect_from_blk_pin[physical_tile->index][to_physical_pin];
@@ -102,7 +102,7 @@ static void find_all_the_macro(int* num_of_macro, std::vector<ClusterBlockId>& p
102102
|| (is_constant_clb_net(to_net_id)
103103
&& !net_is_driven_by_direct(to_net_id)))) {
104104
for (from_iblk_pin = 0; from_iblk_pin < num_blk_pins; from_iblk_pin++) {
105-
int from_physical_pin = get_physical_pin(physical_tile, logical_block, from_iblk_pin);
105+
int from_physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, logical_block, from_iblk_pin);
106106

107107
from_net_id = cluster_ctx.clb_nlist.block_net(blk_id, from_iblk_pin);
108108
from_idirect = f_idirect_from_blk_pin[physical_tile->index][from_physical_pin];

vpr/src/util/vpr_utils.cpp

Lines changed: 33 additions & 26 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
auto logical_block = clb_nlist.block_type(clb);
319319
auto physical_tile = pick_best_physical_type(logical_block);
320320

321-
int physical_pin = get_physical_pin(physical_tile, logical_block, logical_pin);
321+
int physical_pin = get_physical_pin(physical_tile, /*z_index=*/0, logical_block, logical_pin);
322322

323323
if (is_opin(physical_pin, physical_tile)) {
324324
//output
@@ -2058,14 +2058,11 @@ void place_sync_external_block_connections(ClusterBlockId iblk) {
20582058
auto logical_block = clb_nlist.block_type(iblk);
20592059

20602060
VTR_ASSERT(physical_tile->num_pins % physical_tile->capacity == 0);
2061-
int max_num_block_pins = physical_tile->num_pins / physical_tile->capacity;
2062-
/* Logical location and physical location is offset by z * max_num_block_pins */
2063-
20642061
for (auto pin : clb_nlist.block_pins(iblk)) {
20652062
int logical_pin_index = clb_nlist.pin_logical_index(pin);
2066-
int physical_pin_index = get_physical_pin(physical_tile, logical_block, logical_pin_index);
2067-
2068-
int new_physical_pin_index = physical_pin_index + place_ctx.block_locs[iblk].loc.z * max_num_block_pins;
2063+
int new_physical_pin_index = get_physical_pin(
2064+
physical_tile, place_ctx.block_locs[iblk].loc.z,
2065+
logical_block, logical_pin_index);
20692066

20702067
auto result = place_ctx.physical_pins.find(pin);
20712068
if (result != place_ctx.physical_pins.end()) {
@@ -2127,32 +2124,34 @@ t_physical_tile_type_ptr get_physical_tile_type(const ClusterBlockId blk) {
21272124
}
21282125
}
21292126

2130-
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
2131-
t_logical_block_type_ptr logical_block,
2132-
int pin) {
2133-
t_physical_pin physical_pin(pin);
2134-
2135-
auto direct_map = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
2136-
auto result = direct_map.find(physical_pin);
2127+
int get_physical_pin(const ClusterBlockId blk,
2128+
t_logical_block_type_ptr logical_block,
2129+
int pin) {
2130+
auto& place_ctx = g_vpr_ctx.placement();
2131+
auto& device_ctx = g_vpr_ctx.device();
21372132

2138-
if (result == direct_map.inverse_end()) {
2139-
VTR_LOG_WARN(
2140-
"Couldn't find the corresponding logical pin of the physical pin %d."
2141-
"Physical Tile: %s, Logical Block: %s.\n",
2142-
pin, physical_tile->name, logical_block->name);
2143-
return OPEN;
2144-
}
2133+
auto block_loc = place_ctx.block_locs[blk];
2134+
auto loc = block_loc.loc;
21452135

2146-
return result->second.pin;
2136+
return get_physical_pin(
2137+
device_ctx.grid[loc.x][loc.y].type,
2138+
loc.z,
2139+
logical_block,
2140+
pin);
21472141
}
21482142

21492143
int get_physical_pin(t_physical_tile_type_ptr physical_tile,
2144+
int z_index,
21502145
t_logical_block_type_ptr logical_block,
21512146
int pin) {
2152-
t_logical_pin logical_pin(pin);
2153-
21542147
const auto& direct_map = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
2155-
auto result = direct_map.find(logical_pin);
2148+
auto result = direct_map.begin();
2149+
if (physical_tile->capacity_type == e_capacity_type::DUPLICATE) {
2150+
result = direct_map.find(t_logical_pin(/*z_index=*/0, pin));
2151+
} else {
2152+
VTR_ASSERT(physical_tile->capacity_type == e_capacity_type::EXPLICIT);
2153+
result = direct_map.find(t_logical_pin(z_index, pin));
2154+
}
21562155

21572156
if (result == direct_map.end()) {
21582157
VTR_LOG_WARN(
@@ -2162,7 +2161,15 @@ int get_physical_pin(t_physical_tile_type_ptr physical_tile,
21622161
return OPEN;
21632162
}
21642163

2165-
return result->second.pin;
2164+
int physical_pin_index = result->second.pin;
2165+
if (physical_tile->capacity_type == e_capacity_type::DUPLICATE) {
2166+
int max_num_block_pins = physical_tile->num_pins / physical_tile->capacity;
2167+
/* Logical location and physical location is offset by z * max_num_block_pins */
2168+
return physical_pin_index + z_index * max_num_block_pins;
2169+
} else {
2170+
VTR_ASSERT(physical_tile->capacity_type == e_capacity_type::EXPLICIT);
2171+
return physical_pin_index;
2172+
}
21662173
}
21672174

21682175
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) {

vpr/src/util/vpr_utils.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ t_logical_block_type_ptr pick_best_logical_type(t_physical_tile_type_ptr physica
163163
//the best expected physical tile the block should use (if no valid placement).
164164
t_physical_tile_type_ptr get_physical_tile_type(const ClusterBlockId blk);
165165

166-
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
167-
t_logical_block_type_ptr logical_block,
168-
int pin);
169166
int get_physical_pin(t_physical_tile_type_ptr physical_tile,
167+
int z_index,
168+
t_logical_block_type_ptr logical_block,
169+
int pin);
170+
int get_physical_pin(const ClusterBlockId blk,
170171
t_logical_block_type_ptr logical_block,
171172
int pin);
172173

0 commit comments

Comments
 (0)