VPR-6.0
|
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 #include "read_xml_arch_file.h" 00009 00010 /******************** Subroutines local to this module ***********************/ 00011 00012 static void print_pinnum(FILE * fp, 00013 int pinnum); 00014 00015 00016 /********************* Subroutine definitions ********************************/ 00017 00018 /** Prints out the netlist related data structures into the file 00019 * fname. 00020 */ 00021 void 00022 print_netlist(char *foutput, 00023 char *net_file) 00024 { 00025 00026 int i, j, max_pin; 00027 int num_global_nets; 00028 int num_p_inputs, num_p_outputs; 00029 FILE *fp; 00030 00031 num_global_nets = 0; 00032 num_p_inputs = 0; 00033 num_p_outputs = 0; 00034 00035 /* Count number of global nets */ 00036 for(i = 0; i < num_nets; i++) 00037 { 00038 if(clb_net[i].is_global) 00039 { 00040 num_global_nets++; 00041 } 00042 } 00043 00044 /* Count I/O input and output pads */ 00045 for(i = 0; i < num_blocks; i++) 00046 { 00047 if(block[i].type == IO_TYPE) 00048 { 00049 for(j = 0; j < IO_TYPE->num_pins; j++) 00050 { 00051 if(block[i].nets[j] != OPEN) 00052 { 00053 if(IO_TYPE-> 00054 class_inf[IO_TYPE->pin_class[j]]. 00055 type == DRIVER) 00056 { 00057 num_p_inputs++; 00058 } 00059 else 00060 { 00061 assert(IO_TYPE-> 00062 class_inf[IO_TYPE-> 00063 pin_class[j]]. 00064 type == RECEIVER); 00065 num_p_outputs++; 00066 } 00067 } 00068 } 00069 } 00070 } 00071 00072 00073 fp = my_fopen(foutput, "w", 0); 00074 00075 fprintf(fp, "Input netlist file: %s\n", net_file); 00076 fprintf(fp, "num_p_inputs: %d, num_p_outputs: %d, num_clbs: %d\n", 00077 num_p_inputs, num_p_outputs, num_blocks); 00078 fprintf(fp, "num_blocks: %d, num_nets: %d, num_globals: %d\n", 00079 num_blocks, num_nets, num_global_nets); 00080 fprintf(fp, "\nNet\tName\t\t#Pins\tDriver\t\tRecvs. (block, pin)\n"); 00081 00082 for(i = 0; i < num_nets; i++) 00083 { 00084 fprintf(fp, "\n%d\t%s\t", i, clb_net[i].name); 00085 if(strlen(clb_net[i].name) < 8) 00086 fprintf(fp, "\t"); /* Name field is 16 chars wide */ 00087 fprintf(fp, "%d", clb_net[i].num_sinks + 1); 00088 for(j = 0; j <= clb_net[i].num_sinks; j++) 00089 fprintf(fp, "\t(%4d,%4d)", clb_net[i].node_block[j], 00090 clb_net[i].node_block_pin[j]); 00091 } 00092 00093 fprintf(fp, "\nBlock\tName\t\tType\tPin Connections\n\n"); 00094 00095 for(i = 0; i < num_blocks; i++) 00096 { 00097 fprintf(fp, "\n%d\t%s\t", i, block[i].name); 00098 if(strlen(block[i].name) < 8) 00099 fprintf(fp, "\t"); /* Name field is 16 chars wide */ 00100 fprintf(fp, "%s", block[i].type->name); 00101 00102 max_pin = block[i].type->num_pins; 00103 00104 for(j = 0; j < max_pin; j++) 00105 print_pinnum(fp, block[i].nets[j]); 00106 } 00107 00108 fprintf(fp, "\n"); 00109 00110 /* TODO: Print out pb info */ 00111 00112 fclose(fp); 00113 } 00114 00115 00116 /** This routine prints out either OPEN or the pin number, to file fp. */ 00117 static void 00118 print_pinnum(FILE * fp, 00119 int pinnum) 00120 { 00121 if(pinnum == OPEN) 00122 fprintf(fp, "\tOPEN"); 00123 else 00124 fprintf(fp, "\t%d", pinnum); 00125 }