Skip to content

Commit

Permalink
write_verilog: Handle edge case with non-pruned processes
Browse files Browse the repository at this point in the history
This change only matters for processes that weren't processed by
`proc_rmdead` for which follow-up cases after a default case are treated
differently in Verilog and RTLIL semantics.
  • Loading branch information
povik committed Jan 6, 2024
1 parent 1ddb089 commit 2f8a9d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backends/verilog/verilog_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1992,8 +1992,6 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it) {
dump_attributes(f, indent + " ", (*it)->attributes, '\n', /*modattr=*/false, /*regattr=*/false, /*as_comment=*/true);
if ((*it)->compare.size() == 0) {
if (got_default)
continue;
f << stringf("%s default", indent.c_str());
got_default = true;
} else {
Expand All @@ -2006,6 +2004,14 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
}
f << stringf(":\n");
dump_case_body(f, indent + " ", *it);

if (got_default) {
// If we followed up the default with more cases the Verilog
// semantics would be to match those *before* the default, but
// the RTLIL semantics are to match those *after* the default
// (so they can never be selected). Exit now.
break;
}
}

if (sw->cases.empty()) {
Expand Down

0 comments on commit 2f8a9d0

Please sign in to comment.