@@ -134,6 +134,9 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin,
134
134
const int i_pin,
135
135
std::map<int , int >& edges_map,
136
136
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);
137
140
138
141
/* *
139
142
* 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,
240
243
pb_graph_node->num_clock_ports = 0 ;
241
244
242
245
pb_graph_node->total_primitive_count = 0 ;
243
- pb_graph_node->flat_site_index = flat_index ;
246
+ pb_graph_node->flat_site_index = 0 ;
244
247
245
248
/* Generate ports for pb graph node */
246
249
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,
353
356
sizeof (t_pb_graph_node*));
354
357
for (j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
355
358
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 ;
357
360
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);
359
363
alloc_and_load_pb_graph (&pb_graph_node->child_pb_graph_nodes [i][j][k],
360
364
pb_graph_node,
361
365
&pb_type->modes [i].pb_type_children [j],
362
366
k,
363
- base + k ,
367
+ child_flat_index ,
364
368
load_power_structures,
365
369
pin_count_in_cluster);
366
370
}
@@ -387,6 +391,10 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
387
391
pb_node = pb_node->parent_pb_graph_node ;
388
392
}
389
393
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;
390
398
}
391
399
}
392
400
@@ -1921,3 +1929,22 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c
1921
1929
1922
1930
return nullptr ;
1923
1931
}
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