1 package net.mograsim.logic.model.am2900.components.am2910;
3 import static net.mograsim.logic.core.types.Bit.ONE;
4 import static net.mograsim.logic.core.types.Bit.U;
5 import static net.mograsim.logic.core.types.Bit.X;
6 import static net.mograsim.logic.core.types.Bit.ZERO;
10 import net.mograsim.logic.core.types.Bit;
11 import net.mograsim.logic.core.wires.Wire.ReadEnd;
12 import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
13 import net.mograsim.logic.model.model.ViewModelModifiable;
14 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
15 import net.mograsim.logic.model.model.wires.Pin;
16 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
17 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
19 public class GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent
21 public GUIAm2910InstrPLA(ViewModelModifiable model, String name)
23 super(model, name, "Instr.\nPLA");
25 addPin(new Pin(this, "PASS", 1, 0, 5), Usage.INPUT, Position.RIGHT);
26 addPin(new Pin(this, "I3", 1, 0, 20), Usage.INPUT, Position.RIGHT);
27 addPin(new Pin(this, "I2", 1, 0, 30), Usage.INPUT, Position.RIGHT);
28 addPin(new Pin(this, "I1", 1, 0, 40), Usage.INPUT, Position.RIGHT);
29 addPin(new Pin(this, "I0", 1, 0, 50), Usage.INPUT, Position.RIGHT);
30 addPin(new Pin(this, "R=0", 1, 15, 0), Usage.INPUT, Position.BOTTOM);
31 addPin(new Pin(this, "_PL", 1, 5, 85), Usage.OUTPUT, Position.TOP);
32 addPin(new Pin(this, "_MAP", 1, 15, 85), Usage.OUTPUT, Position.TOP);
33 addPin(new Pin(this, "_VECT", 1, 25, 85), Usage.OUTPUT, Position.TOP);
34 addPin(new Pin(this, "RWE", 1, 30, 5), Usage.OUTPUT, Position.LEFT);
35 addPin(new Pin(this, "RDEC", 1, 30, 15), Usage.OUTPUT, Position.LEFT);
36 addPin(new Pin(this, "YD", 1, 30, 25), Usage.OUTPUT, Position.LEFT);
37 addPin(new Pin(this, "YR", 1, 30, 35), Usage.OUTPUT, Position.LEFT);
38 addPin(new Pin(this, "YF", 1, 30, 45), Usage.OUTPUT, Position.LEFT);
39 addPin(new Pin(this, "YmuPC", 1, 30, 55), Usage.OUTPUT, Position.LEFT);
40 addPin(new Pin(this, "STKI0", 1, 30, 65), Usage.OUTPUT, Position.LEFT);
41 addPin(new Pin(this, "STKI1", 1, 30, 75), Usage.OUTPUT, Position.LEFT);
45 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
47 ReadEnd PASS = readEnds.get("PASS");
48 ReadEnd I3 = readEnds.get("I3");
49 ReadEnd I2 = readEnds.get("I2");
50 ReadEnd I1 = readEnds.get("I1");
51 ReadEnd I0 = readEnds.get("I0");
52 ReadEnd Req0 = readEnds.get("R=0");
53 ReadWriteEnd _PL = readWriteEnds.get("_PL");
54 ReadWriteEnd _MAP = readWriteEnds.get("_MAP");
55 ReadWriteEnd _VECT = readWriteEnds.get("_VECT");
56 ReadWriteEnd RWE = readWriteEnds.get("RWE");
57 ReadWriteEnd RDEC = readWriteEnds.get("RDEC");
58 ReadWriteEnd YD = readWriteEnds.get("YD");
59 ReadWriteEnd YR = readWriteEnds.get("YR");
60 ReadWriteEnd YF = readWriteEnds.get("YF");
61 ReadWriteEnd YmuPC = readWriteEnds.get("YmuPC");
62 ReadWriteEnd STKI0 = readWriteEnds.get("STKI0");
63 ReadWriteEnd STKI1 = readWriteEnds.get("STKI1");
65 Bit PASSVal = PASS.getValue();
66 Bit I3Val = I3.getValue();
67 Bit I2Val = I2.getValue();
68 Bit I1Val = I1.getValue();
69 Bit I0Val = I0.getValue();
70 Bit Req0Val = Req0.getValue();
72 if (!I3Val.isBinary() || !I2Val.isBinary() || !I1Val.isBinary() || !I0Val.isBinary())
73 if ((I3Val == U || I3Val.isBinary()) || (I2Val == U || I2Val.isBinary()) || (I1Val == U || I1Val.isBinary())
74 || (I0Val == U || I0Val.isBinary()))
103 int I = (I3Val == ONE ? 8 : 0) + (I2Val == ONE ? 4 : 0) + (I1Val == ONE ? 2 : 0) + (I0Val == ONE ? 1 : 0);
113 _PL.feedSignals(_PLVal);
114 _MAP.feedSignals(_MAPVal);
115 _VECT.feedSignals(_VECTVal);
116 if (I == 8 || I == 9 || I == 15)
118 RWE.feedSignals(Req0Val);
119 RDEC.feedSignals(Req0Val);// "forward" X/U/Z
122 RWE.feedSignals(PASSVal);
123 RDEC.feedSignals(PASSVal == ONE ? ZERO : PASSVal);// "forward" X/U/Z
126 RWE.feedSignals(ZERO);
127 RDEC.feedSignals(ZERO);
129 if (!PASSVal.isBinary())
131 YD.feedSignals(PASSVal);// "forward" X/U/Z
132 YR.feedSignals(PASSVal);// "forward" X/U/Z
133 YF.feedSignals(PASSVal);// "forward" X/U/Z
134 YmuPC.feedSignals(PASSVal);// "forward" X/U/Z
141 switch (I + (PASSVal == ONE ? 16 : 0))
181 YFVal = Req0Val.not();// "forward" X/U/Z
182 YmuPCVal = Req0Val;// "forward" X/U/Z
186 YDVal = Req0Val.not();// "forward" X/U/Z
187 YmuPCVal = Req0Val;// "forward" X/U/Z
190 YFVal = Req0Val.not();// "forward" X/U/Z
191 YDVal = Req0Val;// "forward" X/U/Z
194 throw new IllegalStateException("shouldn't happen");
196 YD.feedSignals(YDVal);
197 YR.feedSignals(YRVal);
198 YF.feedSignals(YFVal);
199 YmuPC.feedSignals(YmuPCVal);
202 switch (I + (PASSVal == ONE ? 16 : 0))
252 STKI1Val = Req0Val;// "forward" X/U/Z
253 STKI0Val = Req0Val;// "forward" X/U/Z
256 throw new IllegalStateException("shouldn't happen");
258 STKI0.feedSignals(STKI0Val);
259 STKI1.feedSignals(STKI1Val);
267 IndirectGUIComponentCreator.setComponentSupplier(GUIAm2910InstrPLA.class.getCanonicalName(),
268 (m, p, n) -> new GUIAm2910InstrPLA(m, n));