Skip to content

Commit d89ea99

Browse files
Merge pull request #3050 from verilog-to-routing/temp_rr_graph_gen_dir
RR graph generation directory
2 parents 87eefdb + 1681fa1 commit d89ea99

40 files changed

+801
-772
lines changed

libs/libarchfpga/src/physical_types.cpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,71 @@ const t_port* t_logical_block_type::get_port_by_pin(int pin) const {
252252
return nullptr;
253253
}
254254

255-
/**
255+
/*
256+
* t_pb_type
257+
*/
258+
259+
int t_pb_type::get_max_primitives() const {
260+
int max_size;
261+
262+
if (modes == nullptr) {
263+
max_size = 1;
264+
} else {
265+
max_size = 0;
266+
int temp_size = 0;
267+
for (int i = 0; i < num_modes; i++) {
268+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
269+
temp_size += modes[i].pb_type_children[j].num_pb * modes[i].pb_type_children[j].get_max_primitives();
270+
}
271+
if (temp_size > max_size) {
272+
max_size = temp_size;
273+
}
274+
}
275+
}
276+
277+
return max_size;
278+
}
279+
280+
/* finds maximum number of nets that can be contained in pb_type, this is bounded by the number of driving pins */
281+
int t_pb_type::get_max_nets() const {
282+
int max_nets;
283+
if (modes == nullptr) {
284+
max_nets = num_output_pins;
285+
} else {
286+
max_nets = 0;
287+
288+
for (int i = 0; i < num_modes; i++) {
289+
int temp_nets = 0;
290+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
291+
temp_nets += modes[i].pb_type_children[j].num_pb * modes[i].pb_type_children[j].get_max_nets();
292+
}
293+
294+
if (temp_nets > max_nets) {
295+
max_nets = temp_nets;
296+
}
297+
}
298+
}
299+
300+
if (is_root()) {
301+
max_nets += num_input_pins + num_output_pins + num_clock_pins;
302+
}
303+
304+
return max_nets;
305+
}
306+
307+
int t_pb_type::get_max_depth() const {
308+
int max_depth = depth;
309+
310+
for (int i = 0; i < num_modes; i++) {
311+
for (int j = 0; j < modes[i].num_pb_type_children; j++) {
312+
int temp_depth = modes[i].pb_type_children[j].get_max_depth();
313+
max_depth = std::max(max_depth, temp_depth);
314+
}
315+
}
316+
return max_depth;
317+
}
318+
319+
/*
256320
* t_pb_graph_node
257321
*/
258322

