@@ -52,6 +52,28 @@ void define_ff(nnode_t* node, FILE* out);
5252void define_decoded_mux (nnode_t * node, FILE* out);
5353void output_blif_pin_connect (nnode_t * node, FILE* out);
5454
55+ static void replace_input_names (nnode_t * node, long pin_idx) {
56+ oassert (pin_idx < node->num_input_pins );
57+ nnet_t * net = node->input_pins [pin_idx]->net ;
58+ if (!net->num_driver_pins ) {
59+ // Add a warning for an undriven net.
60+ int line_number = node->related_ast_node ? node->related_ast_node ->line_number : 0 ;
61+ warning_message (NETLIST, line_number, -1 ,
62+ " Net %s driving node %s is itself undriven." ,
63+ net->name , node->name );
64+ }
65+
66+ for (int i = 0 ; i < net->num_driver_pins ; i++) {
67+ if (net->driver_pins [i]->name != NULL && ((net->driver_pins [i]->node ->type == MULTIPLY) || (net->driver_pins [i]->node ->type == HARD_IP) || (net->driver_pins [i]->node ->type == MEMORY) || (net->driver_pins [i]->node ->type == ADD) || (net->driver_pins [i]->node ->type == MINUS))) {
68+ vtr::free (net->driver_pins [i]->name );
69+ net->driver_pins [i]->name = vtr::strdup (node->name );
70+ } else {
71+ vtr::free (net->driver_pins [i]->node ->name );
72+ net->driver_pins [i]->node ->name = vtr::strdup (node->name );
73+ }
74+ }
75+ }
76+
5577static void print_input_pin (FILE* out, nnode_t * node, long pin_idx) {
5678 oassert (pin_idx < node->num_input_pins );
5779 nnet_t * net = node->input_pins [pin_idx]->net ;
@@ -66,7 +88,7 @@ static void print_input_pin(FILE* out, nnode_t* node, long pin_idx) {
6688 }
6789
6890 for (int i = 0 ; i < net->num_driver_pins ; i++) {
69- if (!net->driver_pins [0 ]->node ) {
91+ if (!net->driver_pins [i ]->node ) {
7092 // Add a warning for an undriven net.
7193 int line_number = node->related_ast_node ? node->related_ast_node ->line_number : 0 ;
7294 warning_message (NETLIST, line_number, -1 ,
@@ -170,25 +192,20 @@ void output_blif(FILE* out, netlist_t* netlist) {
170192 fprintf (out, " \n .names gnd\n .names unconn\n .names vcc\n 1\n " );
171193 fprintf (out, " \n " );
172194
195+
196+ /* replace the names of intermediate nodes with output */
197+ for (long i = 0 ; i < netlist->num_top_output_nodes ; i++) {
198+ nnode_t * node = netlist->top_output_nodes [i];
199+ replace_input_names (node, 0 );
200+ }
201+
173202 /* traverse the internals of the flat net-list */
174203 if (strcmp (configuration.output_type .c_str (), " blif" ) == 0 ) {
175204 depth_first_traversal_to_output (OUTPUT_TRAVERSE_VALUE, out, netlist);
176205 } else {
177206 error_message (NETLIST, 0 , -1 , " %s" , " Invalid output file type." );
178207 }
179208
180- /* connect all the outputs up to the last gate */
181- for (long i = 0 ; i < netlist->num_top_output_nodes ; i++) {
182- nnode_t * node = netlist->top_output_nodes [i];
183-
184- fprintf (out, " .names" );
185- print_input_pin (out, node, 0 );
186- print_output_pin (out, node);
187- fprintf (out, " \n " );
188-
189- fprintf (out, " 1 1\n\n " );
190- }
191-
192209 /* finish off the top level module */
193210 fprintf (out, " .end\n " );
194211 fprintf (out, " \n " );
0 commit comments