Add "pmux2shiftx -norange", fixes #1135
authorClifford Wolf <clifford@clifford.at>
Thu, 27 Jun 2019 08:59:12 +0000 (10:59 +0200)
committerClifford Wolf <clifford@clifford.at>
Thu, 27 Jun 2019 08:59:12 +0000 (10:59 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
CHANGELOG
passes/opt/pmux2shiftx.cc

index 8c88a7db8f53954ba094263effe83ec9bdb904ad..b8e53b4cf7d665cf6e71894a7270a328961e6758 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@ Yosys 0.8 .. Yosys 0.8-dev
     - Added "muxcover -dmux=<cost>"
     - Added "muxcover -nopartial"
     - Added "muxpack" pass
+    - Added "pmux2shiftx -norange"
     - "synth_xilinx" to now infer hard shift registers, using new "shregmap -tech xilinx"
     - Fixed sign extension of unsized constants with 'bx and 'bz MSB
 
index 29870f510fa3fcfdf7102304a94fa1c46764ebe1..65d8b8f324d8e507769548431f81cb3a56dc80b5 100644 (file)
@@ -221,6 +221,9 @@ struct Pmux2ShiftxPass : public Pass {
                log("        select strategy for one-hot encoded control signals\n");
                log("        default: pmux\n");
                log("\n");
+               log("    -norange\n");
+               log("        disable $sub inference for \"range decoders\"\n");
+               log("\n");
        }
        void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
        {
@@ -230,6 +233,7 @@ struct Pmux2ShiftxPass : public Pass {
                bool optimize_onehot = true;
                bool verbose = false;
                bool verbose_onehot = false;
+               bool norange = false;
 
                log_header(design, "Executing PMUX2SHIFTX pass.\n");
 
@@ -270,6 +274,10 @@ struct Pmux2ShiftxPass : public Pass {
                                verbose_onehot = true;
                                continue;
                        }
+                       if (args[argidx] == "-norange") {
+                               norange = true;
+                               continue;
+                       }
                        break;
                }
                extra_args(args, argidx, design);
@@ -559,7 +567,7 @@ struct Pmux2ShiftxPass : public Pass {
                                                                int this_inv_delta = this_maxval - this_minval;
                                                                bool this_inv = false;
 
-                                                               if (this_delta != this_inv_delta)
+                                                               if (!norange && this_delta != this_inv_delta)
                                                                        this_inv = this_inv_delta < this_delta;
                                                                else if (this_maxval != this_inv_maxval)
                                                                        this_inv = this_inv_maxval < this_maxval;
@@ -574,7 +582,7 @@ struct Pmux2ShiftxPass : public Pass {
 
                                                                if (best_src_col < 0)
                                                                        this_is_better = true;
-                                                               else if (this_delta != best_delta)
+                                                               else if (!norange && this_delta != best_delta)
                                                                        this_is_better = this_delta < best_delta;
                                                                else if (this_maxval != best_maxval)
                                                                        this_is_better = this_maxval < best_maxval;
@@ -656,7 +664,7 @@ struct Pmux2ShiftxPass : public Pass {
 
                                        // check density percentages
                                        Const offset(State::S0, GetSize(sig));
-                                       if (absolute_density < min_density && range_density >= min_density)
+                                       if (!norange && absolute_density < min_density && range_density >= min_density)
                                        {
                                                offset = Const(min_choice, GetSize(sig));
                                                log("    offset: %s\n", log_signal(offset));