Simplified FusionNotWorkingTestbench
[Mograsim.git] / net.mograsim.logic.core / src / net / mograsim / logic / core / types / Bit.java
index 707c5ad..da7b8c9 100644 (file)
@@ -18,6 +18,16 @@ public enum Bit implements StrictLogicType<Bit>
                this.symbol = symbol;
        }
 
+       /**
+        * Returns if the Bit is binary, this is only true for <code>ZERO</code> and <code>ONE</code>.
+        * 
+        * @return true if and only if <code>this == ONE || this == ZERO</code>
+        */
+       public boolean isBinary()
+       {
+               return this == ONE || this == ZERO;
+       }
+
        @Override
        public Bit and(Bit other)
        {
@@ -86,6 +96,11 @@ public enum Bit implements StrictLogicType<Bit>
                return values()[2 + (value & 1)];
        }
 
+       public static Bit of(boolean binaryValue)
+       {
+               return binaryValue ? ONE : ZERO;
+       }
+
        public static Bit parse(String s)
        {
                Bit bit = SYMBOL_MAP.get(s);