Some cleanups in "clean"
authorClifford Wolf <clifford@clifford.at>
Tue, 24 Feb 2015 21:31:30 +0000 (22:31 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 24 Feb 2015 21:31:30 +0000 (22:31 +0100)
kernel/rtlil.h
passes/opt/opt.cc
passes/opt/opt_clean.cc

index dd40e2fbadeb290574697bcf9755b2925c604c25..1d0008f9d4c471447ec49a9902efc4167ca76750 100644 (file)
@@ -807,6 +807,14 @@ struct RTLIL::Design
        bool selected_module(RTLIL::Module *mod) const;
        bool selected_whole_module(RTLIL::Module *mod) const;
 
+       RTLIL::Selection &selection() {
+               return selection_stack.back();
+       }
+
+       const RTLIL::Selection &selection() const {
+               return selection_stack.back();
+       }
+
        bool full_selection() const {
                return selection_stack.back().full_selection;
        }
index 25419375e93f62f138b12e2870ccfb1e38a704cd..5ca57a147650007e11e54e56d1a834c0c8464d34 100644 (file)
@@ -145,6 +145,10 @@ struct OptPass : public Pass {
                        }
                }
 
+               design->optimize();
+               design->sort();
+               design->check();
+
                log_header(fast_mode ? "Finished fast OPT passes.\n" : "Finished OPT passes. (There is nothing left to do.)\n");
                log_pop();
        }
index aea341759c27429b647f75de7803447d623d680b..e9f653e5fac9be9c336c148ae53361df4d33d3ce 100644 (file)
@@ -296,8 +296,14 @@ void rmunused_module(RTLIL::Module *module, bool purge_mode, bool verbose)
                        module->connect(y, a);
                        delcells.push_back(cell);
                }
-       for (auto cell : delcells)
+       for (auto cell : delcells) {
+               if (verbose)
+                       log("  removing buffer cell `%s': %s = %s\n", cell->name.c_str(),
+                                       log_signal(cell->getPort("\\Y")), log_signal(cell->getPort("\\A")));
                module->remove(cell);
+       }
+       if (!delcells.empty())
+               module->design->scratchpad_set_bool("opt.did_something", true);
 
        rmunused_module_cells(module, verbose);
        rmunused_module_signals(module, purge_mode, verbose);
@@ -353,6 +359,10 @@ struct OptCleanPass : public Pass {
                        rmunused_module(module, purge_mode, true);
                }
 
+               design->optimize();
+               design->sort();
+               design->check();
+
                ct.clear();
                ct_reg.clear();
                log_pop();
@@ -404,13 +414,10 @@ struct CleanPass : public Pass {
                count_rm_cells = 0;
                count_rm_wires = 0;
 
-               for (auto mod : design->selected_whole_modules()) {
-                       if (mod->has_processes())
+               for (auto module : design->selected_whole_modules()) {
+                       if (module->has_processes())
                                continue;
-                       do {
-                               design->scratchpad_unset("opt.did_something");
-                               rmunused_module(mod, purge_mode, false);
-                       } while (design->scratchpad_get_bool("opt.did_something"));
+                       rmunused_module(module, purge_mode, false);
                }
 
                if (count_rm_cells > 0 || count_rm_wires > 0)