X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Ftypes%2FBit.java;h=8bff357a1cf02cd41e75b0b8f440765f0255e1b1;hb=2f2269e36940705063adba3ff89ed7830c0b2edf;hp=fbfd0d567bdf8960da4fdc94abebdd63eda94043;hpb=07faf07e3acb8b2afdc2bf65a46bc868faaed0f8;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java index fbfd0d56..8bff357a 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java @@ -18,6 +18,11 @@ public enum Bit implements StrictLogicType this.symbol = symbol; } + public boolean isBinary() + { + return this == ONE || this == ZERO; + } + @Override public Bit and(Bit other) { @@ -81,6 +86,16 @@ public enum Bit implements StrictLogicType return symbol; } + public static Bit lastBitOf(int value) + { + 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);