Skip to content

Commit

Permalink
proc_clean: only consider fully-defined case operands.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottia authored and mwkmwkmwk committed Aug 12, 2023
1 parent 4097897 commit bf84861
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion passes/proc/proc_clean.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void proc_clean_switch(RTLIL::SwitchRule *sw, RTLIL::CaseRule *parent, bool &did
break;
for (int j = 0; j < int(cs->compare.size()); j++) {
RTLIL::SigSpec &val = cs->compare[j];
if (!val.is_fully_const())
if (!val.is_fully_def())
continue;
if (val == sw->signal) {
cs->compare.clear();
Expand Down
22 changes: 22 additions & 0 deletions tests/proc/clean_undef_case.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
read_rtlil <<EOT

module \m
wire width 1 \w
process $p
switch 3'001
case 3'--1
assign \w 3'001
case 3'-1-
assign \w 3'010
case 3'1--
assign \w 3'100
end
end
end

EOT

proc_clean # Bug: removes the cases.
proc_clean # Removes the now-empty switch and its containing process.

select -assert-count 1 */p:*

0 comments on commit bf84861

Please sign in to comment.