@@ -52,6 +52,28 @@ void define_ff(nnode_t* node, FILE* out);
52
52
void define_decoded_mux (nnode_t * node, FILE* out);
53
53
void output_blif_pin_connect (nnode_t * node, FILE* out);
54
54
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
+
55
77
static void print_input_pin (FILE* out, nnode_t * node, long pin_idx) {
56
78
oassert (pin_idx < node->num_input_pins );
57
79
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) {
66
88
}
67
89
68
90
for (int i = 0 ; i < net->num_driver_pins ; i++) {
69
- if (!net->driver_pins [0 ]->node ) {
91
+ if (!net->driver_pins [i ]->node ) {
70
92
// Add a warning for an undriven net.
71
93
int line_number = node->related_ast_node ? node->related_ast_node ->line_number : 0 ;
72
94
warning_message (NETLIST, line_number, -1 ,
@@ -170,25 +192,20 @@ void output_blif(FILE* out, netlist_t* netlist) {
170
192
fprintf (out, " \n .names gnd\n .names unconn\n .names vcc\n 1\n " );
171
193
fprintf (out, " \n " );
172
194
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
+
173
202
/* traverse the internals of the flat net-list */
174
203
if (strcmp (configuration.output_type .c_str (), " blif" ) == 0 ) {
175
204
depth_first_traversal_to_output (OUTPUT_TRAVERSE_VALUE, out, netlist);
176
205
} else {
177
206
error_message (NETLIST, 0 , -1 , " %s" , " Invalid output file type." );
178
207
}
179
208
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
-
192
209
/* finish off the top level module */
193
210
fprintf (out, " .end\n " );
194
211
fprintf (out, " \n " );
0 commit comments