X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Fcomponents%2Fam2910%2FGUIAm2910RegCntr.java;h=baf456a8ba2be4d414fb6dd06edc876292a76195;hb=8fb54d22443ae9eb2990d652995279d901467a0a;hp=ec900c0846bbc41c78b7cbb67af634b61167a9b5;hpb=755dd287af38d41b225e5976466111bc69249edb;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java index ec900c08..baf456a8 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java @@ -13,6 +13,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.serializing.IndirectGUIComponentCreator; import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position; public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent @@ -23,8 +24,8 @@ public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent setSize(40, 40); addPin(new Pin(this, "D", 12, 20, 0), Usage.INPUT, Position.BOTTOM); addPin(new Pin(this, "_RLD", 1, 0, 5), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "RWE", 1, 0, 20), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "RDEC", 1, 0, 30), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "WE", 1, 0, 20), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "DEC", 1, 0, 30), Usage.INPUT, Position.RIGHT); addPin(new Pin(this, "C", 1, 40, 20), Usage.INPUT, Position.LEFT); addPin(new Pin(this, "Y", 12, 20, 40), Usage.OUTPUT, Position.TOP); } @@ -41,21 +42,25 @@ public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent ReadEnd D = readEnds.get("D"); ReadEnd _RLD = readEnds.get("_RLD"); - ReadEnd RWE = readEnds.get("RWE"); - ReadEnd RDEC = readEnds.get("RDEC"); + ReadEnd WE = readEnds.get("WE"); + ReadEnd DEC = readEnds.get("DEC"); ReadEnd C = readEnds.get("C"); ReadWriteEnd Y = readWriteEnds.get("Y"); Bit oldCVal = QC[12]; Bit CVal = C.getValue(); - if (oldCVal == ZERO && CVal == ONE && _RLD.getValue() == ZERO && RWE.getValue() == ONE) + // TODO handle U/X/Z + if (oldCVal == ZERO && CVal == ONE) { - if (RDEC.getValue() == ONE) + if ((DEC.getValue() == ZERO && WE.getValue() == ONE) || _RLD.getValue() == ZERO) + System.arraycopy(D.getValues().getBits(), 0, QC, 0, 12); + else if (WE.getValue() == ONE) { Bit carry = Bit.ZERO; + // TODO extract to helper. This code almost also exists in GUIinc12. // TODO maybe invert loop direction - for (int i = 12; i >= 0; i--) + for (int i = 11; i >= 0; i--) { Bit a = QC[i]; Bit z; @@ -72,12 +77,17 @@ public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent } QC[i] = z; } - } else - System.arraycopy(D.getValues().getBits(), 0, QC, 0, 12); + } } QC[12] = CVal; Y.feedSignals(Arrays.copyOfRange(QC, 0, 12)); return QC; } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIAm2910RegCntr.class.getCanonicalName(), + (m, p, n) -> new GUIAm2910RegCntr(m, n)); + } } \ No newline at end of file