From: Christian Femers Date: Tue, 14 May 2019 12:20:23 +0000 (+0200) Subject: ajusted or() behaviour when Z is input X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=eb869bb3f59306fef2f9a028ea53a94b5f1bdd72;p=Mograsim.git ajusted or() behaviour when Z is input --- diff --git a/era.mi/src/era/mi/logic/Bit.java b/era.mi/src/era/mi/logic/Bit.java index 804ecc94..0e709852 100644 --- a/era.mi/src/era/mi/logic/Bit.java +++ b/era.mi/src/era/mi/logic/Bit.java @@ -13,12 +13,14 @@ public enum Bit public Bit and(Bit other) { - if (equals(Bit.ZERO) || other.equals(Bit.ZERO)) - return Bit.ZERO; - else if (equals(other) && equals(Bit.ONE)) - return Bit.ONE; + if (this == ZERO || other == ZERO) + return ZERO; + else if (this == other && this == ONE) + return ONE; + else if (this == X || other == X) + return X; else - return Bit.X; + return ZERO; } public static Bit or(Bit a, Bit b) @@ -28,12 +30,14 @@ public enum Bit public Bit or(Bit other) { - if (equals(Bit.ONE) || other.equals(Bit.ONE)) - return Bit.ONE; - else if (equals(other) && equals(Bit.ZERO)) - return Bit.ZERO; + if (this == ONE || other == ONE) + return ONE; + else if (this == other && this == ZERO) + return ZERO; + else if (this == X || other == X) + return X; else - return Bit.X; + return ZERO; } public static Bit xor(Bit a, Bit b) @@ -43,11 +47,10 @@ public enum Bit public Bit xor(Bit other) { - if(this == Bit.X || this == Bit.Z - || other == Bit.X || other == Bit.Z) + if(this == X || this == Z || other == X || other == Z) return Bit.X; else - return this == other ? Bit.ZERO : Bit.ONE; + return this == other ? ZERO : ONE; } public Bit not()