Skip to content

Commit 2918b9d

Browse files
committed
updated comments, added subrouting for flat index computation
1 parent f9b3cd7 commit 2918b9d

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,12 @@ struct t_pin_to_pin_annotation {
12251225
* parent_pb_graph_node : parent pb graph node
12261226
* total_primitive_count : Total number of this primitive type in the cluster. If there are 10 ALMs per cluster
12271227
* and 2 FFs per ALM (given the mode of the parent of this primitive) then the total is 20.
1228-
* flat_site_index : index of this primitive within its primitive type in this cluster; in [0,...,total_primitive_count]
1228+
* This member is only used by nodes corresponding to primitive sites.
1229+
* flat_site_index : Index of this primitive site within its primitive type within this cluster type.
1230+
* Values are in [0...total_primitive_count-1], e.g. if there are 10 ALMs per cluster, 2 FFS
1231+
* and 2 LUTs per ALM, then flat site indices for FFs would run from 0 to 19, and flat site
1232+
indices for LUTs would run from 0 to 19. This member is only used by nodes corresponding
1233+
to primitive sites. It is used when reconstructing clusters from a flat placement file.
12291234
* illegal_modes : vector containing illegal modes that result in conflicts during routing
12301235
*/
12311236
class t_pb_graph_node {

vpr/src/pack/pb_type_graph.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin,
134134
const int i_pin,
135135
std::map<int, int>& edges_map,
136136
int* line_num);
137+
static int compute_flat_index_for_child_node(int num_children_of_type,
138+
int parent_flat_index,
139+
int child_index);
137140

138141
/**
139142
* Allocate memory into types and load the pb graph with interconnect edges
@@ -240,7 +243,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
240243
pb_graph_node->num_clock_ports = 0;
241244

242245
pb_graph_node->total_primitive_count = 0;
243-
pb_graph_node->flat_site_index = flat_index;
246+
pb_graph_node->flat_site_index = 0;
244247

245248
/* Generate ports for pb graph node */
246249
for (i = 0; i < pb_type->num_ports; i++) {
@@ -353,14 +356,15 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
353356
sizeof(t_pb_graph_node*));
354357
for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
355358
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));
356-
int base = flat_index*(pb_type->modes[i].pb_type_children[j].num_pb);
359+
int num_children_of_type = pb_type->modes[i].pb_type_children[j].num_pb;
357360

358-
for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) {
361+
for (k = 0; k < num_children_of_type; k++) {
362+
int child_flat_index = compute_flat_index_for_child_node(num_children_of_type, flat_index, k);
359363
alloc_and_load_pb_graph(&pb_graph_node->child_pb_graph_nodes[i][j][k],
360364
pb_graph_node,
361365
&pb_type->modes[i].pb_type_children[j],
362366
k,
363-
base + k,
367+
child_flat_index,
364368
load_power_structures,
365369
pin_count_in_cluster);
366370
}
@@ -387,6 +391,10 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
387391
pb_node = pb_node->parent_pb_graph_node;
388392
}
389393
pb_graph_node->total_primitive_count = total_count;
394+
395+
// if this is a primitive, then flat_index corresponds
396+
// to its index within all primitives of this type
397+
pb_graph_node->flat_site_index = flat_index;
390398
}
391399
}
392400

@@ -1921,3 +1929,22 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c
19211929

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

0 commit comments

Comments
 (0)