Bugfix in opt_const $eq -> buffer code
authorClifford Wolf <clifford@clifford.at>
Sat, 31 Jan 2015 22:25:32 +0000 (23:25 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 31 Jan 2015 22:25:32 +0000 (23:25 +0100)
passes/opt/opt_const.cc

index 6a830dd0de1d6176fbd1adffcfb65485c24e2079..55da987af89cff5a1222d5ff5b64ae37744f8593 100644 (file)
@@ -524,11 +524,11 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
                        RTLIL::SigSpec a = assign_map(cell->getPort("\\A"));
                        RTLIL::SigSpec b = assign_map(cell->getPort("\\B"));
 
-                       if (a.is_fully_const()) {
+                       if (a.is_fully_const() && !b.is_fully_const()) {
                                cover_list("opt.opt_const.eqneq.swapconst", "$eq", "$ne", cell->type.str());
-                               RTLIL::SigSpec tmp = cell->getPort("\\A");
-                               cell->setPort("\\A", cell->getPort("\\B"));
-                               cell->setPort("\\B", tmp);
+                               cell->setPort("\\A", b);
+                               cell->setPort("\\B", a);
+                               std::swap(a, b);
                        }
 
                        if (b.is_fully_const()) {