Skip to content

Commit 1e2f698

Browse files
author
djns1
committed
Fixed cyclic loop thing
1 parent 676581d commit 1e2f698

File tree

5 files changed

+48
-39
lines changed

5 files changed

+48
-39
lines changed

ODIN_II/SRC/netlist_create_from_ast.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,10 +3128,6 @@ void terminate_registered_assignment(ast_node_t* always_node, signal_list_t* ass
31283128
npin_t* ff_output_pin = allocate_npin();
31293129
add_output_pin_to_node(ff_node, ff_output_pin, 0);
31303130

3131-
if (net->num_driver_pins > 0) {
3132-
warning_message(NETLIST, always_node->line_number, always_node->file_number,
3133-
"You've defined the driver \"%s\" twice\nThis may happen if you use inout or assign multiple times", get_pin_name(pin->name));
3134-
}
31353131
add_driver_pin_to_net(net, ff_output_pin);
31363132

31373133
verilog_netlist->ff_nodes = (nnode_t**)vtr::realloc(verilog_netlist->ff_nodes, sizeof(nnode_t*) * (verilog_netlist->num_ff_nodes + 1));

ODIN_II/SRC/output_blif.cpp

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ void define_ff(nnode_t* node, FILE* out);
5252
void define_decoded_mux(nnode_t* node, FILE* out);
5353
void 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+
5577
static 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\n1\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");
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
module inout_basic(dir, out1, out2);
2-
input dir;
3-
inout out1;
4-
inout out2;
5-
assign out2 = (dir) ? out1 : 1'bz;
6-
assign out1 = (!dir) ? out2 : 1'bz;
7-
endmodule
1+
module inout_basic(input dir, inout io, output out);
2+
assign io = (dir) ? dir : 1'bz;
3+
assign out = (!dir) ? io : 1'bx;
4+
endmodule
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
GLOBAL_SIM_BASE_CLK dir out1 out2
2-
0 1 0 0
3-
0 1 0 1
4-
0 1 1 0
5-
0 1 1 1
6-
0 0 0 0
7-
0 0 0 1
8-
0 0 1 0
9-
0 0 1 1
1+
GLOBAL_SIM_BASE_CLK dir io
2+
0 1 0
3+
0 1 0
4+
0 1 1
5+
0 1 1
6+
0 0 0
7+
0 0 0
8+
0 0 1
9+
0 0 1
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
out1 out2
1+
io out
2+
1 x
3+
1 x
4+
1 x
5+
1 x
26
0 0
37
0 0
4-
0 1
5-
0 1
6-
0 0
7-
1 1
8-
0 0
98
1 1
109
1 1

0 commit comments

Comments
 (0)