Merge remote-tracking branch 'origin/master' into xc7dsp
[yosys.git] / techlibs / ecp5 / synth_ecp5.cc
index 8e243f7a66dd70e8015bc03018ab007fce3eb897..0a3dcc62cc93fee763bed99fa7a5ad5d27b0c3f5 100644 (file)
@@ -71,10 +71,10 @@ struct SynthEcp5Pass : public ScriptPass
                log("        do not use flipflops with CE in output netlist\n");
                log("\n");
                log("    -nobram\n");
-               log("        do not use BRAM cells in output netlist\n");
+               log("        do not use block RAM cells in output netlist\n");
                log("\n");
-               log("    -nodram\n");
-               log("        do not use distributed RAM cells in output netlist\n");
+               log("    -nolutram\n");
+               log("        do not use LUT RAM cells in output netlist\n");
                log("\n");
                log("    -nowidelut\n");
                log("        do not use PFU muxes to implement LUTs larger than LUT4s\n");
@@ -89,8 +89,8 @@ 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("    -dsp\n");
-               log("        map multipliers to MULT18X18D (EXPERIMENTAL)\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");
@@ -99,7 +99,7 @@ struct SynthEcp5Pass : public ScriptPass
        }
 
        string top_opt, blif_file, edif_file, json_file;
-       bool noccu2, nodffe, nobram, nodram, nowidelut, flatten, retime, abc2, abc9, dsp, vpr;
+       bool noccu2, nodffe, nobram, nolutram, nowidelut, flatten, retime, abc2, abc9, nodsp, vpr;
 
        void clear_flags() YS_OVERRIDE
        {
@@ -110,14 +110,14 @@ struct SynthEcp5Pass : public ScriptPass
                noccu2 = false;
                nodffe = false;
                nobram = false;
-               nodram = false;
+               nolutram = false;
                nowidelut = false;
                flatten = true;
                retime = false;
                abc2 = false;
                vpr = false;
                abc9 = false;
-               dsp = false;
+               nodsp = false;
        }
 
        void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
@@ -176,11 +176,11 @@ struct SynthEcp5Pass : public ScriptPass
                                nobram = true;
                                continue;
                        }
-                       if (args[argidx] == "-nodram") {
-                               nodram = true;
+                       if (args[argidx] == "-nolutram" || /*deprecated alias*/ args[argidx] == "-nodram") {
+                               nolutram = true;
                                continue;
                        }
-                       if (args[argidx] == "-nowidelut" || args[argidx] == "-nomux") {
+                       if (args[argidx] == "-nowidelut" || /*deprecated alias*/ args[argidx] == "-nomux") {
                                nowidelut = true;
                                continue;
                        }
@@ -196,8 +196,8 @@ struct SynthEcp5Pass : public ScriptPass
                                abc9 = true;
                                continue;
                        }
-                       if (args[argidx] == "-dsp") {
-                               dsp = true;
+                       if (args[argidx] == "-nodsp") {
+                               nodsp = true;
                                continue;
                        }
                        break;
@@ -247,10 +247,11 @@ struct SynthEcp5Pass : public ScriptPass
                        run("techmap -map +/cmp2lut.v -D LUT_WIDTH=4");
                        run("opt_expr");
                        run("opt_clean");
-                       if (dsp) {
-                               run("techmap -map +/mul2dsp.v -D DSP_A_MAXWIDTH=18 -D DSP_B_MAXWIDTH=18 -D DSP_NAME=$__MUL18X18");
-                               run("clean");
-                               run("techmap -map +/ecp5/dsp_map.v");
+                       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");
@@ -260,23 +261,27 @@ struct SynthEcp5Pass : public ScriptPass
                        run("opt_clean");
                }
 
-               if (!nobram && check_label("bram", "(skip if -nobram)"))
+               if (!nobram && check_label("map_bram", "(skip if -nobram)"))
                {
                        run("memory_bram -rules +/ecp5/bram.txt");
                        run("techmap -map +/ecp5/brams_map.v");
                }
 
-               if (!nodram && check_label("dram", "(skip if -nodram)"))
+               if (!nolutram && check_label("map_lutram", "(skip if -nolutram)"))
                {
-                       run("memory_bram -rules +/ecp5/dram.txt");
-                       run("techmap -map +/ecp5/drams_map.v");
+                       run("memory_bram -rules +/ecp5/lutram.txt");
+                       run("techmap -map +/ecp5/lutrams_map.v");
                }
 
-               if (check_label("fine"))
+               if (check_label("map_ffram"))
                {
                        run("opt -fast -mux_undef -undriven -fine");
                        run("memory_map");
                        run("opt -undriven -fine");
+               }
+
+               if (check_label("map_gates"))
+               {
                        if (noccu2)
                                run("techmap");
                        else
@@ -296,6 +301,8 @@ struct SynthEcp5Pass : public ScriptPass
                        run("opt_expr -undriven -mux_undef");
                        run("simplemap");
                        run("ecp5_ffinit");
+                       run("ecp5_gsr");
+                       run("opt_clean");
                }
 
                if (check_label("map_luts"))
@@ -303,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");