libs/libarchfpga/src/physical_types.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,11 @@ struct t_physical_tile_type {
725725
///@brief Is this t_physical_tile_type an empty type?
726726
bool is_empty() const;
727727

728+
///@brief Returns true if the physical tile type can implement either a .input or .output block type
729+
inline bool is_io() const {
730+
return is_input_type || is_output_type;
731+
}
732+
728733
///@brief Returns the relative pin index within a sub tile that corresponds to the pin within the given port and its index in the port
729734
int find_pin(std::string_view port_name, int pin_index_in_port) const;
730735

@@ -1087,6 +1092,10 @@ struct t_pb_type {
10871092
inline bool is_primitive() const {
10881093
return num_modes == 0;
10891094
}
1095+
1096+
int get_max_primitives() const;
1097+
int get_max_depth() const;
1098+
int get_max_nets() const;
10901099
};
10911100

10921101
/** Describes an operational mode of a clustered logic block

libs/libarchfpga/src/physical_types_util.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -637,21 +637,6 @@ bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from
637637
return false;
638638
}
639639

640-
// TODO: Remove is_input_type / is_output_type / is_io_type as part of
641-
// https://github.com/verilog-to-routing/vtr-verilog-to-routing/issues/1193
642-
bool is_input_type(t_physical_tile_type_ptr type) {
643-
return type->is_input_type;
644-
}
645-
646-
bool is_output_type(t_physical_tile_type_ptr type) {
647-
return type->is_output_type;
648-
}
649-
650-
bool is_io_type(t_physical_tile_type_ptr type) {
651-
return is_input_type(type)
652-
|| is_output_type(type);
653-
}
654-
655640
std::string block_type_pin_index_to_name(t_physical_tile_type_ptr type, int pin_physical_num, bool is_flat) {
656641
int max_ptc = get_tile_pin_max_ptc(type, is_flat);
657642
VTR_ASSERT(pin_physical_num < max_ptc);

libs/libarchfpga/src/physical_types_util.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,6 @@ bool is_opin(int ipin, t_physical_tile_type_ptr type);
120120
///@brief Returns true if the specified pin is located at "from_layer" and it is connected to "to_layer"
121121
bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from_layer, int to_layer, int num_of_avail_layer);
122122

123-
///@brief Returns true if the given physical tile type can implement a .input block type
124-
bool is_input_type(t_physical_tile_type_ptr type);
125-
///@brief Returns true if the given physical tile type can implement a .output block type
126-
bool is_output_type(t_physical_tile_type_ptr type);
127-
///@brief Returns true if the given physical tile type can implement either a .input or .output block type
128-
bool is_io_type(t_physical_tile_type_ptr type);
129-
130123
/**
131124
* @brief Returns the corresponding physical pin based on the input parameters:
132125
*

vpr/src/base/ShowSetup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ClusteredNetlistStats::ClusteredNetlistStats() {
135135
auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
136136
auto physical_tile = pick_physical_type(logical_block);
137137
num_blocks_type[logical_block->index]++;
138-
if (is_io_type(physical_tile)) {
138+
if (physical_tile->is_io()) {
139139
for (int j = 0; j < logical_block->pb_type->num_pins; j++) {
140140
int physical_pin = get_physical_pin(physical_tile, logical_block, j);
141141

vpr/src/base/check_netlist.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ static int check_connections_to_global_clb_pins(ClusterNetId net_id, int verbosi
110110
int log_index = cluster_ctx.clb_nlist.pin_logical_index(pin_id);
111111
int pin_index = get_physical_pin(physical_type, logical_type, log_index);
112112

113-
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored
114-
&& !is_io_type(physical_type)) {
113+
if (physical_type->is_ignored_pin[pin_index] != net_is_ignored && !physical_type->is_io()) {
115114
VTR_LOGV_WARN(verbosity > 2,
116115
"Global net '%s' connects to non-global architecture pin '%s' (netlist pin '%s')\n",
117116
cluster_ctx.clb_nlist.net_name(net_id).c_str(),

vpr/src/base/read_route.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static void process_nodes(const Netlist<>& net_list, std::ifstream& fp, ClusterN
296296
/* Verify types and ptc*/
297297
if (tokens[2] == "SOURCE" || tokens[2] == "SINK" || tokens[2] == "OPIN" || tokens[2] == "IPIN") {
298298
const auto& type = device_ctx.grid.get_physical_type({x, y, layer_num});
299-
if (tokens[4 + offset] == "Pad:" && !is_io_type(type)) {
299+
if (tokens[4 + offset] == "Pad:" && !type->is_io()) {
300300
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
301301
"Node %d is of the wrong type", inode);
302302
}
@@ -319,7 +319,7 @@ static void process_nodes(const Netlist<>& net_list, std::ifstream& fp, ClusterN
319319
if (tokens[6 + offset] != "Switch:") {
320320
/*This is an opin or ipin, process its pin nums*/
321321
auto type = device_ctx.grid.get_physical_type({x, y, layer_num});
322-
if (!is_io_type(type) && (tokens[2] == "IPIN" || tokens[2] == "OPIN")) {
322+
if (!type->is_io() && (tokens[2] == "IPIN" || tokens[2] == "OPIN")) {
323323
int pin_num = rr_graph.node_pin_num(RRNodeId(inode));
324324
int width_offset = device_ctx.grid.get_width_offset({x, y, layer_num});
325325
int height_offset = device_ctx.grid.get_height_offset({x, y, layer_num});
@@ -592,10 +592,13 @@ void print_route(const Netlist<>& net_list,
592592
fprintf(fp, "to (%d,%d,%d) ", rr_graph.node_xhigh(inode),
593593
rr_graph.node_yhigh(inode), layer_num);
594594

595+
t_physical_tile_type_ptr physical_tile = device_ctx.grid.get_physical_type({ilow, jlow, layer_num});
596+
595597
switch (rr_type) {
596598
case e_rr_type::IPIN:
597599
case e_rr_type::OPIN:
598-
if (is_io_type(device_ctx.grid.get_physical_type({ilow, jlow, layer_num}))) {
600+
601+
if (physical_tile->is_io()) {
599602
fprintf(fp, " Pad: ");
600603
} else { /* IO Pad. */
601604
fprintf(fp, " Pin: ");
@@ -609,7 +612,7 @@ void print_route(const Netlist<>& net_list,
609612

610613
case e_rr_type::SOURCE:
611614
case e_rr_type::SINK:
612-
if (is_io_type(device_ctx.grid.get_physical_type({ilow, jlow, layer_num}))) {
615+
if (physical_tile->is_io()) {
613616
fprintf(fp, " Pad: ");
614617
} else { /* IO Pad. */
615618
fprintf(fp, " Class: ");
@@ -625,8 +628,7 @@ void print_route(const Netlist<>& net_list,
625628

626629
fprintf(fp, "%d ", rr_graph.node_ptc_num(inode));
627630

628-
auto physical_tile = device_ctx.grid.get_physical_type({ilow, jlow, layer_num});
629-
if (!is_io_type(physical_tile) && (rr_type == e_rr_type::IPIN || rr_type == e_rr_type::OPIN)) {
631+
if (!physical_tile->is_io() && (rr_type == e_rr_type::IPIN || rr_type == e_rr_type::OPIN)) {
630632
int pin_num = rr_graph.node_pin_num(inode);
631633
int xoffset = device_ctx.grid.get_width_offset({ilow, jlow, layer_num});
632634
int yoffset = device_ctx.grid.get_height_offset({ilow, jlow, layer_num});

vpr/src/base/stats.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ void routing_stats(const Netlist<>& net_list,
9191
auto type = device_ctx.grid.get_physical_type({i, j, layer_num});
9292
int width_offset = device_ctx.grid.get_width_offset({i, j, layer_num});
9393
int height_offset = device_ctx.grid.get_height_offset({i, j, layer_num});
94-
if (width_offset == 0
95-
&& height_offset == 0
96-
&& !is_io_type(type)
97-
&& type != device_ctx.EMPTY_PHYSICAL_TILE_TYPE) {
94+
if (width_offset == 0 && height_offset == 0 && !type->is_io() && !type->is_empty()) {
9895
if (type->area == UNDEFINED) {
9996
area += grid_logic_tile_area * type->width * type->height;
10097
} else {
@@ -111,7 +108,7 @@ void routing_stats(const Netlist<>& net_list,
111108
for (ClusterBlockId blk_id : cluster_ctx.clb_nlist.blocks()) {
112109
t_pl_loc block_loc = block_locs[blk_id].loc;
113110
auto type = physical_tile_type(block_loc);
114-
if (!is_io_type(type)) {
111+
if (!type->is_io()) {
115112
if (type->area == UNDEFINED) {
116113
used_area += grid_logic_tile_area * type->width * type->height;
117114
} else {
@@ -473,7 +470,7 @@ void print_lambda() {
473470
t_pl_loc block_loc = block_locs[blk_id].loc;
474471
auto type = physical_tile_type(block_loc);
475472
VTR_ASSERT(type != nullptr);
476-
if (!is_io_type(type)) {
473+
if (!type->is_io()) {
477474
for (int ipin = 0; ipin < type->num_pins; ipin++) {
478475
if (get_pin_type_from_pin_physical_num(type, ipin) == RECEIVER) {
479476
ClusterNetId net_id = cluster_ctx.clb_nlist.block_net(blk_id, ipin);

vpr/src/pack/appack_max_dist_th_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void APPackMaxDistThManager::auto_set_max_distance_thresholds(const std::vector<
100100
// Find which type(s) this logical block type looks like.
101101
bool has_memory = has_memory_pbs(lb_ty.pb_type);
102102
bool is_logic_block_type = (lb_ty.index == logic_block_type->index);
103-
bool is_io_block = is_io_type(pick_physical_type(&lb_ty));
103+
bool is_io_block = pick_physical_type(&lb_ty)->is_io();
104104

105105
// Update the max distance threshold based on the type. If the logical
106106
// block type looks like many block types at the same time (for example

vpr/src/place/initial_placement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,10 @@ static inline void fix_IO_block_types(const t_pl_macro& pl_macro,
10121012
vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
10131013
const auto& device_ctx = g_vpr_ctx.device();
10141014

1015-
//If the user marked the IO block pad_loc_type as RANDOM, that means it should be randomly
1016-
//placed and then stay fixed to that location, which is why the macro members are marked as fixed.
1017-
const auto& type = device_ctx.grid.get_physical_type({loc.x, loc.y, loc.layer});
1018-
if (is_io_type(type) && pad_loc_type == e_pad_loc_type::RANDOM) {
1015+
// If the user marked the IO block pad_loc_type as RANDOM, that means it should be randomly
1016+
// placed and then stay fixed to that location, which is why the macro members are marked as fixed.
1017+
const t_physical_tile_type_ptr type = device_ctx.grid.get_physical_type({loc.x, loc.y, loc.layer});
1018+
if (type->is_io() && pad_loc_type == e_pad_loc_type::RANDOM) {
10191019
for (const t_pl_macro_member& pl_macro_member : pl_macro.members) {
10201020
block_locs[pl_macro_member.blk_index].is_fixed = true;
10211021
}

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static t_clb_opins_used alloc_and_load_clb_opins_used_locally() {
358358

359359
clb_opins_used_locally[blk_id].resize((int)type->class_inf.size());
360360

361-
if (is_io_type(type)) continue;
361+
if (type->is_io()) continue;
362362

363363
const auto [pin_low, pin_high] = get_pin_range_for_block(blk_id);
364364

vpr/src/route/router_lookahead_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void compute_tiles_lookahead(std::unordered_map<int, util::t_ipin_primiti
8989
const t_det_routing_arch& det_routing_arch,
9090
const DeviceContext& device_ctx);
9191
/***
92-
* @brief Compute the cose from tile pins to tile sinks
92+
* @brief Compute the cost from tile pins to tile sinks
9393
* @param intra_tile_pin_primitive_pin_delay [physical_tile_type_idx][from_pin_ptc_num][sink_ptc_num] -> cost
9494
* @param physical_tile
9595
* @param det_routing_arch

vpr/src/route/rr_graph.cpp renamed to vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "edge_groups.h"
3434
#include "rr_graph_builder.h"
3535
#include "rr_types.h"
36+
#include "rr_node_indices.h"
3637

3738
//#define VERBOSE
3839
//used for getting the exact count of each edge type and printing it to std out.

0 commit comments

Comments
 (0)