remove buffers in opt_clean
authorClifford Wolf <clifford@clifford.at>
Fri, 3 Oct 2014 08:04:15 +0000 (10:04 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 3 Oct 2014 08:04:15 +0000 (10:04 +0200)
passes/opt/opt_clean.cc

index 0e5ed238f358c0b91e26bf3305ac9b1b624a864d..15bbf54e0fdef175143b0ab6c99d521c35f995e2 100644 (file)
@@ -293,6 +293,19 @@ void rmunused_module(RTLIL::Module *module, bool purge_mode, bool verbose)
        if (verbose)
                log("Finding unused cells or wires in module %s..\n", module->name.c_str());
 
+       std::vector<RTLIL::Cell*> delcells;
+       for (auto cell : module->cells())
+               if (cell->type == "$pos") {
+                       bool is_signed = cell->getParam("\\A_SIGNED").as_bool();
+                       RTLIL::SigSpec a = cell->getPort("\\A");
+                       RTLIL::SigSpec y = cell->getPort("\\Y");
+                       a.extend_u0(SIZE(y), is_signed);
+                       module->connect(y, a);
+                       delcells.push_back(cell);
+               }
+       for (auto cell : delcells)
+               module->remove(cell);
+
        rmunused_module_cells(module, verbose);
        rmunused_module_signals(module, purge_mode, verbose);
 }