Added "opt_rmdff -keepdc"

This commit is contained in:
Clifford Wolf 2016-09-30 17:02:38 +02:00
parent ca5462523e
commit ed519f578e
2 changed files with 20 additions and 7 deletions

View File

@ -44,7 +44,7 @@ struct OptPass : public Pass {
log(" opt_muxtree\n"); log(" opt_muxtree\n");
log(" opt_reduce [-fine] [-full]\n"); log(" opt_reduce [-fine] [-full]\n");
log(" opt_merge [-share_all]\n"); log(" opt_merge [-share_all]\n");
log(" opt_rmdff\n"); log(" opt_rmdff [-keepdc]\n");
log(" opt_clean [-purge]\n"); log(" opt_clean [-purge]\n");
log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n"); log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n");
log(" while <changed design>\n"); log(" while <changed design>\n");
@ -54,7 +54,7 @@ struct OptPass : public Pass {
log(" do\n"); log(" do\n");
log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n"); log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-clkinv] [-fine] [-full] [-keepdc]\n");
log(" opt_merge [-share_all]\n"); log(" opt_merge [-share_all]\n");
log(" opt_rmdff\n"); log(" opt_rmdff [-keepdc]\n");
log(" opt_clean [-purge]\n"); log(" opt_clean [-purge]\n");
log(" while <changed design in opt_rmdff>\n"); log(" while <changed design in opt_rmdff>\n");
log("\n"); log("\n");
@ -69,6 +69,7 @@ struct OptPass : public Pass {
std::string opt_expr_args; std::string opt_expr_args;
std::string opt_reduce_args; std::string opt_reduce_args;
std::string opt_merge_args; std::string opt_merge_args;
std::string opt_rmdff_args;
bool fast_mode = false; bool fast_mode = false;
log_header(design, "Executing OPT pass (performing simple optimizations).\n"); log_header(design, "Executing OPT pass (performing simple optimizations).\n");
@ -108,6 +109,7 @@ struct OptPass : public Pass {
} }
if (args[argidx] == "-keepdc") { if (args[argidx] == "-keepdc") {
opt_expr_args += " -keepdc"; opt_expr_args += " -keepdc";
opt_rmdff_args += " -keepdc";
continue; continue;
} }
if (args[argidx] == "-share_all") { 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_expr" + opt_expr_args);
Pass::call(design, "opt_merge" + opt_merge_args); Pass::call(design, "opt_merge" + opt_merge_args);
design->scratchpad_unset("opt.did_something"); 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) if (design->scratchpad_get_bool("opt.did_something") == false)
break; break;
Pass::call(design, "opt_clean" + opt_clean_args); 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_muxtree");
Pass::call(design, "opt_reduce" + opt_reduce_args); Pass::call(design, "opt_reduce" + opt_reduce_args);
Pass::call(design, "opt_merge" + opt_merge_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_clean" + opt_clean_args);
Pass::call(design, "opt_expr" + opt_expr_args); Pass::call(design, "opt_expr" + opt_expr_args);
if (design->scratchpad_get_bool("opt.did_something") == false) if (design->scratchpad_get_bool("opt.did_something") == false)

View File

@ -29,6 +29,7 @@ PRIVATE_NAMESPACE_BEGIN
SigMap assign_map, dff_init_map; SigMap assign_map, dff_init_map;
SigSet<RTLIL::Cell*> mux_drivers; SigSet<RTLIL::Cell*> mux_drivers;
dict<SigBit, pool<SigBit>> init_attributes; dict<SigBit, pool<SigBit>> init_attributes;
bool keepdc;
void remove_init_attr(SigSpec sig) void remove_init_attr(SigSpec sig)
{ {
@ -115,7 +116,7 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff)
bool has_init = false; bool has_init = false;
RTLIL::Const val_init; RTLIL::Const val_init;
for (auto bit : dff_init_map(sig_q).to_sigbit_vector()) { for (auto bit : dff_init_map(sig_q).to_sigbit_vector()) {
if (bit.wire == NULL) if (bit.wire == NULL || keepdc)
has_init = true; has_init = true;
val_init.bits.push_back(bit.wire == NULL ? bit.data : RTLIL::State::Sx); 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---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n"); log("\n");
log(" opt_rmdff [selection]\n"); log(" opt_rmdff [-keepdc] [selection]\n");
log("\n"); log("\n");
log("This pass identifies flip-flops with constant inputs and replaces them with\n"); log("This pass identifies flip-flops with constant inputs and replaces them with\n");
log("a constant driver.\n"); log("a constant driver.\n");
@ -193,7 +194,17 @@ struct OptRmdffPass : public Pass {
int total_count = 0, total_initdrv = 0; int total_count = 0, total_initdrv = 0;
log_header(design, "Executing OPT_RMDFF pass (remove dff with constant values).\n"); 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()) for (auto module : design->selected_modules())
{ {