Skip to content

Commit e6f473b

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 c5197e5 commit e6f473b

File tree

10 files changed

+221
-92
lines changed

10 files changed

+221
-92
lines changed

libs/libarchfpga/src/physical_types.h

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

524524
};
525525

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

@@ -577,6 +583,7 @@ struct t_physical_tile_type {
577583
int num_clock_pins = 0;
578584

579585
int capacity = 0;
586+
e_capacity_type capacity_type = e_capacity_type::DUPLICATE;
580587

581588
int width = 0;
582589
int height = 0;
@@ -625,18 +632,20 @@ struct t_physical_tile_type {
625632
* vtr::bimap container.
626633
*/
627634
struct t_logical_pin {
635+
int z_index = -1;
628636
int pin = -1;
629637

630-
t_logical_pin(int value) {
638+
t_logical_pin(int z_index_value, int value) {
639+
z_index = z_index_value;
631640
pin = value;
632641
}
633642

634643
bool operator==(const t_logical_pin o) const {
635-
return pin == o.pin;
644+
return z_index == o.z_index && pin == o.pin;
636645
}
637646

638647
bool operator<(const t_logical_pin o) const {
639-
return pin < o.pin;
648+
return std::make_pair(z_index, pin) < std::make_pair(o.z_index, o.pin);
640649
}
641650
};
642651

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
@@ -95,7 +95,7 @@ static int check_connections_to_global_clb_pins(ClusterNetId net_id, int verbosi
9595
auto physical_type = pick_best_physical_type(logical_type);
9696

9797
int log_index = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
98-
int pin_index = get_physical_pin(physical_type, logical_type, log_index);
98+
int pin_index = get_physical_pin(physical_type, /*z_index=*/0, logical_type, log_index);
9999

100100
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored
101101
&& !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
@@ -2666,7 +2666,7 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type, ClusterBlockId b
26662666
continue;
26672667

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

26712671
iclass = physical_tile->pin_class[physical_pin];
26722672

vpr/src/pack/output_clustering.cpp

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

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: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ std::vector<AtomPinId> find_clb_pin_connected_atom_pins(ClusterBlockId clb, int
319319
auto logical_block = clb_nlist.block_type(clb);
320320
auto physical_tile = pick_best_physical_type(logical_block);
321321

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

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

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

20712068
auto result = place_ctx.physical_pins.find(pin);
20722069
if (result != place_ctx.physical_pins.end()) {
@@ -2128,32 +2125,34 @@ t_physical_tile_type_ptr get_physical_tile_type(const ClusterBlockId blk) {
21282125
}
21292126
}
21302127

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

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

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

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

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

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

21692176
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
@@ -165,10 +165,11 @@ t_logical_block_type_ptr pick_best_logical_type(t_physical_tile_type_ptr physica
165165
//the best expected physical tile the block should use (if no valid placement).
166166
t_physical_tile_type_ptr get_physical_tile_type(const ClusterBlockId blk);
167167

168-
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
169-
t_logical_block_type_ptr logical_block,
170-
int pin);
171168
int get_physical_pin(t_physical_tile_type_ptr physical_tile,
169+
int z_index,
170+
t_logical_block_type_ptr logical_block,
171+
int pin);
172+
int get_physical_pin(const ClusterBlockId blk,
172173
t_logical_block_type_ptr logical_block,
173174
int pin);
174175

0 commit comments

Comments
 (0)