Merge remote-tracking branch 'origin/master' into xc7dsp
[yosys.git] / techlibs / ecp5 / synth_ecp5.cc
index a8075e86eb62004d84a04257845010ae6d569433..0a3dcc62cc93fee763bed99fa7a5ad5d27b0c3f5 100644 (file)
@@ -89,6 +89,9 @@ struct SynthEcp5Pass : public ScriptPass
                log("        generate an output netlist (and BLIF file) suitable for VPR\n");
                log("        (this feature is experimental and incomplete)\n");
                log("\n");
+               log("    -nodsp\n");
+               log("        do not map multipliers to MULT18X18D\n");
+               log("\n");
                log("\n");
                log("The following commands are executed by this synthesis command:\n");
                help_script();
@@ -96,7 +99,7 @@ struct SynthEcp5Pass : public ScriptPass
        }
 
        string top_opt, blif_file, edif_file, json_file;
-       bool noccu2, nodffe, nobram, nolutram, nowidelut, flatten, retime, abc2, abc9, vpr;
+       bool noccu2, nodffe, nobram, nolutram, nowidelut, flatten, retime, abc2, abc9, nodsp, vpr;
 
        void clear_flags() YS_OVERRIDE
        {
@@ -114,6 +117,7 @@ struct SynthEcp5Pass : public ScriptPass
                abc2 = false;
                vpr = false;
                abc9 = false;
+               nodsp = false;
        }
 
        void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
@@ -192,6 +196,10 @@ struct SynthEcp5Pass : public ScriptPass
                                abc9 = true;
                                continue;
                        }
+                       if (args[argidx] == "-nodsp") {
+                               nodsp = true;
+                               continue;
+                       }
                        break;
                }
                extra_args(args, argidx, design);
@@ -228,7 +236,29 @@ struct SynthEcp5Pass : public ScriptPass
 
                if (check_label("coarse"))
                {
-                       run("synth -run coarse");
+                       run("opt_expr");
+                       run("opt_clean");
+                       run("check");
+                       run("opt");
+                       run("wreduce");
+                       run("peepopt");
+                       run("opt_clean");
+                       run("share");
+                       run("techmap -map +/cmp2lut.v -D LUT_WIDTH=4");
+                       run("opt_expr");
+                       run("opt_clean");
+                       if (!nodsp) {
+                               run("techmap -map +/mul2dsp.v -D DSP_A_MAXWIDTH=18 -D DSP_B_MAXWIDTH=18  -D DSP_A_MINWIDTH=2 -D DSP_B_MINWIDTH=2  -D DSP_NAME=$__MUL18X18", "(unless -nodsp)");
+                               run("clean", "(unless -nodsp)");
+                               run("techmap -map +/ecp5/dsp_map.v", "(unless -nodsp)");
+                               run("chtype -set $mul t:$__soft_mul", "(unless -nodsp)");
+                       }
+                       run("alumacc");
+                       run("opt");
+                       run("fsm");
+                       run("opt -fast");
+                       run("memory -nomap");
+                       run("opt_clean");
                }
 
                if (!nobram && check_label("map_bram", "(skip if -nobram)"))
@@ -280,12 +310,17 @@ struct SynthEcp5Pass : public ScriptPass
                        if (abc2 || help_mode) {
                                run("abc", "      (only if -abc2)");
                        }
-                       run("techmap -map +/ecp5/latches_map.v");
+                       std::string techmap_args = "-map +/ecp5/latches_map.v";
+                       if (abc9)
+                               techmap_args += " -map +/ecp5/abc_map.v -max_iter 1";
+                       run("techmap " + techmap_args);
+
                        if (abc9) {
                                if (nowidelut)
                                        run("abc9 -lut +/ecp5/abc_5g_nowide.lut -box +/ecp5/abc_5g.box -W 200");
                                else
                                        run("abc9 -lut +/ecp5/abc_5g.lut -box +/ecp5/abc_5g.box -W 200");
+                               run("techmap -map +/ecp5/abc_unmap.v");
                        } else {
                                if (nowidelut)
                                        run("abc -lut 4 -dress");