X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Fcomponents%2FGUIinc12.java;h=c3848d43122d816835b728b6a6b6b2a4c22b9f3f;hb=bfd483ea32de08383550ba6903f77c11c33ea36d;hp=0b94583c2be5e4f42b3afc0566c55198a05a535b;hpb=c9cca272f312bdea6cf661e861508fca2431a9d2;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java index 0b94583c..c3848d43 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java @@ -1,6 +1,5 @@ package net.mograsim.logic.model.am2900.components; -import static net.mograsim.logic.core.types.Bit.ONE; import static net.mograsim.logic.core.types.Bit.U; import static net.mograsim.logic.core.types.Bit.X; import static net.mograsim.logic.core.types.Bit.Z; @@ -15,6 +14,7 @@ import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent; import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.model.wires.PinUsage; import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position; @@ -24,13 +24,13 @@ public class GUIinc12 extends SimpleRectangularHardcodedGUIComponent { super(model, name, "Incrementer"); setSize(40, 20); - addPin(new Pin(this, "A", 12, 20, 20), Usage.INPUT, Position.TOP); - addPin(new Pin(this, "CI", 1, 40, 10), Usage.INPUT, Position.LEFT); - addPin(new Pin(this, "Y", 12, 20, 0), Usage.OUTPUT, Position.BOTTOM); + addPin(new Pin(this, "A", 12, PinUsage.INPUT, 20, 20), Position.TOP); + addPin(new Pin(this, "CI", 1, PinUsage.INPUT, 40, 10), Position.LEFT); + addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM); } @Override - protected Object recalculate(Object lastState, Map readEnds, Map readWriteEnds) + public Object recalculate(Object lastState, Map readEnds, Map readWriteEnds) { Bit[] ABits = readEnds.get("A").getValues().getBits(); Bit CIVal = readEnds.get("CI").getValue(); @@ -47,23 +47,11 @@ public class GUIinc12 extends SimpleRectangularHardcodedGUIComponent { Bit carry = Bit.ONE; // TODO extract to helper. This code almost also exists in GUIAM2910RegCntr. - // TODO maybe invert loop direction for (int i = 11; i >= 0; i--) { Bit a = ABits[i]; - Bit z; - if (a.isBinary() && carry.isBinary()) - { - boolean aBool = a == ONE; - boolean carryBool = carry == ONE; - z = aBool ^ carryBool ? ONE : ZERO; - carry = aBool && carryBool ? ONE : ZERO; - } else - { - carry = carry.join(a); - z = carry; - } - YBits[i] = z; + YBits[i] = a.xor(carry); + carry = a.and(carry); } } readWriteEnds.get("Y").feedSignals(YBits);