Skip to content

add flat idx to pb_graph_node , populate in alloc_and_load_pb_graph #2590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libs/libarchfpga/src/physical_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,12 @@ struct t_pin_to_pin_annotation {
* parent_pb_graph_node : parent pb graph node
* total_primitive_count : Total number of this primitive type in the cluster. If there are 10 ALMs per cluster
* and 2 FFs per ALM (given the mode of the parent of this primitive) then the total is 20.
* This member is only used by nodes corresponding to primitive sites.
* flat_site_index : Index of this primitive site within its primitive type within this cluster type.
* Values are in [0...total_primitive_count-1], e.g. if there are 10 ALMs per cluster, 2 FFS
* and 2 LUTs per ALM, then flat site indices for FFs would run from 0 to 19, and flat site
indices for LUTs would run from 0 to 19. This member is only used by nodes corresponding
to primitive sites. It is used when reconstructing clusters from a flat placement file.
* illegal_modes : vector containing illegal modes that result in conflicts during routing
*/
class t_pb_graph_node {
Expand Down Expand Up @@ -1281,6 +1287,8 @@ class t_pb_graph_node {
int num_output_pin_class; /* number of output pin classes that this pb_graph_node has */

int total_primitive_count; /* total number of this primitive type in the cluster */
int flat_site_index; /* index of this primitive within sites of its type in this cluster */


/* Interconnect instances for this pb
* Only used for power
Expand Down
38 changes: 37 additions & 1 deletion vpr/src/pack/pb_type_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
t_pb_graph_node* parent_pb_graph_node,
t_pb_type* pb_type,
const int index,
const int flat_index,
bool load_power_structures,
int& pin_count_in_cluster);

Expand Down Expand Up @@ -134,6 +135,11 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin,
std::map<int, int>& edges_map,
int* line_num);

/* computes the index of a pb graph node at its level of the pb hierarchy */
static int compute_flat_index_for_child_node(int num_children_of_type,
int parent_flat_index,
int child_index);

/**
* Allocate memory into types and load the pb graph with interconnect edges
*/
Expand All @@ -151,6 +157,7 @@ void alloc_and_load_all_pb_graphs(bool load_power_structures, bool is_flat) {
nullptr,
type.pb_type,
0,
0,
load_power_structures,
pin_count_in_cluster);
type.pb_graph_head->total_pb_pins = pin_count_in_cluster;
Expand Down Expand Up @@ -224,6 +231,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
t_pb_graph_node* parent_pb_graph_node,
t_pb_type* pb_type,
const int index,
const int flat_index,
bool load_power_structures,
int& pin_count_in_cluster) {
int i, j, k, i_input, i_output, i_clockport;
Expand All @@ -237,6 +245,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
pb_graph_node->num_clock_ports = 0;

pb_graph_node->total_primitive_count = 0;
pb_graph_node->flat_site_index = 0;

/* Generate ports for pb graph node */
for (i = 0; i < pb_type->num_ports; i++) {
Expand Down Expand Up @@ -349,11 +358,15 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
sizeof(t_pb_graph_node*));
for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
pb_graph_node->child_pb_graph_nodes[i][j] = (t_pb_graph_node*)vtr::calloc(pb_type->modes[i].pb_type_children[j].num_pb, sizeof(t_pb_graph_node));
for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) {
int num_children_of_type = pb_type->modes[i].pb_type_children[j].num_pb;

for (k = 0; k < num_children_of_type; k++) {
int child_flat_index = compute_flat_index_for_child_node(num_children_of_type, flat_index, k);
alloc_and_load_pb_graph(&pb_graph_node->child_pb_graph_nodes[i][j][k],
pb_graph_node,
&pb_type->modes[i].pb_type_children[j],
k,
child_flat_index,
load_power_structures,
pin_count_in_cluster);
}
Expand All @@ -380,6 +393,10 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
pb_node = pb_node->parent_pb_graph_node;
}
pb_graph_node->total_primitive_count = total_count;

// if this is a primitive, then flat_index corresponds
// to its index within all primitives of this type
pb_graph_node->flat_site_index = flat_index;
}
}

Expand Down Expand Up @@ -1914,3 +1931,22 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c

return nullptr;
}

/* Date:June 8th, 2024
* Author: Kate Thurmer
* Purpose: This subroutine computes the index of a pb graph node at its
level of the pb hierarchy; it is computed by the parent and
passed to each child of each child pb type. When the child is
a primitive, the computed indes is its flat site index.
For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs,
then the ALM at index N, when calling this function for
its FF child at index M, would compute the child's index as:
N*(FFs per ALM) + M
e.g. for FF[1] in ALM[5], this returns
5*(2 FFS per ALM) + 1 = 11
*/
static int compute_flat_index_for_child_node(int num_children_of_type,
int parent_flat_index,
int child_index) {
return parent_flat_index*num_children_of_type + child_index;
}
Loading