Merge pull request #4417 from kivikakk/cxxrtl-unused-output

cxxrtl: don't emit invalid code on unconnected outputs.
This commit is contained in:
Catherine 2024-06-09 21:35:42 +01:00 committed by GitHub
commit 9f94ecf4ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 1 deletions

View File

@ -1138,7 +1138,7 @@ struct CxxrtlWorker {
f << indent << "// cell " << cell->name.str() << " syncs\n"; f << indent << "// cell " << cell->name.str() << " syncs\n";
for (auto conn : cell->connections()) for (auto conn : cell->connections())
if (cell->output(conn.first)) if (cell->output(conn.first))
if (is_cxxrtl_sync_port(cell, conn.first)) { if (is_cxxrtl_sync_port(cell, conn.first) && !conn.second.empty()) {
f << indent; f << indent;
dump_sigspec_lhs(conn.second, for_debug); dump_sigspec_lhs(conn.second, for_debug);
f << " = " << mangle(cell) << access << mangle_wire_name(conn.first) << ".curr;\n"; f << " = " << mangle(cell) << access << mangle_wire_name(conn.first) << ".curr;\n";

View File

@ -11,3 +11,7 @@ run_subtest () {
run_subtest value run_subtest value
run_subtest value_fuzz run_subtest value_fuzz
# Compile-only test.
../../yosys -p "read_verilog test_unconnected_output.v; proc; clean; write_cxxrtl cxxrtl-test-unconnected_output.cc"
${CC:-gcc} -std=c++11 -c -o cxxrtl-test-unconnected_output -I../../backends/cxxrtl/runtime cxxrtl-test-unconnected_output.cc

View File

@ -0,0 +1,24 @@
(* cxxrtl_blackbox *)
module blackbox(...);
(* cxxrtl_edge = "p" *)
input clk;
(* cxxrtl_sync *)
output [7:0] out1;
(* cxxrtl_sync *)
output [7:0] out2;
endmodule
module unconnected_output(
input clk,
in,
output out
);
blackbox bb (
.clock (clock),
.in (in),
.out1 (out),
.out2 (/* unconnected */),
);
endmodule