00001 #include <assert.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include "util.h"
00005 #include "vpr_types.h"
00006 #include "globals.h"
00007 #include "print_netlist.h"
00008
00009
00010
00011
00012 static void print_pinnum(FILE * fp,
00013 int pinnum);
00014
00015
00016
00017
00018 void
00019 print_netlist(char *foutput,
00020 char *net_file,
00021 t_subblock_data subblock_data)
00022 {
00023
00024
00025
00026
00027 int i, j, ipin, max_pin;
00028 int num_global_nets;
00029 int num_p_inputs, num_p_outputs;
00030 FILE *fp;
00031 t_subblock **subblock_inf;
00032 int *num_subblocks_per_block;
00033
00034 num_global_nets = 0;
00035 num_p_inputs = 0;
00036 num_p_outputs = 0;
00037
00038
00039 for(i = 0; i < num_nets; i++)
00040 {
00041 if(!net[i].is_global)
00042 {
00043 num_global_nets++;
00044 }
00045 }
00046
00047
00048 for(i = 0; i < num_blocks; i++)
00049 {
00050 if(block[i].type == IO_TYPE)
00051 {
00052 for(j = 0; j < IO_TYPE->num_pins; j++)
00053 {
00054 if(block[i].nets[j] != OPEN)
00055 {
00056 if(IO_TYPE->
00057 class_inf[IO_TYPE->pin_class[j]].
00058 type == DRIVER)
00059 {
00060 num_p_inputs++;
00061 }
00062 else
00063 {
00064 assert(IO_TYPE->
00065 class_inf[IO_TYPE->
00066 pin_class[j]].
00067 type == RECEIVER);
00068 num_p_outputs++;
00069 }
00070 }
00071 }
00072 }
00073 }
00074
00075
00076 fp = my_fopen(foutput, "w");
00077
00078 fprintf(fp, "Input netlist file: %s\n", net_file);
00079 fprintf(fp, "num_p_inputs: %d, num_p_outputs: %d, num_clbs: %d\n",
00080 num_p_inputs, num_p_outputs, num_blocks);
00081 fprintf(fp, "num_blocks: %d, num_nets: %d, num_globals: %d\n",
00082 num_blocks, num_nets, num_global_nets);
00083 fprintf(fp, "\nNet\tName\t\t#Pins\tDriver\t\tRecvs. (block, pin)\n");
00084
00085 for(i = 0; i < num_nets; i++)
00086 {
00087 fprintf(fp, "\n%d\t%s\t", i, net[i].name);
00088 if(strlen(net[i].name) < 8)
00089 fprintf(fp, "\t");
00090 fprintf(fp, "%d", net[i].num_sinks + 1);
00091 for(j = 0; j <= net[i].num_sinks; j++)
00092 fprintf(fp, "\t(%4d,%4d)", net[i].node_block[j],
00093 net[i].node_block_pin[j]);
00094 }
00095
00096 fprintf(fp, "\nBlock\tName\t\tType\tPin Connections\n\n");
00097
00098 for(i = 0; i < num_blocks; i++)
00099 {
00100 fprintf(fp, "\n%d\t%s\t", i, block[i].name);
00101 if(strlen(block[i].name) < 8)
00102 fprintf(fp, "\t");
00103 fprintf(fp, "%s", block[i].type->name);
00104
00105 max_pin = block[i].type->num_pins;
00106
00107 for(j = 0; j < max_pin; j++)
00108 print_pinnum(fp, block[i].nets[j]);
00109 }
00110
00111 fprintf(fp, "\n");
00112
00113
00114
00115 subblock_inf = subblock_data.subblock_inf;
00116 num_subblocks_per_block = subblock_data.num_subblocks_per_block;
00117
00118
00119 fprintf(fp, "\n\nSubblock List:\n\n");
00120
00121 for(i = 0; i < num_blocks; i++)
00122 {
00123 fprintf(fp, "\nBlock: %d (%s)\tNum_subblocks: %d\n", i,
00124 block[i].name, num_subblocks_per_block[i]);
00125
00126
00127
00128 fprintf(fp, "Index\tName\t\tInputs");
00129 for(j = 0; j < block[i].type->max_subblock_inputs; j++)
00130 fprintf(fp, "\t");
00131 fprintf(fp, "Outputs");
00132 for(j = 0; j < block[i].type->max_subblock_outputs; j++)
00133 fprintf(fp, "\t");
00134 fprintf(fp, "Clock\n");
00135
00136
00137
00138 for(j = 0; j < num_subblocks_per_block[i]; j++)
00139 {
00140 fprintf(fp, "%d\t%s", j, subblock_inf[i][j].name);
00141 if(strlen(subblock_inf[i][j].name) < 8)
00142 fprintf(fp, "\t");
00143 for(ipin = 0; ipin < block[i].type->max_subblock_inputs;
00144 ipin++)
00145 print_pinnum(fp, subblock_inf[i][j].inputs[ipin]);
00146 for(ipin = 0; ipin < block[i].type->max_subblock_outputs;
00147 ipin++)
00148 print_pinnum(fp, subblock_inf[i][j].outputs[ipin]);
00149 print_pinnum(fp, subblock_inf[i][j].clock);
00150 fprintf(fp, "\n");
00151 }
00152 }
00153
00154 fclose(fp);
00155 }
00156
00157
00158 static void
00159 print_pinnum(FILE * fp,
00160 int pinnum)
00161 {
00162
00163
00164
00165 if(pinnum == OPEN)
00166 fprintf(fp, "\tOPEN");
00167 else
00168 fprintf(fp, "\t%d", pinnum);
00169 }