Skip to content

Commit

Permalink
write_verilog: avoid emitting empty cases.
Browse files Browse the repository at this point in the history
The Verilog grammar does not allow an empty case.  Most synthesis tools
are quite permissive about this, but Quartus is not.  This causes
problems for amaranth with Quartus (see amaranth-lang/amaranth#931).
  • Loading branch information
wanda-phi committed Oct 7, 2023
1 parent a1923a5 commit c36cf9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backends/verilog/verilog_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,11 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
dump_case_body(f, indent + " ", *it);
}

if (sw->cases.empty()) {
// Verilog does not allow empty cases.
f << stringf("%s default: ;\n", indent.c_str());
}

f << stringf("%s" "endcase\n", indent.c_str());
}

Expand Down

0 comments on commit c36cf9c

Please sign in to comment.