VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
print_netlist.c
Go to the documentation of this file.
1 #include <assert.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include "util.h"
5 #include "vpr_types.h"
6 #include "globals.h"
7 #include "print_netlist.h"
8 #include "read_xml_arch_file.h"
9 
10 /******************** Subroutines local to this module ***********************/
11 
12 static void print_pinnum(FILE * fp, int pinnum);
13 
14 /********************* Subroutine definitions ********************************/
15 
16 void print_netlist(char *foutput, char *net_file) {
17 
18  /* Prints out the netlist related data structures into the file *
19  * fname. */
20 
21  int i, j, max_pin;
22  int num_global_nets;
23  int L_num_p_inputs, L_num_p_outputs;
24  FILE *fp;
25 
26  num_global_nets = 0;
27  L_num_p_inputs = 0;
28  L_num_p_outputs = 0;
29 
30  /* Count number of global nets */
31  for (i = 0; i < num_nets; i++) {
32  if (clb_net[i].is_global) {
33  num_global_nets++;
34  }
35  }
36 
37  /* Count I/O input and output pads */
38  for (i = 0; i < num_blocks; i++) {
39  if (block[i].type == IO_TYPE) {
40  for (j = 0; j < IO_TYPE->num_pins; j++) {
41  if (block[i].nets[j] != OPEN) {
43  == DRIVER) {
44  L_num_p_inputs++;
45  } else {
46  assert(
47  IO_TYPE-> class_inf[IO_TYPE-> pin_class[j]]. type == RECEIVER);
48  L_num_p_outputs++;
49  }
50  }
51  }
52  }
53  }
54 
55  fp = my_fopen(foutput, "w", 0);
56 
57  fprintf(fp, "Input netlist file: %s\n", net_file);
58  fprintf(fp, "L_num_p_inputs: %d, L_num_p_outputs: %d, num_clbs: %d\n",
59  L_num_p_inputs, L_num_p_outputs, num_blocks);
60  fprintf(fp, "num_blocks: %d, num_nets: %d, num_globals: %d\n", num_blocks,
61  num_nets, num_global_nets);
62  fprintf(fp, "\nNet\tName\t\t#Pins\tDriver\t\tRecvs. (block, pin)\n");
63 
64  for (i = 0; i < num_nets; i++) {
65  fprintf(fp, "\n%d\t%s\t", i, clb_net[i].name);
66  if (strlen(clb_net[i].name) < 8)
67  fprintf(fp, "\t"); /* Name field is 16 chars wide */
68  fprintf(fp, "%d", clb_net[i].num_sinks + 1);
69  for (j = 0; j <= clb_net[i].num_sinks; j++)
70  fprintf(fp, "\t(%4d,%4d)", clb_net[i].node_block[j],
71  clb_net[i].node_block_pin[j]);
72  }
73 
74  fprintf(fp, "\nBlock\tName\t\tType\tPin Connections\n\n");
75 
76  for (i = 0; i < num_blocks; i++) {
77  fprintf(fp, "\n%d\t%s\t", i, block[i].name);
78  if (strlen(block[i].name) < 8)
79  fprintf(fp, "\t"); /* Name field is 16 chars wide */
80  fprintf(fp, "%s", block[i].type->name);
81 
82  max_pin = block[i].type->num_pins;
83 
84  for (j = 0; j < max_pin; j++)
85  print_pinnum(fp, block[i].nets[j]);
86  }
87 
88  fprintf(fp, "\n");
89 
90  /* TODO: Print out pb info */
91 
92  fclose(fp);
93 }
94 
95 static void print_pinnum(FILE * fp, int pinnum) {
96 
97  /* This routine prints out either OPEN or the pin number, to file fp. */
98 
99  if (pinnum == OPEN)
100  fprintf(fp, "\tOPEN");
101  else
102  fprintf(fp, "\t%d", pinnum);
103 }
FILE * my_fopen(const char *fname, const char *flag, int prompt)
Definition: util.c:54
struct s_class * class_inf
int num_nets
Definition: globals.c:27
t_type_ptr type
Definition: vpr_types.h:561
int num_blocks
Definition: globals.c:30
char * name
Definition: vpr_types.h:560
boolean * is_global
struct s_block * block
Definition: globals.c:31
struct s_net * clb_net
Definition: globals.c:28
t_type_ptr IO_TYPE
Definition: globals.c:40
Definition: slre.c:50
enum e_pin_type type
int num_sinks
Definition: vpr_types.h:506