X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Fcomponents%2Fam2910%2FGUIAm2910InstrPLA.java;h=9dd05b9f5b0769b39d8b47911149c84a276f83ba;hb=662eb9515b9fcbccc4997f50fecfb597ee8eb316;hp=2e2e0d386a1c52860b35bcbcd2a2d04210a07348;hpb=e3d7905ec00f7515817ab9921724fd0eb51f79e7;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java index 2e2e0d38..9dd05b9f 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java @@ -1,86 +1,258 @@ package net.mograsim.logic.model.am2900.components.am2910; -import net.haspamelodica.swt.helper.gcs.GeneralGC; -import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; +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.ZERO; + +import java.util.Map; + +import net.mograsim.logic.core.types.Bit; +import net.mograsim.logic.core.wires.Wire.ReadEnd; +import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; import net.mograsim.logic.model.model.ViewModelModifiable; -import net.mograsim.logic.model.model.components.GUIComponent; +import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent; import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter; -import net.mograsim.logic.model.modeladapter.componentadapters.Am2910InstrPLAAdapter; -import net.mograsim.logic.model.snippets.Renderer; -import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer; -import net.mograsim.logic.model.snippets.symbolrenderers.CenteredTextSymbolRenderer; -import net.mograsim.logic.model.snippets.symbolrenderers.CenteredTextSymbolRenderer.CenteredTextParams; -import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer; -import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams; import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position; -public class GUIAm2910InstrPLA extends GUIComponent +public class GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent { - private final Renderer renderer1; - private final Renderer renderer2; - private final Renderer renderer3; - public GUIAm2910InstrPLA(ViewModelModifiable model, String name) { - super(model, name); + super(model, name, "Instr.\nPLA"); setSize(30, 85); - addPin(new Pin(this, "PASS", 1, 0, 5)); - addPin(new Pin(this, "I3", 1, 0, 20)); - addPin(new Pin(this, "I2", 1, 0, 30)); - addPin(new Pin(this, "I1", 1, 0, 40)); - addPin(new Pin(this, "I0", 1, 0, 50)); - addPin(new Pin(this, "R=0", 1, 15, 0)); - addPin(new Pin(this, "_PL", 1, 5, 85)); - addPin(new Pin(this, "_MAP", 1, 15, 85)); - addPin(new Pin(this, "_VECT", 1, 25, 85)); - addPin(new Pin(this, "RWE", 1, 30, 5)); - addPin(new Pin(this, "RDEC", 1, 30, 15)); - addPin(new Pin(this, "YD", 1, 30, 25)); - addPin(new Pin(this, "YR", 1, 30, 35)); - addPin(new Pin(this, "YF", 1, 30, 45)); - addPin(new Pin(this, "YmuPC", 1, 30, 55)); - addPin(new Pin(this, "STKI0", 1, 30, 65)); - addPin(new Pin(this, "STKI1", 1, 30, 75)); - this.renderer1 = new DefaultOutlineRenderer(this); - CenteredTextParams renderer2Params = new CenteredTextParams(); - renderer2Params.text = "Instr.\nPLA"; - renderer2Params.fontHeight = 5; - this.renderer2 = new CenteredTextSymbolRenderer(this, renderer2Params); - PinNamesParams renderer3Params = new PinNamesParams(); - renderer3Params.pinLabelHeight = 3.5; - renderer3Params.pinLabelMargin = .5; - PinNamesSymbolRenderer pinNamesRenderer; - this.renderer3 = pinNamesRenderer = new PinNamesSymbolRenderer(this, renderer3Params); - pinNamesRenderer.setPinPosition("PASS", Position.RIGHT); - pinNamesRenderer.setPinPosition("I3", Position.RIGHT); - pinNamesRenderer.setPinPosition("I2", Position.RIGHT); - pinNamesRenderer.setPinPosition("I1", Position.RIGHT); - pinNamesRenderer.setPinPosition("I0", Position.RIGHT); - pinNamesRenderer.setPinPosition("R=0", Position.BOTTOM); - pinNamesRenderer.setPinPosition("_PL", Position.TOP); - pinNamesRenderer.setPinPosition("_MAP", Position.TOP); - pinNamesRenderer.setPinPosition("_VECT", Position.TOP); - pinNamesRenderer.setPinPosition("RWE", Position.LEFT); - pinNamesRenderer.setPinPosition("RDEC", Position.LEFT); - pinNamesRenderer.setPinPosition("YD", Position.LEFT); - pinNamesRenderer.setPinPosition("YR", Position.LEFT); - pinNamesRenderer.setPinPosition("YF", Position.LEFT); - pinNamesRenderer.setPinPosition("YmuPC", Position.LEFT); - pinNamesRenderer.setPinPosition("STKI0", Position.LEFT); - pinNamesRenderer.setPinPosition("STKI1", Position.LEFT); + addPin(new Pin(this, "PASS", 1, 0, 5), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "I3", 1, 0, 20), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "I2", 1, 0, 30), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "I1", 1, 0, 40), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "I0", 1, 0, 50), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "R=0", 1, 15, 0), Usage.INPUT, Position.BOTTOM); + addPin(new Pin(this, "_PL", 1, 5, 85), Usage.OUTPUT, Position.TOP); + addPin(new Pin(this, "_MAP", 1, 15, 85), Usage.OUTPUT, Position.TOP); + addPin(new Pin(this, "_VECT", 1, 25, 85), Usage.OUTPUT, Position.TOP); + addPin(new Pin(this, "RWE", 1, 30, 5), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "RDEC", 1, 30, 15), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "YD", 1, 30, 25), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "YR", 1, 30, 35), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "YF", 1, 30, 45), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "YmuPC", 1, 30, 55), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "STKI0", 1, 30, 65), Usage.OUTPUT, Position.LEFT); + addPin(new Pin(this, "STKI1", 1, 30, 75), Usage.OUTPUT, Position.LEFT); } @Override - public void render(GeneralGC gc, Rectangle visibleRegion) + protected void recalculate(Map readEnds, Map readWriteEnds) { - renderer1.render(gc, visibleRegion); - renderer2.render(gc, visibleRegion); - renderer3.render(gc, visibleRegion); - } + ReadEnd PASS = readEnds.get("PASS"); + ReadEnd I3 = readEnds.get("I3"); + ReadEnd I2 = readEnds.get("I2"); + ReadEnd I1 = readEnds.get("I1"); + ReadEnd I0 = readEnds.get("I0"); + ReadEnd Req0 = readEnds.get("R=0"); + ReadWriteEnd _PL = readWriteEnds.get("_PL"); + ReadWriteEnd _MAP = readWriteEnds.get("_MAP"); + ReadWriteEnd _VECT = readWriteEnds.get("_VECT"); + ReadWriteEnd RWE = readWriteEnds.get("RWE"); + ReadWriteEnd RDEC = readWriteEnds.get("RDEC"); + ReadWriteEnd YD = readWriteEnds.get("YD"); + ReadWriteEnd YR = readWriteEnds.get("YR"); + ReadWriteEnd YF = readWriteEnds.get("YF"); + ReadWriteEnd YmuPC = readWriteEnds.get("YmuPC"); + ReadWriteEnd STKI0 = readWriteEnds.get("STKI0"); + ReadWriteEnd STKI1 = readWriteEnds.get("STKI1"); - static - { - ViewLogicModelAdapter.addComponentAdapter(new Am2910InstrPLAAdapter()); + Bit PASSVal = PASS.getValue(); + Bit I3Val = I3.getValue(); + Bit I2Val = I2.getValue(); + Bit I1Val = I1.getValue(); + Bit I0Val = I0.getValue(); + Bit Req0Val = Req0.getValue(); + + if (!I3Val.isBinary() || !I2Val.isBinary() || !I1Val.isBinary() || !I0Val.isBinary()) + if ((I3Val == U || I3Val.isBinary()) || (I2Val == U || I2Val.isBinary()) || (I1Val == U || I1Val.isBinary()) + || (I0Val == U || I0Val.isBinary())) + { + _PL.feedSignals(U); + _MAP.feedSignals(U); + _VECT.feedSignals(U); + RWE.feedSignals(U); + RDEC.feedSignals(U); + YD.feedSignals(U); + YR.feedSignals(U); + YF.feedSignals(U); + YmuPC.feedSignals(U); + STKI0.feedSignals(U); + STKI1.feedSignals(U); + } else + { + _PL.feedSignals(X); + _MAP.feedSignals(X); + _VECT.feedSignals(X); + RWE.feedSignals(X); + RDEC.feedSignals(X); + YD.feedSignals(X); + YR.feedSignals(X); + YF.feedSignals(X); + YmuPC.feedSignals(X); + STKI0.feedSignals(X); + STKI1.feedSignals(X); + } + else + { + int I = (I3Val == ONE ? 8 : 0) + (I2Val == ONE ? 4 : 0) + (I1Val == ONE ? 2 : 0) + (I0Val == ONE ? 1 : 0); + Bit _PLVal = ONE; + Bit _MAPVal = ONE; + Bit _VECTVal = ONE; + if (I == 2) + _MAPVal = ZERO; + else if (I == 6) + _VECTVal = ZERO; + else + _PLVal = ZERO; + _PL.feedSignals(_PLVal); + _MAP.feedSignals(_MAPVal); + _VECT.feedSignals(_VECTVal); + if (I == 8 || I == 9 || I == 15) + { + RWE.feedSignals(Req0Val); + RDEC.feedSignals(Req0Val);// "forward" X/U/Z + } else if (I == 4) + { + RWE.feedSignals(PASSVal); + RDEC.feedSignals(PASSVal == ONE ? ZERO : PASSVal);// "forward" X/U/Z + } else + { + RWE.feedSignals(ZERO); + RDEC.feedSignals(ZERO); + } + if (!PASSVal.isBinary()) + { + YD.feedSignals(PASSVal);// "forward" X/U/Z + YR.feedSignals(PASSVal);// "forward" X/U/Z + YF.feedSignals(PASSVal);// "forward" X/U/Z + YmuPC.feedSignals(PASSVal);// "forward" X/U/Z + } else + { + Bit YDVal = ZERO; + Bit YRVal = ZERO; + Bit YFVal = ZERO; + Bit YmuPCVal = ZERO; + switch (I + (PASSVal == ONE ? 16 : 0)) + { + case 0: + case 0 + 16: + break; + case 2: + case 1 + 16: + case 2 + 16: + case 3 + 16: + case 5 + 16: + case 6 + 16: + case 7 + 16: + case 11 + 16: + YDVal = ONE; + break; + case 5: + case 7: + YRVal = ONE; + break; + case 13: + case 10 + 16: + YFVal = ONE; + break; + case 1: + case 3: + case 4: + case 6: + case 10: + case 11: + case 12: + case 14: + case 4 + 16: + case 12 + 16: + case 13 + 16: + case 14 + 16: + case 15 + 16: + YmuPCVal = ONE; + break; + case 8: + case 8 + 16: + YFVal = Req0Val.not();// "forward" X/U/Z + YmuPCVal = Req0Val;// "forward" X/U/Z + break; + case 9: + case 9 + 16: + YDVal = Req0Val.not();// "forward" X/U/Z + YmuPCVal = Req0Val;// "forward" X/U/Z + break; + case 15: + YFVal = Req0Val.not();// "forward" X/U/Z + YDVal = Req0Val;// "forward" X/U/Z + break; + default: + throw new IllegalStateException("shouldn't happen"); + } + YD.feedSignals(YDVal); + YR.feedSignals(YRVal); + YF.feedSignals(YFVal); + YmuPC.feedSignals(YmuPCVal); + Bit STKI0Val; + Bit STKI1Val; + switch (I + (PASSVal == ONE ? 16 : 0)) + { + case 1: + case 2: + case 3: + case 6: + case 7: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 2 + 16: + case 3 + 16: + case 6 + 16: + case 7 + 16: + case 9 + 16: + case 12 + 16: + case 14 + 16: + STKI1Val = ZERO; + STKI0Val = ZERO; + break; + case 4: + case 5: + case 1 + 16: + case 4 + 16: + case 5 + 16: + STKI1Val = ZERO; + STKI0Val = ONE; + break; + case 0: + case 0 + 16: + STKI1Val = ONE; + STKI0Val = ZERO; + break; + case 10 + 16: + case 11 + 16: + case 13 + 16: + case 15 + 16: + STKI1Val = ONE; + STKI0Val = ONE; + break; + case 8: + case 15: + case 8 + 16: + STKI1Val = Req0Val;// "forward" X/U/Z + STKI0Val = Req0Val;// "forward" X/U/Z + break; + default: + throw new IllegalStateException("shouldn't happen"); + } + STKI0.feedSignals(STKI0Val); + STKI1.feedSignals(STKI1Val); + } + } } } \ No newline at end of file