Add more muxpack tests, with overlapping entries
authorEddie Hung <eddie@fpgeh.com>
Fri, 21 Jun 2019 18:45:53 +0000 (11:45 -0700)
committerEddie Hung <eddie@fpgeh.com>
Fri, 21 Jun 2019 18:45:53 +0000 (11:45 -0700)
tests/various/muxpack.v
tests/various/muxpack.ys

index 3a1086dbf8b21b3fc6e1bd33f03f9f3ab1767a14..7a658d7540d646068e8b6cdb8f54cf4a9d481cf1 100644 (file)
@@ -187,7 +187,9 @@ module case_nonexclusive_select (
 );
         always @* begin
             case (x)
-                0, 2: o = b;
+                //0, 2: o = b;
+                0: o = b;
+                2: o = b;
                 1: o = c;
                 default: begin
                     o = a;
@@ -197,3 +199,54 @@ module case_nonexclusive_select (
         endcase
         end
 endmodule
+
+module case_nonoverlap (
+        input wire [2:0] x,
+        input wire a, b, c, d, e, f, g,
+        output reg o
+);
+        always @* begin
+            case (x)
+                //0, 2: o = b; // Creates $reduce_or
+                //0: o = b; 2: o = b; // Creates $reduce_or
+                0: o = b;
+                2: o = f;
+                1: o = c;
+                default:
+                    case (x)
+                        //3, 4: o = d; // Creates $reduce_or
+                        //3: o = d; 4: o = d; // Creates $reduce_or
+                        3: o = d;
+                        4: o = g;
+                        5: o = e;
+                        default: o = 1'b0;
+                    endcase
+        endcase
+        end
+endmodule
+
+module case_overlap (
+        input wire [2:0] x,
+        input wire a, b, c, d, e, f, g,
+        output reg o
+);
+        always @* begin
+            case (x)
+                //0, 2: o = b; // Creates $reduce_or
+                //0: o = b; 2: o = b; // Creates $reduce_or
+                0: o = b;
+                2: o = f;
+                1: o = c;
+                default:
+                    case (x)
+                        //3, 4: o = d; // Creates $reduce_or
+                        //3: o = d; 4: o = d; // Creates $reduce_or
+                        2: o = 1'b1; // Overlaps with previous $pmux
+                        3: o = d;
+                        4: o = g;
+                        5: o = e;
+                        default: o = 1'b0;
+                    endcase
+        endcase
+        end
+endmodule
index 579dad8d37c9c83d2c755ebb888d38d71d6d3434..ef8a6dab98edd30a4da8a09b2a7b414f150e75d7 100644 (file)
@@ -212,3 +212,33 @@ design -import gold -as gold
 design -import gate -as gate
 miter -equiv -flatten -make_assert -make_outputs gold gate miter
 sat -verify -prove-asserts -show-ports miter
+
+design -load read
+hierarchy -top case_nonoverlap
+prep
+design -save gold
+muxpack
+opt
+stat
+select -assert-count 0 t:$mux
+select -assert-count 1 t:$pmux
+design -stash gate
+design -import gold -as gold
+design -import gate -as gate
+miter -equiv -flatten -make_assert -make_outputs gold gate miter
+sat -verify -prove-asserts -show-ports miter
+
+design -load read
+hierarchy -top case_overlap
+prep
+design -save gold
+muxpack
+#opt # Do not opt otherwise $pmux's overlapping entry will get removed
+stat
+select -assert-count 0 t:$mux
+select -assert-count 1 t:$pmux
+design -stash gate
+design -import gold -as gold
+design -import gate -as gate
+miter -equiv -flatten -make_assert -make_outputs gold gate miter
+sat -verify -prove-asserts -show-ports miter