Improved $_MUX_ handling in opt_const
authorClifford Wolf <clifford@clifford.at>
Sat, 28 Dec 2013 09:30:31 +0000 (10:30 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 28 Dec 2013 09:30:31 +0000 (10:30 +0100)
passes/opt/opt_const.cc

index 84285567e229b75fc8a5c04c8ffcd173f5acff21..0ead97b4e3599e4a20d7ab6143a7ff44f97b363a 100644 (file)
@@ -17,8 +17,6 @@
  *
  */
 
-#undef MUX_UNDEF_SEL_TO_UNDEF_RESULTS
-
 #include "opt_status.h"
 #include "kernel/register.h"
 #include "kernel/sigtools.h"
@@ -133,15 +131,16 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
                                ACTION_DO("\\Y", input.extract(2, 1));
                        if (input.match("  0")) ACTION_DO("\\Y", input.extract(2, 1));
                        if (input.match("  1")) ACTION_DO("\\Y", input.extract(1, 1));
-#ifdef MUX_UNDEF_SEL_TO_UNDEF_RESULTS
                        if (input.match("01 ")) ACTION_DO("\\Y", input.extract(0, 1));
-                       // TODO: "10 " -> replace with "!S" gate
-                       // TODO: "0  " -> replace with "B AND S" gate
-                       // TODO: " 1 " -> replace with "A OR S" gate
-                       // TODO: "1  " -> replace with "B OR !S" gate (?)
-                       // TODO: " 0 " -> replace with "A AND !S" gate (?)
-                       if (input.match("  *")) ACTION_DO_Y(x);
-#endif
+                       if (input.match("10 ")) {
+                               cell->type = "$_INV_";
+                               cell->connections["\\A"] = input.extract(0, 1);
+                               cell->connections.erase("\\B");
+                               cell->connections.erase("\\S");
+                               goto next_cell;
+                       }
+                       if (input.match("01*")) ACTION_DO_Y(x);
+                       if (input.match("10*")) ACTION_DO_Y(x);
                }
 
                if (cell->type == "$eq" || cell->type == "$ne" || cell->type == "$eqx" || cell->type == "$nex")