Skip to content

Commit

Permalink
proc_prune: fix handling of exactly identical assigns.
Browse files Browse the repository at this point in the history
Before this commit, in a process like:
   process $proc$bug.v:8$3
     assign $foo \bar
     switch \sel
       case 1'1
         assign $foo 1'1
         assign $foo 1'1
       case
         assign $foo 1'0
     end
   end
both of the "assign $foo 1'1" would incorrectly be removed.

Fixes YosysHQ#1243.
  • Loading branch information
whitequark committed Aug 8, 2019
1 parent 3414ee1 commit 0b09a34
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions passes/proc/proc_prune.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ struct PruneWorker
pool<RTLIL::SigBit> sw_assigned = do_switch((*it), assigned, affected);
assigned.insert(sw_assigned.begin(), sw_assigned.end());
}
pool<RTLIL::SigSig> remove;
for (auto it = cs->actions.rbegin(); it != cs->actions.rend(); ++it) {
for (auto it = cs->actions.rbegin(); it != cs->actions.rend(); ) {
RTLIL::SigSpec lhs = sigmap(it->first);
bool redundant = true;
for (auto &bit : lhs) {
Expand All @@ -75,9 +74,10 @@ struct PruneWorker
break;
}
}
bool remove = false;
if (redundant) {
removed_count++;
remove.insert(*it);
remove = true;
} else {
if (root) {
bool promotable = true;
Expand All @@ -99,7 +99,7 @@ struct PruneWorker
}
promoted_count++;
module->connect(conn);
remove.insert(*it);
remove = true;
}
}
for (auto &bit : lhs)
Expand All @@ -109,11 +109,9 @@ struct PruneWorker
if (bit.wire)
affected.insert(bit);
}
}
for (auto it = cs->actions.begin(); it != cs->actions.end(); ) {
if (remove[*it]) {
it = cs->actions.erase(it);
} else it++;
if (remove)
cs->actions.erase((it++).base() - 1);
else it++;
}
return assigned;
}
Expand Down

0 comments on commit 0b09a34

Please sign in to comment.