wreduce: Introduce -mux_undef option (aligned with opt_expr).
authorMarcelina Kościelnicka <mwk@0x04.net>
Wed, 8 Jun 2022 18:32:04 +0000 (20:32 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Wed, 8 Jun 2022 19:28:58 +0000 (21:28 +0200)
passes/opt/wreduce.cc

index aaad28ef0ab3881ef5b132d1aad9f92659a2b779..08ab6de6f560ceb7f05fd5e14a477c572cb845cf 100644 (file)
@@ -30,6 +30,7 @@ struct WreduceConfig
 {
        pool<IdString> supported_cell_types;
        bool keepdc = false;
+       bool mux_undef = false;
 
        WreduceConfig()
        {
@@ -83,7 +84,7 @@ struct WreduceWorker
 
                        SigBit ref = sig_a[i];
                        for (int k = 0; k < GetSize(sig_s); k++) {
-                               if ((config->keepdc || (ref != State::Sx && sig_b[k*GetSize(sig_a) + i] != State::Sx)) && ref != sig_b[k*GetSize(sig_a) + i])
+                               if ((config->keepdc || !config->mux_undef || (ref != State::Sx && sig_b[k*GetSize(sig_a) + i] != State::Sx)) && ref != sig_b[k*GetSize(sig_a) + i])
                                        goto no_match_ab;
                                if (sig_b[k*GetSize(sig_a) + i] != State::Sx)
                                        ref = sig_b[k*GetSize(sig_a) + i];
@@ -479,6 +480,9 @@ struct WreducePass : public Pass {
                log("        Do not change the width of memory address ports. Use this options in\n");
                log("        flows that use the 'memory_memx' pass.\n");
                log("\n");
+               log("    -mux_undef\n");
+               log("        remove 'undef' inputs from $mux, $pmux and $_MUX_ cells\n");
+               log("\n");
                log("    -keepdc\n");
                log("        Do not optimize explicit don't-care values.\n");
                log("\n");
@@ -500,6 +504,10 @@ struct WreducePass : public Pass {
                                config.keepdc = true;
                                continue;
                        }
+                       if (args[argidx] == "-mux_undef") {
+                               config.mux_undef = true;
+                               continue;
+                       }
                        break;
                }
                extra_args(args, argidx, design);