Fixed "dff2dffe -direct-match"
authorClifford Wolf <clifford@clifford.at>
Thu, 16 Apr 2015 09:47:59 +0000 (11:47 +0200)
committerClifford Wolf <clifford@clifford.at>
Thu, 16 Apr 2015 09:47:59 +0000 (11:47 +0200)
passes/techmap/dff2dffe.cc
techlibs/ice40/synth_ice40.cc

index 1ec4cf5e9280f98a454721b77e30df7a5f5c6abf..4d2808851d664608f86981fca2f99df52735cfe7 100644 (file)
@@ -243,9 +243,11 @@ struct Dff2dffeWorker
 
        void run()
        {
-               log("Transforming $dff to $dffe cells in module %s:\n", log_id(module));
-               for (auto dff_cell : dff_cells)
+               log("Transforming FF to FF+Enable cells in module %s:\n", log_id(module));
+               for (auto dff_cell : dff_cells) {
+                       // log("Handling candidate %s:\n", log_id(dff_cell));
                        handle_dff_cell(dff_cell);
+               }
        }
 };
 
@@ -301,23 +303,32 @@ struct Dff2dffePass : public Pass {
                                continue;
                        }
                        if (args[argidx] == "-direct-match" && argidx + 1 < args.size()) {
+                               bool found_match = false;
                                const char *pattern = args[++argidx].c_str();
-                               if (patmatch(pattern, "$_DFF_P_"  ))  direct_dict["$_DFF_P_" ] = "$_DFFE_P_";
-                               if (patmatch(pattern, "$_DFF_N_"  ))  direct_dict["$_DFF_N_" ] = "$_DFFE_N_";
-                               if (patmatch(pattern, "$_DFF_NN0_")) direct_dict["$_DFF_NN0"] = "$__DFFE_NN0";
-                               if (patmatch(pattern, "$_DFF_NN1_")) direct_dict["$_DFF_NN1"] = "$__DFFE_NN1";
-                               if (patmatch(pattern, "$_DFF_NP0_")) direct_dict["$_DFF_NP0"] = "$__DFFE_NP0";
-                               if (patmatch(pattern, "$_DFF_NP1_")) direct_dict["$_DFF_NP1"] = "$__DFFE_NP1";
-                               if (patmatch(pattern, "$_DFF_PN0_")) direct_dict["$_DFF_PN0"] = "$__DFFE_PN0";
-                               if (patmatch(pattern, "$_DFF_PN1_")) direct_dict["$_DFF_PN1"] = "$__DFFE_PN1";
-                               if (patmatch(pattern, "$_DFF_PP0_")) direct_dict["$_DFF_PP0"] = "$__DFFE_PP0";
-                               if (patmatch(pattern, "$_DFF_PP1_")) direct_dict["$_DFF_PP1"] = "$__DFFE_PP1";
+                               if (patmatch(pattern, "$_DFF_P_"  )) found_match = true, direct_dict["$_DFF_P_"  ] = "$_DFFE_P_";
+                               if (patmatch(pattern, "$_DFF_N_"  )) found_match = true, direct_dict["$_DFF_N_"  ] = "$_DFFE_N_";
+                               if (patmatch(pattern, "$_DFF_NN0_")) found_match = true, direct_dict["$_DFF_NN0_"] = "$__DFFE_NN0";
+                               if (patmatch(pattern, "$_DFF_NN1_")) found_match = true, direct_dict["$_DFF_NN1_"] = "$__DFFE_NN1";
+                               if (patmatch(pattern, "$_DFF_NP0_")) found_match = true, direct_dict["$_DFF_NP0_"] = "$__DFFE_NP0";
+                               if (patmatch(pattern, "$_DFF_NP1_")) found_match = true, direct_dict["$_DFF_NP1_"] = "$__DFFE_NP1";
+                               if (patmatch(pattern, "$_DFF_PN0_")) found_match = true, direct_dict["$_DFF_PN0_"] = "$__DFFE_PN0";
+                               if (patmatch(pattern, "$_DFF_PN1_")) found_match = true, direct_dict["$_DFF_PN1_"] = "$__DFFE_PN1";
+                               if (patmatch(pattern, "$_DFF_PP0_")) found_match = true, direct_dict["$_DFF_PP0_"] = "$__DFFE_PP0";
+                               if (patmatch(pattern, "$_DFF_PP1_")) found_match = true, direct_dict["$_DFF_PP1_"] = "$__DFFE_PP1";
+                               if (!found_match)
+                                       log_cmd_error("No cell types matched pattern '%s'.\n", pattern);
                                continue;
                        }
                        break;
                }
                extra_args(args, argidx, design);
 
+               if (!direct_dict.empty()) {
+                       log("Selected cell types for direct conversion:\n");
+                       for (auto &it : direct_dict)
+                               log("  %s -> %s\n", log_id(it.first), log_id(it.second));
+               }
+
                for (auto mod : design->selected_modules())
                        if (!mod->has_processes_warn())
                        {
index b683929bf5c212fa683d01e0f8daa53228c37a07..c5d8f5edbd563c27b106ff548eff83caa8741688 100644 (file)
@@ -72,6 +72,7 @@ struct SynthIce40Pass : public Pass {
                log("    map_ffs:\n");
                log("        dff2dffe -direct-match $_DFF_*\n");
                log("        techmap -map +/ice40/cells_map.v\n");
+               log("        opt_const -mux_undef\n");
                log("        simplemap\n");
                log("        clean\n");
                log("\n");
@@ -145,6 +146,7 @@ struct SynthIce40Pass : public Pass {
                {
                        Pass::call(design, "dff2dffe -direct-match $_DFF_*");
                        Pass::call(design, "techmap -map +/ice40/cells_map.v");
+                       Pass::call(design, "opt_const -mux_undef");
                        Pass::call(design, "simplemap");
                        Pass::call(design, "clean");
                }