3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-01-09 20:39:00 +00:00

Merge pull request #5591 from YosysHQ/krys/clean_empty_switch

Improve handling of empty switches
This commit is contained in:
KrystalDelusion 2026-01-09 11:52:27 +13:00 committed by GitHub
commit cc3d569ade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 0 deletions

View file

@ -2143,6 +2143,9 @@ void dump_case_actions(std::ostream &f, std::string indent, RTLIL::CaseRule *cs)
bool dump_proc_switch_ifelse(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw)
{
if (sw->cases.empty())
return true;
for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it) {
if ((*it)->compare.size() == 0) {
break;

View file

@ -97,6 +97,7 @@ void proc_clean_switch(RTLIL::SwitchRule *sw, RTLIL::CaseRule *parent, bool &did
all_empty = false;
if (all_empty)
{
did_something = true;
for (auto cs : sw->cases)
delete cs;
sw->cases.clear();

19
tests/proc/bug5572.ys Normal file
View file

@ -0,0 +1,19 @@
read_rtlil << EOT
attribute \top 1
module \top
wire width 1 \sig
wire width 1 \val
process $2
switch \sig [0]
case 1'0
case 1'1
case
assign \val [0] 1'1
end
end
end
EOT
proc_rmdead
proc_clean
select -assert-none p:*

View file

@ -1,3 +1,4 @@
/bug5572.v
/const_arst.v
/const_sr.v
/doubleslash.v

15
tests/verilog/bug5572.ys Normal file
View file

@ -0,0 +1,15 @@
read_rtlil << EOT
module \top
wire \sig
wire \val
process $2
attribute \full_case 1
switch \sig
end
end
end
EOT
write_verilog bug5572.v
design -reset
read_verilog bug5572.v