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:
commit
cc3d569ade
5 changed files with 39 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
19
tests/proc/bug5572.ys
Normal 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:*
|
||||
1
tests/verilog/.gitignore
vendored
1
tests/verilog/.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
/bug5572.v
|
||||
/const_arst.v
|
||||
/const_sr.v
|
||||
/doubleslash.v
|
||||
|
|
|
|||
15
tests/verilog/bug5572.ys
Normal file
15
tests/verilog/bug5572.ys
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue