From 9ae21263f0de0c0011c7de290af3600ddeb51a34 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 24 Feb 2015 22:31:30 +0100 Subject: [PATCH] Some cleanups in "clean" --- kernel/rtlil.h | 8 ++++++++ passes/opt/opt.cc | 4 ++++ passes/opt/opt_clean.cc | 21 ++++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index dd40e2fba..1d0008f9d 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -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; } diff --git a/passes/opt/opt.cc b/passes/opt/opt.cc index 25419375e..5ca57a147 100644 --- a/passes/opt/opt.cc +++ b/passes/opt/opt.cc @@ -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(); } diff --git a/passes/opt/opt_clean.cc b/passes/opt/opt_clean.cc index aea341759..e9f653e5f 100644 --- a/passes/opt/opt_clean.cc +++ b/passes/opt/opt_clean.cc @@ -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) -- 2.30.2