@@ -48,6 +48,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
48
48
t_pb_graph_node* parent_pb_graph_node,
49
49
t_pb_type* pb_type,
50
50
const int index,
51
+ const int flat_index,
51
52
bool load_power_structures,
52
53
int & pin_count_in_cluster);
53
54
@@ -134,6 +135,11 @@ static bool check_input_pins_equivalence(const t_pb_graph_pin* cur_pin,
134
135
std::map<int , int >& edges_map,
135
136
int * line_num);
136
137
138
+ /* computes the index of a pb graph node at its level of the pb hierarchy */
139
+ static int compute_flat_index_for_child_node (int num_children_of_type,
140
+ int parent_flat_index,
141
+ int child_index);
142
+
137
143
/* *
138
144
* Allocate memory into types and load the pb graph with interconnect edges
139
145
*/
@@ -151,6 +157,7 @@ void alloc_and_load_all_pb_graphs(bool load_power_structures, bool is_flat) {
151
157
nullptr ,
152
158
type.pb_type ,
153
159
0 ,
160
+ 0 ,
154
161
load_power_structures,
155
162
pin_count_in_cluster);
156
163
type.pb_graph_head ->total_pb_pins = pin_count_in_cluster;
@@ -224,6 +231,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
224
231
t_pb_graph_node* parent_pb_graph_node,
225
232
t_pb_type* pb_type,
226
233
const int index,
234
+ const int flat_index,
227
235
bool load_power_structures,
228
236
int & pin_count_in_cluster) {
229
237
int i, j, k, i_input, i_output, i_clockport;
@@ -237,6 +245,7 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
237
245
pb_graph_node->num_clock_ports = 0 ;
238
246
239
247
pb_graph_node->total_primitive_count = 0 ;
248
+ pb_graph_node->flat_site_index = 0 ;
240
249
241
250
/* Generate ports for pb graph node */
242
251
for (i = 0 ; i < pb_type->num_ports ; i++) {
@@ -349,11 +358,15 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
349
358
sizeof (t_pb_graph_node*));
350
359
for (j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
351
360
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));
352
- for (k = 0 ; k < pb_type->modes [i].pb_type_children [j].num_pb ; k++) {
361
+ int num_children_of_type = pb_type->modes [i].pb_type_children [j].num_pb ;
362
+
363
+ for (k = 0 ; k < num_children_of_type; k++) {
364
+ int child_flat_index = compute_flat_index_for_child_node (num_children_of_type, flat_index, k);
353
365
alloc_and_load_pb_graph (&pb_graph_node->child_pb_graph_nodes [i][j][k],
354
366
pb_graph_node,
355
367
&pb_type->modes [i].pb_type_children [j],
356
368
k,
369
+ child_flat_index,
357
370
load_power_structures,
358
371
pin_count_in_cluster);
359
372
}
@@ -380,6 +393,10 @@ static void alloc_and_load_pb_graph(t_pb_graph_node* pb_graph_node,
380
393
pb_node = pb_node->parent_pb_graph_node ;
381
394
}
382
395
pb_graph_node->total_primitive_count = total_count;
396
+
397
+ // if this is a primitive, then flat_index corresponds
398
+ // to its index within all primitives of this type
399
+ pb_graph_node->flat_site_index = flat_index;
383
400
}
384
401
}
385
402
@@ -1914,3 +1931,22 @@ const t_pb_graph_edge* get_edge_between_pins(const t_pb_graph_pin* driver_pin, c
1914
1931
1915
1932
return nullptr ;
1916
1933
}
1934
+
1935
+ /* Date:June 8th, 2024
1936
+ * Author: Kate Thurmer
1937
+ * Purpose: This subroutine computes the index of a pb graph node at its
1938
+ level of the pb hierarchy; it is computed by the parent and
1939
+ passed to each child of each child pb type. When the child is
1940
+ a primitive, the computed indes is its flat site index.
1941
+ For example, if there are 10 ALMs, each with 2 FFs and 2 LUTs,
1942
+ then the ALM at index N, when calling this function for
1943
+ its FF child at index M, would compute the child's index as:
1944
+ N*(FFs per ALM) + M
1945
+ e.g. for FF[1] in ALM[5], this returns
1946
+ 5*(2 FFS per ALM) + 1 = 11
1947
+ */
1948
+ static int compute_flat_index_for_child_node (int num_children_of_type,
1949
+ int parent_flat_index,
1950
+ int child_index) {
1951
+ return parent_flat_index*num_children_of_type + child_index;
1952
+ }
0 commit comments