X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Ftypes%2FBit.java;h=119ee53ae308d6faafb035d9175ff0f450ac30b0;hb=0ab3dafe756a69ff8b1e0137058caf2f5ac564aa;hp=8bff357a1cf02cd41e75b0b8f440765f0255e1b1;hpb=2f2269e36940705063adba3ff89ed7830c0b2edf;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 8bff357a..119ee53a 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; } + /** + * Returns if the Bit is binary, this is only true for ZERO and ONE. + * + * @return true if and only if this == ONE || this == ZERO + */ public boolean isBinary() { return this == ONE || this == ZERO; @@ -29,18 +34,36 @@ public enum Bit implements StrictLogicType return fromTable(AND_TABLE, this, other); } + public static void and(Bit[] dst, Bit[] src) + { + for (int i = 0; i < dst.length; i++) + dst[i] = dst[i].and(src[i]); + } + @Override public Bit or(Bit other) { return fromTable(OR_TABLE, this, other); } + public static void or(Bit[] dst, Bit[] src) + { + for (int i = 0; i < dst.length; i++) + dst[i] = dst[i].or(src[i]); + } + @Override public Bit xor(Bit other) { return fromTable(XOR_TABLE, this, other); } + public static void xor(Bit[] dst, Bit[] src) + { + for (int i = 0; i < dst.length; i++) + dst[i] = dst[i].xor(src[i]); + } + @Override public Bit not() { @@ -75,6 +98,12 @@ public enum Bit implements StrictLogicType return fromTable(JOIN_TABLE, this, other); } + public static void join(Bit[] dst, Bit[] src) + { + for (int i = 0; i < dst.length; i++) + dst[i] = dst[i].join(src[i]); + } + @Override public String toString() {