35 INP int index,
boolean load_power_structures);
40 INP const t_mode * mode,
boolean load_power_structures);
45 INP boolean interconnect_error_check,
INP boolean is_input_to_interc,
55 INP int num_input_sets,
INP int *num_input_ptrs,
57 INP int num_output_sets,
INP int *num_output_ptrs);
62 INP int num_input_sets,
INP int *num_input_ptrs,
64 INP int num_output_sets,
INP int *num_output_ptrs);
68 INP int num_input_sets,
INP int *num_input_ptrs,
70 INP int num_output_sets,
INP int *num_output_ptrs);
77 INP int level,
INP FILE * fp);
82 int num_input_sets,
int * num_input_pins,
84 int * num_output_pins);
92 num_edges_head = NULL;
149 fprintf(fp,
"Physical Blocks Graph\n");
150 fprintf(fp,
"--------------------------------------------\n\n");
180 INP int index,
boolean load_power_structures) {
181 int i, j, k, i_input, i_output, i_clockport;
183 pb_graph_node->placement_index = index;
184 pb_graph_node->pb_type = pb_type;
185 pb_graph_node->parent_pb_graph_node = parent_pb_graph_node;
187 pb_graph_node->num_input_ports = 0;
188 pb_graph_node->num_output_ports = 0;
189 pb_graph_node->num_clock_ports = 0;
192 for (i = 0; i < pb_type->num_ports; i++) {
193 if (pb_type->ports[i].type ==
IN_PORT && !pb_type->ports[i].is_clock) {
194 pb_graph_node->num_input_ports++;
195 }
else if (pb_type->ports[i].type ==
OUT_PORT) {
196 assert(!pb_type->ports[i].is_clock);
197 pb_graph_node->num_output_ports++;
200 pb_type->ports[i].is_clock && pb_type->ports[i].type ==
IN_PORT);
201 pb_graph_node->num_clock_ports++;
205 pb_graph_node->num_input_pins = (
int*)
my_calloc(
206 pb_graph_node->num_input_ports,
sizeof(
int));
207 pb_graph_node->num_output_pins = (
int*)
my_calloc(
208 pb_graph_node->num_output_ports,
sizeof(
int));
209 pb_graph_node->num_clock_pins = (
int*)
my_calloc(
210 pb_graph_node->num_clock_ports,
sizeof(
int));
219 i_input = i_output = i_clockport = 0;
220 for (i = 0; i < pb_type->num_ports; i++) {
221 if (pb_type->ports[i].model_port) {
222 assert(pb_type->num_modes == 0);
224 assert(pb_type->num_modes != 0 || pb_type->ports[i].is_clock);
226 if (pb_type->ports[i].type ==
IN_PORT && !pb_type->ports[i].is_clock) {
229 pb_graph_node->num_input_pins[i_input] = pb_type->ports[i].num_pins;
230 for (j = 0; j < pb_type->ports[i].num_pins; j++) {
231 pb_graph_node->input_pins[i_input][j].input_edges = NULL;
232 pb_graph_node->input_pins[i_input][j].num_input_edges = 0;
233 pb_graph_node->input_pins[i_input][j].output_edges = NULL;
234 pb_graph_node->input_pins[i_input][j].num_output_edges = 0;
235 pb_graph_node->input_pins[i_input][j].pin_number = j;
236 pb_graph_node->input_pins[i_input][j].port = &pb_type->ports[i];
237 pb_graph_node->input_pins[i_input][j].parent_node =
239 pb_graph_node->input_pins[i_input][j].pin_count_in_cluster =
242 if (pb_graph_node->pb_type->blif_model != NULL ) {
243 if (strcmp(pb_graph_node->pb_type->blif_model,
".output")
245 pb_graph_node->input_pins[i_input][j].type =
247 }
else if (pb_graph_node->num_clock_ports != 0) {
248 pb_graph_node->input_pins[i_input][j].type =
251 pb_graph_node->input_pins[i_input][j].type =
258 }
else if (pb_type->ports[i].type ==
OUT_PORT) {
261 pb_graph_node->num_output_pins[i_output] =
262 pb_type->ports[i].num_pins;
263 for (j = 0; j < pb_type->ports[i].num_pins; j++) {
264 pb_graph_node->output_pins[i_output][j].input_edges = NULL;
265 pb_graph_node->output_pins[i_output][j].num_input_edges = 0;
266 pb_graph_node->output_pins[i_output][j].output_edges = NULL;
267 pb_graph_node->output_pins[i_output][j].num_output_edges = 0;
268 pb_graph_node->output_pins[i_output][j].pin_number = j;
269 pb_graph_node->output_pins[i_output][j].port =
271 pb_graph_node->output_pins[i_output][j].parent_node =
273 pb_graph_node->output_pins[i_output][j].pin_count_in_cluster =
275 pb_graph_node->output_pins[i_output][j].type =
PB_PIN_NORMAL;
276 if (pb_graph_node->pb_type->blif_model != NULL ) {
277 if (strcmp(pb_graph_node->pb_type->blif_model,
".input")
279 pb_graph_node->output_pins[i_output][j].type =
281 }
else if (pb_graph_node->num_clock_ports != 0) {
282 pb_graph_node->output_pins[i_output][j].type =
285 pb_graph_node->output_pins[i_output][j].type =
294 pb_type->ports[i].is_clock && pb_type->ports[i].type ==
IN_PORT);
295 pb_graph_node->clock_pins[i_clockport] =
298 pb_graph_node->num_clock_pins[i_clockport] =
299 pb_type->ports[i].num_pins;
300 for (j = 0; j < pb_type->ports[i].num_pins; j++) {
301 pb_graph_node->clock_pins[i_clockport][j].input_edges = NULL;
302 pb_graph_node->clock_pins[i_clockport][j].num_input_edges = 0;
303 pb_graph_node->clock_pins[i_clockport][j].output_edges = NULL;
304 pb_graph_node->clock_pins[i_clockport][j].num_output_edges = 0;
305 pb_graph_node->clock_pins[i_clockport][j].pin_number = j;
306 pb_graph_node->clock_pins[i_clockport][j].port =
308 pb_graph_node->clock_pins[i_clockport][j].parent_node =
310 pb_graph_node->clock_pins[i_clockport][j].pin_count_in_cluster =
312 pb_graph_node->clock_pins[i_clockport][j].type =
PB_PIN_NORMAL;
313 if (pb_graph_node->pb_type->blif_model != NULL ) {
314 pb_graph_node->clock_pins[i_clockport][j].type =
324 if (load_power_structures) {
327 pb_graph_node->pb_node_power->transistor_cnt_buffers = 0.;
328 pb_graph_node->pb_node_power->transistor_cnt_interc = 0.;
329 pb_graph_node->pb_node_power->transistor_cnt_pb_children = 0.;
335 for (i = 0; i < pb_type->num_modes; i++) {
337 pb_type->modes[i].num_pb_type_children,
339 for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
340 pb_graph_node->child_pb_graph_nodes[i][j] =
342 pb_type->modes[i].pb_type_children[j].num_pb,
344 for (k = 0; k < pb_type->modes[i].pb_type_children[j].num_pb; k++) {
346 &pb_graph_node->child_pb_graph_nodes[i][j][k],
347 pb_graph_node, &pb_type->modes[i].pb_type_children[j],
348 k, load_power_structures);
355 for (i = 0; i < pb_type->num_modes; i++) {
358 pb_graph_node->child_pb_graph_nodes[i], &pb_type->modes[i],
359 load_power_structures);
369 pb_type = pb_graph_node->pb_type;
375 for (i = 0; i < pb_graph_node->num_input_ports; i++) {
376 for (j = 0; j < pb_graph_node->num_input_pins[i]; j++) {
377 if (pb_graph_node->input_pins[i][j].pin_timing)
378 free(pb_graph_node->input_pins[i][j].pin_timing);
379 if (pb_graph_node->input_pins[i][j].pin_timing_del_max)
380 free(pb_graph_node->input_pins[i][j].pin_timing_del_max);
381 if (pb_graph_node->input_pins[i][j].input_edges)
382 free(pb_graph_node->input_pins[i][j].input_edges);
383 if (pb_graph_node->input_pins[i][j].output_edges)
384 free(pb_graph_node->input_pins[i][j].output_edges);
385 if (pb_graph_node->input_pins[i][j].parent_pin_class)
386 free(pb_graph_node->input_pins[i][j].parent_pin_class);
388 free(pb_graph_node->input_pins[i]);
390 for (i = 0; i < pb_graph_node->num_output_ports; i++) {
391 for (j = 0; j < pb_graph_node->num_output_pins[i]; j++) {
392 if (pb_graph_node->output_pins[i][j].pin_timing)
393 free(pb_graph_node->output_pins[i][j].pin_timing);
394 if (pb_graph_node->output_pins[i][j].pin_timing_del_max)
395 free(pb_graph_node->output_pins[i][j].pin_timing_del_max);
396 if (pb_graph_node->output_pins[i][j].input_edges)
397 free(pb_graph_node->output_pins[i][j].input_edges);
398 if (pb_graph_node->output_pins[i][j].output_edges)
399 free(pb_graph_node->output_pins[i][j].output_edges);
400 if (pb_graph_node->output_pins[i][j].parent_pin_class)
401 free(pb_graph_node->output_pins[i][j].parent_pin_class);
403 if (pb_graph_node->output_pins[i][j].list_of_connectable_input_pin_ptrs) {
404 for (k = 0; k < pb_graph_node->pb_type->depth; k++) {
405 if (pb_graph_node->output_pins[i][j].list_of_connectable_input_pin_ptrs[k]) {
407 pb_graph_node->output_pins[i][j].list_of_connectable_input_pin_ptrs[k]);
411 pb_graph_node->output_pins[i][j].list_of_connectable_input_pin_ptrs);
414 if (pb_graph_node->output_pins[i][j].num_connectable_primtive_input_pins)
416 pb_graph_node->output_pins[i][j].num_connectable_primtive_input_pins);
418 free(pb_graph_node->output_pins[i]);
420 for (i = 0; i < pb_graph_node->num_clock_ports; i++) {
421 for (j = 0; j < pb_graph_node->num_clock_pins[i]; j++) {
422 if (pb_graph_node->clock_pins[i][j].pin_timing)
423 free(pb_graph_node->clock_pins[i][j].pin_timing);
424 if (pb_graph_node->clock_pins[i][j].pin_timing_del_max)
425 free(pb_graph_node->clock_pins[i][j].pin_timing_del_max);
426 if (pb_graph_node->clock_pins[i][j].input_edges)
427 free(pb_graph_node->clock_pins[i][j].input_edges);
428 if (pb_graph_node->clock_pins[i][j].output_edges)
429 free(pb_graph_node->clock_pins[i][j].output_edges);
430 if (pb_graph_node->clock_pins[i][j].parent_pin_class)
431 free(pb_graph_node->clock_pins[i][j].parent_pin_class);
433 free(pb_graph_node->clock_pins[i]);
437 for(i = 0; i < pb_graph_node->pb_type->num_modes; i++) {
438 free(pb_graph_node->interconnect_pins[i]);
440 free(pb_graph_node->interconnect_pins);
442 free(pb_graph_node->input_pins);
443 free(pb_graph_node->output_pins);
444 free(pb_graph_node->clock_pins);
446 free(pb_graph_node->num_input_pins);
447 free(pb_graph_node->num_output_pins);
448 free(pb_graph_node->num_clock_pins);
450 free(pb_graph_node->input_pin_class_size);
451 free(pb_graph_node->output_pin_class_size);
453 for (i = 0; i < pb_type->
num_modes; i++) {
456 free_pb_graph(&pb_graph_node->child_pb_graph_nodes[i][j][k]);
458 free(pb_graph_node->child_pb_graph_nodes[i][j]);
460 free(pb_graph_node->child_pb_graph_nodes[i]);
462 free(pb_graph_node->child_pb_graph_nodes);
464 while (edges_head != NULL ) {
468 for (i = 0; i < (long) cur_num->
data_vptr; i++) {
469 free(edges[i].input_pins);
470 free(edges[i].output_pins);
471 if (edges[i].pack_pattern_indices) {
472 free(edges[i].pack_pattern_indices);
474 if (edges[i].pack_pattern_names) {
475 free(edges[i].pack_pattern_names);
478 edges_head = edges_head->
next;
479 num_edges_head = num_edges_head->
next;
488 int num_input_sets,
int * num_input_pins,
490 int * num_output_pins) {
498 switch (interconnect->
type) {
500 assert(num_output_sets == 1);
505 for (set_idx = 0; set_idx < num_input_sets; set_idx++) {
506 assert(num_input_pins[set_idx] == num_output_pins[0]);
532 for (set_idx = 0; set_idx < num_input_sets; set_idx++) {
547 for (set_idx = 0; set_idx < num_input_sets; set_idx++) {
549 input_pins[set_idx][pin_idx];
551 interc_pins->
output_pins[0][pin_idx] = output_pins[0][pin_idx];
563 for (set_idx = 0; set_idx < num_input_sets; set_idx++) {
564 num_ports += num_input_pins[set_idx];
569 for (set_idx = 0; set_idx < num_output_sets; set_idx++) {
570 num_ports += num_output_pins[set_idx];
601 for (set_idx = 0; set_idx < num_input_sets; set_idx++) {
602 for (pin_idx = 0; pin_idx < num_input_pins[set_idx]; pin_idx++) {
604 input_pins[set_idx][pin_idx];
620 for (set_idx = 0; set_idx < num_output_sets; set_idx++) {
621 for (pin_idx = 0; pin_idx < num_output_pins[set_idx]; pin_idx++) {
623 output_pins[set_idx][pin_idx];
641 INP const t_mode * mode,
boolean load_power_structures) {
643 int *num_input_pb_graph_node_pins, *num_output_pb_graph_node_pins;
644 int num_input_pb_graph_node_sets, num_output_pb_graph_node_sets;
645 t_pb_graph_pin *** input_pb_graph_node_pins, ***output_pb_graph_node_pins;
647 if (load_power_structures) {
648 assert(pb_graph_parent_node->interconnect_pins[mode->index] == NULL);
649 pb_graph_parent_node->interconnect_pins[mode->index] =
654 for (i = 0; i < mode->num_interconnect; i++) {
657 mode->interconnect[i].line_num, pb_graph_parent_node,
658 pb_graph_children_nodes, mode->interconnect[i].input_string,
659 &num_input_pb_graph_node_pins, &num_input_pb_graph_node_sets,
663 mode->interconnect[i].line_num, pb_graph_parent_node,
664 pb_graph_children_nodes, mode->interconnect[i].output_string,
665 &num_output_pb_graph_node_pins, &num_output_pb_graph_node_sets,
668 if (load_power_structures) {
670 &pb_graph_parent_node->interconnect_pins[mode->index][i],
671 &mode->interconnect[i], input_pb_graph_node_pins,
672 num_input_pb_graph_node_sets, num_input_pb_graph_node_pins,
673 output_pb_graph_node_pins, num_output_pb_graph_node_sets,
674 num_output_pb_graph_node_pins);
678 switch (mode->interconnect[i].type) {
682 input_pb_graph_node_pins, num_input_pb_graph_node_sets,
683 num_input_pb_graph_node_pins, output_pb_graph_node_pins,
684 num_output_pb_graph_node_sets,
685 num_output_pb_graph_node_pins);
691 input_pb_graph_node_pins, num_input_pb_graph_node_sets,
692 num_input_pb_graph_node_pins, output_pb_graph_node_pins,
693 num_output_pb_graph_node_sets,
694 num_output_pb_graph_node_pins);
699 input_pb_graph_node_pins, num_input_pb_graph_node_sets,
700 num_input_pb_graph_node_pins, output_pb_graph_node_pins,
701 num_output_pb_graph_node_sets,
702 num_output_pb_graph_node_pins);
708 "[LINE %d] Unknown interconnect %d for mode %s in pb_type %s, input %s, output %s\n",
709 mode->interconnect[i].line_num, mode->interconnect[i].type,
710 mode->name, pb_graph_parent_node->pb_type->name,
711 mode->interconnect[i].input_string,
712 mode->interconnect[i].output_string);
715 for (j = 0; j < num_input_pb_graph_node_sets; j++) {
716 free(input_pb_graph_node_pins[j]);
718 free(input_pb_graph_node_pins);
719 for (j = 0; j < num_output_pb_graph_node_sets; j++) {
720 free(output_pb_graph_node_pins[j]);
722 free(output_pb_graph_node_pins);
723 free(num_input_pb_graph_node_pins);
724 free(num_output_pb_graph_node_pins);
735 INP const char * port_string,
OUTP int ** num_ptrs,
OUTP int * num_sets,
736 INP boolean is_input_to_interc,
INP boolean interconnect_error_check) {
738 int num_tokens, curr_set;
740 boolean in_squig_bracket, success;
747 in_squig_bracket =
FALSE;
750 for (i = 0; i < num_tokens; i++) {
753 if (in_squig_bracket) {
755 "[LINE %d] { inside { in port %s\n", line_num,
759 in_squig_bracket =
TRUE;
761 if (!in_squig_bracket) {
764 "[LINE %d] No matching '{' for '}' in port %s\n",
765 line_num, port_string);
768 in_squig_bracket =
FALSE;
769 }
else if (tokens[i].type ==
TOKEN_DOT) {
770 if (!in_squig_bracket) {
776 if (in_squig_bracket) {
779 "[LINE %d] No matching '{' for '}' in port %s\n", line_num,
786 *num_ptrs = (
int*)
my_calloc(*num_sets,
sizeof(
int));
789 for (i = 0; i < num_tokens; i++) {
792 if (in_squig_bracket) {
794 "[LINE %d] { inside { in port %s\n", line_num,
798 in_squig_bracket =
TRUE;
800 if ((*num_ptrs)[curr_set] == 0) {
802 "[LINE %d] No data contained in {} in port %s\n",
803 line_num, port_string);
806 if (!in_squig_bracket) {
809 "[LINE %d] No matching '{' for '}' in port %s\n",
810 line_num, port_string);
813 in_squig_bracket =
FALSE;
817 pb_graph_parent_node, pb_graph_children_nodes,
818 interconnect_error_check, is_input_to_interc, tokens, &i,
819 &((*num_ptrs)[curr_set]), &pb_graph_pins[curr_set]);
823 "[LINE %d] syntax error processing port string %s\n",
824 line_num, port_string);
828 if (!in_squig_bracket) {
833 assert(curr_set == *num_sets);
835 return pb_graph_pins;
844 INP int num_input_sets,
INP int *num_input_ptrs,
846 INP int num_output_sets,
INP int *num_output_ptrs) {
847 int i_inset, i_outset, i_inpin, i_outpin;
848 int in_count, out_count;
853 assert(interconnect->infer_annotations ==
FALSE);
856 in_count = out_count = 0;
858 for (i_inset = 0; i_inset < num_input_sets; i_inset++) {
859 in_count += num_input_ptrs[i_inset];
861 for (i_outset = 0; i_outset < num_output_sets; i_outset++) {
862 out_count += num_output_ptrs[i_outset];
873 num_edges_head = cur;
874 cur->
data_vptr = (
void *) ((
long) in_count * out_count);
876 for (i_inset = 0; i_inset < num_input_sets; i_inset++) {
877 for (i_inpin = 0; i_inpin < num_input_ptrs[i_inset]; i_inpin++) {
878 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges =
880 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges,
881 (input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges
886 for (i_outset = 0; i_outset < num_output_sets; i_outset++) {
887 for (i_outpin = 0; i_outpin < num_output_ptrs[i_outset]; i_outpin++) {
888 output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->input_edges =
890 output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->input_edges,
891 (output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->num_input_edges
899 for (i_inset = 0; i_inset < num_input_sets; i_inset++) {
900 for (i_inpin = 0; i_inpin < num_input_ptrs[i_inset]; i_inpin++) {
901 for (i_outset = 0; i_outset < num_output_sets; i_outset++) {
902 for (i_outpin = 0; i_outpin < num_output_ptrs[i_outset];
905 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges[input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges] =
907 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges++;
908 output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->input_edges[output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->num_input_edges] =
910 output_pb_graph_node_pin_ptrs[i_outset][i_outpin]->num_input_edges++;
916 input_pb_graph_node_pin_ptrs[i_inset][i_inpin];
921 output_pb_graph_node_pin_ptrs[i_outset][i_outpin];
932 assert(i_edge == in_count * out_count);
938 INP int num_input_sets,
INP int *num_input_ptrs,
940 INP int num_output_sets,
INP int *num_output_ptrs) {
947 if (!(num_input_sets == 1 && num_output_sets == 1)) {
949 "[LINE %d] Direct interconnect allows connections from one set of pins to one other set\n",
950 interconnect->line_num);
953 if (!(num_input_ptrs[0] == num_output_ptrs[0])) {
955 "[LINE %d] Direct interconnect must use an equal number of pins\n",
956 interconnect->line_num);
968 num_edges_head = cur;
969 cur->
data_vptr = (
void *) ((
long) num_input_ptrs[0]);
972 for (i = 0; i < num_input_ptrs[0]; i++) {
973 input_pb_graph_node_pin_ptrs[0][i]->output_edges =
975 input_pb_graph_node_pin_ptrs[0][i]->output_edges,
976 (input_pb_graph_node_pin_ptrs[0][i]->num_output_edges
978 input_pb_graph_node_pin_ptrs[0][i]->output_edges[input_pb_graph_node_pin_ptrs[0][i]->num_output_edges] =
980 input_pb_graph_node_pin_ptrs[0][i]->num_output_edges++;
982 output_pb_graph_node_pin_ptrs[0][i]->input_edges =
984 output_pb_graph_node_pin_ptrs[0][i]->input_edges,
985 (output_pb_graph_node_pin_ptrs[0][i]->num_input_edges
987 output_pb_graph_node_pin_ptrs[0][i]->input_edges[output_pb_graph_node_pin_ptrs[0][i]->num_input_edges] =
989 output_pb_graph_node_pin_ptrs[0][i]->num_input_edges++;
994 edges[i].
input_pins[0] = input_pb_graph_node_pin_ptrs[0][i];
998 edges[i].
output_pins[0] = output_pb_graph_node_pin_ptrs[0][i];
1009 INP int num_input_sets,
INP int *num_input_ptrs,
1011 INP int num_output_sets,
INP int *num_output_ptrs) {
1012 int i_inset, i_inpin, i_outpin;
1016 assert(interconnect->infer_annotations ==
FALSE);
1019 if (num_output_sets != 1) {
1020 vpr_printf(TIO_MESSAGE_ERROR,
"[LINE %d] Mux must have one output\n",
1021 interconnect->line_num);
1033 num_edges_head = cur;
1034 cur->
data_vptr = (
void *) ((
long) num_input_sets);
1036 for (i_inset = 0; i_inset < num_input_sets; i_inset++) {
1037 for (i_inpin = 0; i_inpin < num_input_ptrs[i_inset]; i_inpin++) {
1038 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges =
1040 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges,
1041 (input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges
1046 for (i_outpin = 0; i_outpin < num_output_ptrs[0]; i_outpin++) {
1047 output_pb_graph_node_pin_ptrs[0][i_outpin]->input_edges =
1049 output_pb_graph_node_pin_ptrs[0][i_outpin]->input_edges,
1050 (output_pb_graph_node_pin_ptrs[0][i_outpin]->num_input_edges
1055 for (i_inset = 0; i_inset < num_input_sets; i_inset++) {
1056 if (num_output_ptrs[0] != num_input_ptrs[i_inset]) {
1058 "[LINE %d] # of pins for a particular data line of a mux must equal number of pins at output of mux\n",
1059 interconnect->line_num);
1068 for (i_inpin = 0; i_inpin < num_input_ptrs[i_inset]; i_inpin++) {
1069 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->output_edges[input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges] =
1071 input_pb_graph_node_pin_ptrs[i_inset][i_inpin]->num_output_edges++;
1072 output_pb_graph_node_pin_ptrs[0][i_inpin]->input_edges[output_pb_graph_node_pin_ptrs[0][i_inpin]->num_input_edges] =
1074 output_pb_graph_node_pin_ptrs[0][i_inpin]->num_input_edges++;
1077 input_pb_graph_node_pin_ptrs[i_inset][i_inpin];
1079 output_pb_graph_node_pin_ptrs[0][i_inpin];
1083 "[LINE %d] Bus-based mux not yet supported, will consider for future work\n",
1084 interconnect->line_num);
1103 INP boolean interconnect_error_check,
INP boolean is_input_to_interc,
1107 int i, j, ipin, ipb;
1109 int pin_msb, pin_lsb;
1110 int max_pb_node_array;
1114 int add_or_subtract_pb, add_or_subtract_pin;
1119 pb_node_array = NULL;
1120 max_pb_node_array = 0;
1122 if (pb_graph_children_nodes)
1123 mode = pb_graph_children_nodes[0][0].pb_type->parent_mode;
1125 pb_msb = pb_lsb =
OPEN;
1126 pin_msb = pin_lsb =
OPEN;
1131 == strcmp(pb_graph_parent_node->pb_type->name,
1132 tokens[*token_index].data)) {
1133 pb_node_array = pb_graph_parent_node;
1134 max_pb_node_array = 1;
1135 pb_msb = pb_lsb = 0;
1143 pb_msb =
my_atoi(tokens[*token_index].data);
1157 pb_lsb =
my_atoi(tokens[*token_index].data);
1166 if ((pb_lsb != pb_msb)
1167 && (pb_lsb != pb_graph_parent_node->placement_index)) {
1169 "[LINE %d] Incorrect placement index for %s, expected index %d\n",
1170 line_num, tokens[0].data,
1171 pb_graph_parent_node->placement_index);
1174 pb_lsb = pb_msb = 0;
1177 if (mode == NULL ) {
1179 "[LINE %d] pb_graph_parent_node %s failed\n", line_num,
1180 pb_graph_parent_node->pb_type->name);
1188 tokens[*token_index].data)) {
1189 pb_node_array = pb_graph_children_nodes[i];
1199 pb_msb =
my_atoi(tokens[*token_index].data);
1213 pb_lsb =
my_atoi(tokens[*token_index].data);
1232 "[LINE %d] Unknown pb_type name %s, not defined in namespace of mode %s\n",
1233 line_num, tokens[*token_index].data, mode->
name);
1248 port_name = tokens[*token_index].data;
1256 pin_msb =
my_atoi(tokens[*token_index].data);
1270 pin_lsb =
my_atoi(tokens[*token_index].data);
1279 if (pb_lsb < 0 || pb_lsb >= max_pb_node_array) {
1281 "[LINE %d] pb %d out of range [%d,%d]\n", line_num, pb_lsb,
1282 max_pb_node_array - 1, 0);
1288 "[LINE %d] failed to find port name %s\n", line_num,
1299 if (pb_msb < pb_lsb) {
1300 add_or_subtract_pb = -1;
1302 add_or_subtract_pb = 1;
1305 if (pin_msb < pin_lsb) {
1306 add_or_subtract_pin = -1;
1308 add_or_subtract_pin = 1;
1310 *num_pins += (abs(pb_msb - pb_lsb) + 1) * (abs(pin_msb - pin_lsb) + 1);
1317 while (ipb != pb_msb + add_or_subtract_pin) {
1320 while (ipin != pin_msb + add_or_subtract_pin) {
1321 if (ipb < 0 || ipb >= max_pb_node_array) {
1323 "[LINE %d] pb %d out of range [%d,%d]\n", line_num, ipb,
1324 max_pb_node_array - 1, 0);
1327 (*pb_graph_pins)[i * (abs(pin_msb - pin_lsb) + 1) + j] =
1330 if ((*pb_graph_pins)[i * (abs(pin_msb - pin_lsb) + 1) + j] == NULL ) {
1332 "[LINE %d] Pin %s.%s[%d] cannot be found\n", line_num,
1333 pb_node_array[ipb].pb_type->name, port_name, ipin);
1337 (*pb_graph_pins)[i * (abs(pin_msb - pin_lsb) + 1) + j]->port;
1343 if (interconnect_error_check) {
1344 if (pb_node_array == pb_graph_parent_node) {
1345 if (is_input_to_interc) {
1348 "[LINE %d] input to interconnect from parent is not an input or clock pin\n",
1355 "[LINE %d] output from interconnect from parent is not an input or clock pin\n",
1361 if (is_input_to_interc) {
1364 "[LINE %d] output from interconnect from parent is not an input or clock pin\n",
1371 "[LINE %d] input to interconnect from parent is not an input or clock pin\n",
1381 ipin += add_or_subtract_pin;
1385 ipb += add_or_subtract_pb;
1388 assert((abs(pb_msb - pb_lsb) + 1) * (abs(pin_msb - pin_lsb) + 1) == i * j);
1397 for (i = 0; i < pb->num_input_ports; i++) {
1398 if (0 == strcmp(port_name, pb->input_pins[i][0].port->name)) {
1399 if (pin < pb->input_pins[i][0].port->num_pins) {
1400 return &pb->input_pins[i][pin];
1406 for (i = 0; i < pb->num_output_ports; i++) {
1407 if (0 == strcmp(port_name, pb->output_pins[i][0].port->name)) {
1408 if (pin < pb->output_pins[i][0].port->num_pins) {
1409 return &pb->output_pins[i][pin];
1415 for (i = 0; i < pb->num_clock_ports; i++) {
1416 if (0 == strcmp(port_name, pb->clock_pins[i][0].port->name)) {
1417 if (pin < pb->clock_pins[i][0].port->num_pins) {
1418 return &pb->clock_pins[i][pin];
1428 int i, j, k, m, icapacity;
1434 int *num_pb_graph_node_pins;
1435 int num_pb_graph_node_sets;
1438 num_sides = 2 * (type->
height + 1);
1445 for (j = 0; j < 4; j++) {
1446 for (i = 0; i < type->
height; i++) {
1447 if (j ==
TOP && i != type->
height - 1) {
1450 if (j ==
BOTTOM && i != 0) {
1453 for (k = 0; k < (type->
num_pins / num_sides) + 1; k++) {
1454 pin_num = side_index + k * num_sides;
1455 if (pin_num < type->num_pins) {
1456 type->
pinloc[i][j][pin_num] = 1;
1464 assert(side_index == num_sides);
1468 for (i = 0; i < type->
height; i++) {
1469 for (j = 0; j < 4; j++) {
1470 if (j ==
TOP && i != type->
height - 1) {
1473 if (j ==
BOTTOM && i != 0) {
1477 pb_graph_node_pins =
1483 &num_pb_graph_node_pins,
1485 assert(num_pb_graph_node_sets == 1);
1487 for (m = 0; m < num_pb_graph_node_pins[0]; m++) {
1490 assert(pin_num < type->num_pins / type->
capacity);
1491 for (icapacity = 0; icapacity < type->
capacity;
1493 type->
pinloc[i][j][pin_num
1497 assert(count < type->num_pins);
1500 free(pb_graph_node_pins[0]);
1501 free(pb_graph_node_pins);
1502 free(num_pb_graph_node_pins);
1514 fprintf(fp,
"Physical Block: type \"%s\" index %d num_children %d\n",
1515 pb_graph_node->pb_type->name, pb_graph_node->placement_index,
1516 pb_graph_node->pb_type->num_pb);
1518 if (pb_graph_node->parent_pb_graph_node) {
1520 fprintf(fp,
"Parent Block: type \"%s\" index %d \n",
1521 pb_graph_node->parent_pb_graph_node->pb_type->name,
1522 pb_graph_node->parent_pb_graph_node->placement_index);
1526 fprintf(fp,
"Input Ports: total ports %d\n",
1527 pb_graph_node->num_input_ports);
1528 echo_pb_pins(pb_graph_node->input_pins, pb_graph_node->num_input_ports,
1531 fprintf(fp,
"Output Ports: total ports %d\n",
1532 pb_graph_node->num_output_ports);
1533 echo_pb_pins(pb_graph_node->output_pins, pb_graph_node->num_output_ports,
1536 fprintf(fp,
"Clock Ports: total ports %d\n",
1537 pb_graph_node->num_clock_ports);
1538 echo_pb_pins(pb_graph_node->clock_pins, pb_graph_node->num_clock_ports,
1541 for (i = 0; i < pb_graph_node->num_input_pin_class; i++) {
1542 fprintf(fp,
"Input class %d: %d pins, ", i,
1543 pb_graph_node->input_pin_class_size[i]);
1547 for (i = 0; i < pb_graph_node->num_output_pin_class; i++) {
1548 fprintf(fp,
"Output class %d: %d pins, ", i,
1549 pb_graph_node->output_pin_class_size[i]);
1553 if (pb_graph_node->pb_type->num_modes > 0) {
1555 fprintf(fp,
"Children:\n");
1557 for (i = 0; i < pb_graph_node->pb_type->num_modes; i++) {
1558 for (j = 0; j < pb_graph_node->pb_type->modes[i].num_pb_type_children;
1562 < pb_graph_node->pb_type->modes[i].pb_type_children[j].num_pb;
1564 echo_pb_rec(&pb_graph_node->child_pb_graph_nodes[i][j][k],
1572 INP int level,
INP FILE * fp) {
1578 for (i = 0; i < num_ports; i++) {
1579 port = pb_graph_pins[i][0].port;
1581 fprintf(fp,
"Port \"%s\": num_pins %d type %d parent name \"%s\"\n",
1585 for (j = 0; j < port->
num_pins; j++) {
1587 assert(j == pb_graph_pins[i][j].pin_number);
1588 assert(pb_graph_pins[i][j].port == port);
1590 "Pin %d port name \"%s\" num input edges %d num output edges %d parent type \"%s\" parent index %d\n",
1591 pb_graph_pins[i][j].pin_number,
1592 pb_graph_pins[i][j].port->
name,
1593 pb_graph_pins[i][j].num_input_edges,
1594 pb_graph_pins[i][j].num_output_edges,
1595 pb_graph_pins[i][j].parent_node->pb_type->name,
1596 pb_graph_pins[i][j].parent_node->placement_index);
1598 if (pb_graph_pins[i][j].parent_node->pb_type->num_modes == 0) {
1599 fprintf(fp,
"pin class (depth, pin class): ");
1600 for (k = 0; k < pb_graph_pins[i][j].parent_node->pb_type->depth;
1602 fprintf(fp,
"(%d %d), ", k,
1603 pb_graph_pins[i][j].parent_pin_class[k]);
1608 k < pb_graph_pins[i][j].parent_node->pb_type->depth;
1612 "connectable input pins within depth %d: %d\n",
1614 pb_graph_pins[i][j].num_connectable_primtive_input_pins[k]);
1617 < pb_graph_pins[i][j].num_connectable_primtive_input_pins[k];
1620 fprintf(fp,
"pb_graph_node %s[%d].%s[%d] \n",
1621 pb_graph_pins[i][j].list_of_connectable_input_pin_ptrs[k][m]->parent_node->pb_type->name,
1622 pb_graph_pins[i][j].list_of_connectable_input_pin_ptrs[k][m]->parent_node->placement_index,
1623 pb_graph_pins[i][j].list_of_connectable_input_pin_ptrs[k][m]->port->name,
1624 pb_graph_pins[i][j].list_of_connectable_input_pin_ptrs[k][m]->pin_number);
1629 fprintf(fp,
"pin class %d \n", pb_graph_pins[i][j].pin_class);
1631 for (k = 0; k < pb_graph_pins[i][j].num_input_edges; k++) {
1633 fprintf(fp,
"Input edge %d num inputs %d num outputs %d\n", k,
1634 pb_graph_pins[i][j].input_edges[k]->num_input_pins,
1635 pb_graph_pins[i][j].input_edges[k]->num_output_pins);
1637 fprintf(fp,
"Input edge inputs\n");
1639 m < pb_graph_pins[i][j].input_edges[k]->num_input_pins;
1642 fprintf(fp,
"pin number %d port_name \"%s\"\n",
1643 pb_graph_pins[i][j].input_edges[k]->input_pins[m]->pin_number,
1644 pb_graph_pins[i][j].input_edges[k]->input_pins[m]->port->
name);
1647 fprintf(fp,
"Input edge outputs\n");
1649 m < pb_graph_pins[i][j].input_edges[k]->num_output_pins;
1653 "pin number %d port_name \"%s\" parent type \"%s\" parent index %d\n",
1654 pb_graph_pins[i][j].input_edges[k]->output_pins[m]->pin_number,
1655 pb_graph_pins[i][j].input_edges[k]->output_pins[m]->port->
name,
1656 pb_graph_pins[i][j].input_edges[k]->output_pins[m]->parent_node->pb_type->name,
1657 pb_graph_pins[i][j].input_edges[k]->output_pins[m]->parent_node->placement_index);
1660 for (k = 0; k < pb_graph_pins[i][j].num_output_edges; k++) {
1662 fprintf(fp,
"Output edge %d num inputs %d num outputs %d\n", k,
1663 pb_graph_pins[i][j].output_edges[k]->num_input_pins,
1664 pb_graph_pins[i][j].output_edges[k]->num_output_pins);
1666 fprintf(fp,
"Output edge inputs\n");
1668 m < pb_graph_pins[i][j].output_edges[k]->num_input_pins;
1671 fprintf(fp,
"pin number %d port_name \"%s\"\n",
1672 pb_graph_pins[i][j].output_edges[k]->input_pins[m]->pin_number,
1673 pb_graph_pins[i][j].output_edges[k]->input_pins[m]->port->
name);
1676 fprintf(fp,
"Output edge outputs\n");
1678 m < pb_graph_pins[i][j].output_edges[k]->num_output_pins;
1682 "pin number %d port_name \"%s\" parent type \"%s\" parent index %d\n",
1683 pb_graph_pins[i][j].output_edges[k]->output_pins[m]->pin_number,
1684 pb_graph_pins[i][j].output_edges[k]->output_pins[m]->port->
name,
1685 pb_graph_pins[i][j].output_edges[k]->output_pins[m]->parent_node->pb_type->name,
1686 pb_graph_pins[i][j].output_edges[k]->output_pins[m]->parent_node->placement_index);
static void alloc_and_load_pb_graph(INOUTP t_pb_graph_node *pb_graph_node, INP t_pb_graph_node *parent_pb_graph_node, INP t_pb_type *pb_type, INP int index, boolean load_power_structures)
t_interconnect * interconnect
void load_pb_graph_pin_to_pin_annotations(INOUTP t_pb_graph_node *pb_graph_node)
FILE * my_fopen(const char *fname, const char *flag, int prompt)
boolean port_info_initialized
boolean checkTokenType(INP t_token token, OUTP enum e_token_type token_type)
static void alloc_and_load_complete_interc_edges(INP t_interconnect *interconnect, INOUTP t_pb_graph_pin ***input_pb_graph_node_pin_ptrs, INP int num_input_sets, INP int *num_input_ptrs, INOUTP t_pb_graph_pin ***output_pb_graph_node_pin_ptrs, INP int num_output_sets, INP int *num_output_ptrs)
struct s_pb_type * pb_type_children
static struct s_linked_vptr * num_edges_head
static struct s_linked_vptr * edges_head
static void alloc_and_load_direct_interc_edges(INP t_interconnect *interconnect, INOUTP t_pb_graph_pin ***input_pb_graph_node_pin_ptrs, INP int num_input_sets, INP int *num_input_ptrs, INOUTP t_pb_graph_pin ***output_pb_graph_node_pin_ptrs, INP int num_output_sets, INP int *num_output_ptrs)
t_pb_graph_pin ** output_pins
void * my_calloc(size_t nelem, size_t size)
static void alloc_and_load_interconnect_pins(t_interconnect_pins *interc_pins, t_interconnect *interconnect, t_pb_graph_pin ***input_pins, int num_input_sets, int *num_input_pins, t_pb_graph_pin ***output_pins, int num_output_sets, int *num_output_pins)
t_token * GetTokensFromString(INP const char *inString, OUTP int *num_tokens)
void alloc_and_load_all_pb_graphs(boolean load_power_structures)
t_interconnect * interconnect
enum e_pin_location_distr pin_location_distribution
t_interconnect * interconnect
struct s_pb_graph_pin *** output_pins
static void * my_malloc(int ibytes)
static int pin_count_in_cluster
static void echo_pb_pins(INP t_pb_graph_pin **pb_graph_pins, INP int num_ports, INP int level, INP FILE *fp)
void echo_pb_graph(char *filename)
static void alloc_and_load_pin_locations_from_pb_graph(t_type_descriptor *type)
static int check_pb_graph(void)
static void free_pb_graph(INOUTP t_pb_graph_node *pb_graph_node)
char **** pin_loc_assignments
struct s_pb_graph_node *** child_pb_graph_nodes
struct s_linked_vptr * next
struct s_pb_type * pb_type
t_pb_graph_pin ** input_pins
void load_pin_classes_in_pb_graph_head(INOUTP t_pb_graph_node *pb_graph_node)
struct s_pb_type * pb_type
struct s_pb_type * parent_pb_type
int ** num_pin_loc_assignments
static void * my_realloc(void *memblk, int ibytes)
void free_all_pb_graph_nodes(void)
t_pb_graph_pin *** alloc_and_load_port_pin_ptrs_from_string(INP int line_num, INP const t_pb_graph_node *pb_graph_parent_node, INP t_pb_graph_node **pb_graph_children_nodes, INP const char *port_string, OUTP int **num_ptrs, OUTP int *num_sets, INP boolean is_input_to_interc, INP boolean interconnect_error_check)
struct s_pb_graph_pin *** input_pins
t_pb_graph_node * pb_graph_head
struct s_type_descriptor * type_descriptors
static void echo_pb_rec(INP const t_pb_graph_node *pb, INP int level, INP FILE *fp)
void freeTokens(INP t_token *tokens, INP int num_tokens)
static void print_tabs(FILE *fpout, int num_tabs)
int my_atoi(const char *str)
static boolean realloc_and_load_pb_graph_pin_ptrs_at_var(INP int line_num, INP const t_pb_graph_node *pb_graph_parent_node, INP t_pb_graph_node **pb_graph_children_nodes, INP boolean interconnect_error_check, INP boolean is_input_to_interc, INP const t_token *tokens, INOUTP int *token_index, INOUTP int *num_pins, OUTP t_pb_graph_pin ***pb_graph_pins)
t_interconnect_power * interconnect_power
static void alloc_and_load_mode_interconnect(INOUTP t_pb_graph_node *pb_graph_parent_node, INOUTP t_pb_graph_node **pb_graph_children_nodes, INP const t_mode *mode, boolean load_power_structures)
static t_pb_graph_pin * get_pb_graph_pin_from_name(INP const char *port_name, INP const t_pb_graph_node *pb, INP int pin)
static void alloc_and_load_mux_interc_edges(INP t_interconnect *interconnect, INOUTP t_pb_graph_pin ***input_pb_graph_node_pin_ptrs, INP int num_input_sets, INP int *num_input_ptrs, INOUTP t_pb_graph_pin ***output_pb_graph_node_pin_ptrs, INP int num_output_sets, INP int *num_output_ptrs)