From ed519f578eb965f9976931c817aa54e3cd89710d Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 30 Sep 2016 17:02:38 +0200 Subject: [PATCH] Added "opt_rmdff -keepdc" --- passes/opt/opt.cc | 10 ++++++---- passes/opt/opt_rmdff.cc | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/passes/opt/opt.cc b/passes/opt/opt.cc index 13ea5469b..021c1a03f 100644 --- a/passes/opt/opt.cc +++ b/passes/opt/opt.cc @@ -44,7 +44,7 @@ struct OptPass : public Pass { log(" opt_muxtree\n"); log(" opt_reduce [-fine] [-full]\n"); log(" opt_merge [-share_all]\n"); - log(" opt_rmdff\n"); + log(" opt_rmdff [-keepdc]\n"); log(" opt_clean [-purge]\n"); log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n"); log(" while \n"); @@ -54,7 +54,7 @@ struct OptPass : public Pass { log(" do\n"); log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n"); log(" opt_merge [-share_all]\n"); - log(" opt_rmdff\n"); + log(" opt_rmdff [-keepdc]\n"); log(" opt_clean [-purge]\n"); log(" while \n"); log("\n"); @@ -69,6 +69,7 @@ struct OptPass : public Pass { std::string opt_expr_args; std::string opt_reduce_args; std::string opt_merge_args; + std::string opt_rmdff_args; bool fast_mode = false; log_header(design, "Executing OPT pass (performing simple optimizations).\n"); @@ -108,6 +109,7 @@ struct OptPass : public Pass { } if (args[argidx] == "-keepdc") { opt_expr_args += " -keepdc"; + opt_rmdff_args += " -keepdc"; continue; } if (args[argidx] == "-share_all") { @@ -128,7 +130,7 @@ struct OptPass : public Pass { Pass::call(design, "opt_expr" + opt_expr_args); Pass::call(design, "opt_merge" + opt_merge_args); design->scratchpad_unset("opt.did_something"); - Pass::call(design, "opt_rmdff"); + Pass::call(design, "opt_rmdff" + opt_rmdff_args); if (design->scratchpad_get_bool("opt.did_something") == false) break; Pass::call(design, "opt_clean" + opt_clean_args); @@ -145,7 +147,7 @@ struct OptPass : public Pass { Pass::call(design, "opt_muxtree"); Pass::call(design, "opt_reduce" + opt_reduce_args); Pass::call(design, "opt_merge" + opt_merge_args); - Pass::call(design, "opt_rmdff"); + Pass::call(design, "opt_rmdff" + opt_rmdff_args); Pass::call(design, "opt_clean" + opt_clean_args); Pass::call(design, "opt_expr" + opt_expr_args); if (design->scratchpad_get_bool("opt.did_something") == false) diff --git a/passes/opt/opt_rmdff.cc b/passes/opt/opt_rmdff.cc index fa954afac..7e87d1adc 100644 --- a/passes/opt/opt_rmdff.cc +++ b/passes/opt/opt_rmdff.cc @@ -29,6 +29,7 @@ PRIVATE_NAMESPACE_BEGIN SigMap assign_map, dff_init_map; SigSet mux_drivers; dict> init_attributes; +bool keepdc; void remove_init_attr(SigSpec sig) { @@ -115,7 +116,7 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff) bool has_init = false; RTLIL::Const val_init; for (auto bit : dff_init_map(sig_q).to_sigbit_vector()) { - if (bit.wire == NULL) + if (bit.wire == NULL || keepdc) has_init = true; val_init.bits.push_back(bit.wire == NULL ? bit.data : RTLIL::State::Sx); } @@ -182,7 +183,7 @@ struct OptRmdffPass : public Pass { { // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); - log(" opt_rmdff [selection]\n"); + log(" opt_rmdff [-keepdc] [selection]\n"); log("\n"); log("This pass identifies flip-flops with constant inputs and replaces them with\n"); log("a constant driver.\n"); @@ -193,7 +194,17 @@ struct OptRmdffPass : public Pass { int total_count = 0, total_initdrv = 0; log_header(design, "Executing OPT_RMDFF pass (remove dff with constant values).\n"); - extra_args(args, 1, design); + keepdc = false; + + size_t argidx; + for (argidx = 1; argidx < args.size(); argidx++) { + if (args[argidx] == "-keepdc") { + keepdc = true; + continue; + } + break; + } + extra_args(args, argidx, design); for (auto module : design->selected_modules()) { -- 2.30.2