Go to the source code of this file.
Functions | |
void | output_blif (char *file_name, netlist_t *netlist) |
void output_blif | ( | char * | file_name, | |
netlist_t * | netlist | |||
) |
Definition at line 51 of file output_blif.c.
00052 { 00053 int i; 00054 int count = 0; 00055 short first_time_inputs = FALSE; 00056 short first_time_outputs = FALSE; 00057 FILE *out; 00058 char *out_file; 00059 00060 /* open the file for output */ 00061 if (global_args.high_level_block != NULL) 00062 { 00063 out_file = (char*)malloc(sizeof(char)*(1+strlen(file_name)+strlen(global_args.high_level_block)+6)); 00064 sprintf(out_file, "%s_%s.blif", file_name, global_args.high_level_block); 00065 out = fopen(out_file, "w"); 00066 } 00067 else 00068 { 00069 out = fopen(file_name, "w"); 00070 } 00071 00072 if (out == NULL) 00073 { 00074 error_message(NETLIST_ERROR, -1, -1, "Could not open output file %s\n", file_name); 00075 } 00076 00077 fprintf(out, ".model %s\n", top_module->children[0]->types.identifier); 00078 00079 /* generate all te signals */ 00080 for (i = 0; i < netlist->num_top_input_nodes; i++) 00081 { 00082 if (first_time_inputs == FALSE) 00083 { 00084 count = fprintf(out, ".inputs"); 00085 first_time_inputs = TRUE; 00086 } 00087 00088 if (global_args.high_level_block != NULL) 00089 { 00090 if (strlen(netlist->top_input_nodes[i]->name) + count < 79) 00091 count = count + fprintf(out, " %s^^%i-%i", netlist->top_input_nodes[i]->name, netlist->top_input_nodes[i]->related_ast_node->far_tag, netlist->top_input_nodes[i]->related_ast_node->high_number); 00092 else 00093 { 00094 /* wrapping line */ 00095 count = fprintf(out, " \\\n %s^^%i-%i", netlist->top_input_nodes[i]->name,netlist->top_input_nodes[i]->related_ast_node->far_tag, netlist->top_input_nodes[i]->related_ast_node->high_number); 00096 count = count - 3; 00097 } 00098 } 00099 else 00100 { 00101 if (strlen(netlist->top_input_nodes[i]->name) + count < 79) 00102 { 00103 count = count + fprintf(out, " %s", netlist->top_input_nodes[i]->name); 00104 } 00105 else 00106 { 00107 /* wrapping line */ 00108 count = fprintf(out, " \\\n %s", netlist->top_input_nodes[i]->name); 00109 count = count - 3; 00110 } 00111 } 00112 } 00113 fprintf(out, "\n"); 00114 00115 count = 0; 00116 for (i = 0; i < netlist->num_top_output_nodes; i++) 00117 { 00118 if (netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin == NULL) 00119 { 00120 warning_message(NETLIST_ERROR, netlist->top_output_nodes[i]->related_ast_node->line_number, netlist->top_output_nodes[i]->related_ast_node->file_number, "This output is undriven (%s) and will be removed\n", netlist->top_output_nodes[i]->name); 00121 } 00122 else 00123 { 00124 if (first_time_outputs == FALSE) 00125 { 00126 count = fprintf(out, ".outputs"); 00127 first_time_outputs = TRUE; 00128 } 00129 00130 if (global_args.high_level_block != NULL) 00131 { 00132 if ((strlen(netlist->top_output_nodes[i]->name) + count) < 79) 00133 count = count + fprintf(out, " %s^^%i-%i", netlist->top_output_nodes[i]->name,netlist->top_output_nodes[i]->related_ast_node->far_tag, netlist->top_output_nodes[i]->related_ast_node->high_number); 00134 else 00135 { 00136 /* wrapping line */ 00137 count = fprintf(out, "\\\n %s^^%i-%i", netlist->top_output_nodes[i]->name,netlist->top_output_nodes[i]->related_ast_node->far_tag, netlist->top_output_nodes[i]->related_ast_node->high_number); 00138 count = count - 3; 00139 } 00140 } 00141 else 00142 { 00143 if ((strlen(netlist->top_output_nodes[i]->name) + count) < 79) 00144 count = count + fprintf(out, " %s", netlist->top_output_nodes[i]->name); 00145 else 00146 { 00147 /* wrapping line */ 00148 count = fprintf(out, "\\\n %s", netlist->top_output_nodes[i]->name); 00149 count = count - 3; 00150 } 00151 } 00152 } 00153 } 00154 fprintf(out, "\n"); 00155 00156 /* add gnd, unconn, and vcc */ 00157 fprintf(out, "\n.names gnd\n.names unconn\n.names vcc\n1\n"); 00158 fprintf(out, "\n"); 00159 00160 /* traverse the internals of the flat net-list */ 00161 if (strcmp(configuration.output_type, "blif") == 0) 00162 { 00163 depth_first_traversal_to_output(OUTPUT_TRAVERSE_VALUE, out, netlist); 00164 } 00165 else 00166 oassert(FALSE); 00167 00168 /* connect all the outputs up to the last gate */ 00169 for (i = 0; i < netlist->num_top_output_nodes; i++) 00170 { 00171 /* KEN -- DPRAM WORKING HERE FOR JASON */ 00172 if (netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin != NULL) 00173 { 00174 if (global_args.high_level_block != NULL) 00175 { 00176 fprintf(out, ".names %s^^%i-%i %s^^%i-%i\n1 1\n", netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->node->name,netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->node->related_ast_node->far_tag, netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->node->related_ast_node->high_number, netlist->top_output_nodes[i]->name, netlist->top_output_nodes[i]->related_ast_node->far_tag, netlist->top_output_nodes[i]->related_ast_node->high_number); 00177 } 00178 else 00179 { 00180 if (netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->mapping != NULL) 00181 fprintf(out, ".names %s %s\n1 1\n", netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->name, netlist->top_output_nodes[i]->name); 00182 else 00183 fprintf(out, ".names %s %s\n1 1\n", netlist->top_output_nodes[i]->input_pins[0]->net->driver_pin->node->name, netlist->top_output_nodes[i]->name); 00184 } 00185 00186 } 00187 } 00188 00189 /* finish off the top level module */ 00190 fprintf(out, ".end\n"); 00191 fprintf(out, "\n"); 00192 00193 /* Print out any hard block modules */ 00194 #ifdef VPR6 00195 add_the_blackbox_for_mults(out); 00196 output_hard_blocks(out); 00197 #endif 00198 00199 fclose(out); 00200 }