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.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
18 public class GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent
20 public GUIAm2910InstrPLA(ViewModelModifiable model, String name)
22 super(model, name, "Instr.\nPLA");
24 addPin(new Pin(this, "PASS", 1, 0, 5), Usage.INPUT, Position.RIGHT);
25 addPin(new Pin(this, "I3", 1, 0, 20), Usage.INPUT, Position.RIGHT);
26 addPin(new Pin(this, "I2", 1, 0, 30), Usage.INPUT, Position.RIGHT);
27 addPin(new Pin(this, "I1", 1, 0, 40), Usage.INPUT, Position.RIGHT);
28 addPin(new Pin(this, "I0", 1, 0, 50), Usage.INPUT, Position.RIGHT);
29 addPin(new Pin(this, "R=0", 1, 15, 0), Usage.INPUT, Position.BOTTOM);
30 addPin(new Pin(this, "_PL", 1, 5, 85), Usage.OUTPUT, Position.TOP);
31 addPin(new Pin(this, "_MAP", 1, 15, 85), Usage.OUTPUT, Position.TOP);
32 addPin(new Pin(this, "_VECT", 1, 25, 85), Usage.OUTPUT, Position.TOP);
33 addPin(new Pin(this, "RWE", 1, 30, 5), Usage.OUTPUT, Position.LEFT);
34 addPin(new Pin(this, "RDEC", 1, 30, 15), Usage.OUTPUT, Position.LEFT);
35 addPin(new Pin(this, "YD", 1, 30, 25), Usage.OUTPUT, Position.LEFT);
36 addPin(new Pin(this, "YR", 1, 30, 35), Usage.OUTPUT, Position.LEFT);
37 addPin(new Pin(this, "YF", 1, 30, 45), Usage.OUTPUT, Position.LEFT);
38 addPin(new Pin(this, "YmuPC", 1, 30, 55), Usage.OUTPUT, Position.LEFT);
39 addPin(new Pin(this, "STKI0", 1, 30, 65), Usage.OUTPUT, Position.LEFT);
40 addPin(new Pin(this, "STKI1", 1, 30, 75), Usage.OUTPUT, Position.LEFT);
44 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
46 ReadEnd PASS = readEnds.get("PASS");
47 ReadEnd I3 = readEnds.get("I3");
48 ReadEnd I2 = readEnds.get("I2");
49 ReadEnd I1 = readEnds.get("I1");
50 ReadEnd I0 = readEnds.get("I0");
51 ReadEnd Req0 = readEnds.get("R=0");
52 ReadWriteEnd _PL = readWriteEnds.get("_PL");
53 ReadWriteEnd _MAP = readWriteEnds.get("_MAP");
54 ReadWriteEnd _VECT = readWriteEnds.get("_VECT");
55 ReadWriteEnd RWE = readWriteEnds.get("RWE");
56 ReadWriteEnd RDEC = readWriteEnds.get("RDEC");
57 ReadWriteEnd YD = readWriteEnds.get("YD");
58 ReadWriteEnd YR = readWriteEnds.get("YR");
59 ReadWriteEnd YF = readWriteEnds.get("YF");
60 ReadWriteEnd YmuPC = readWriteEnds.get("YmuPC");
61 ReadWriteEnd STKI0 = readWriteEnds.get("STKI0");
62 ReadWriteEnd STKI1 = readWriteEnds.get("STKI1");
64 Bit PASSVal = PASS.getValue();
65 Bit I3Val = I3.getValue();
66 Bit I2Val = I2.getValue();
67 Bit I1Val = I1.getValue();
68 Bit I0Val = I0.getValue();
69 Bit Req0Val = Req0.getValue();
71 if (!I3Val.isBinary() || !I2Val.isBinary() || !I1Val.isBinary() || !I0Val.isBinary())
72 if ((I3Val == U || I3Val.isBinary()) || (I2Val == U || I2Val.isBinary()) || (I1Val == U || I1Val.isBinary())
73 || (I0Val == U || I0Val.isBinary()))
102 int I = (I3Val == ONE ? 8 : 0) + (I2Val == ONE ? 4 : 0) + (I1Val == ONE ? 2 : 0) + (I0Val == ONE ? 1 : 0);
112 _PL.feedSignals(_PLVal);
113 _MAP.feedSignals(_MAPVal);
114 _VECT.feedSignals(_VECTVal);
115 if (I == 8 || I == 9 || I == 15)
117 RWE.feedSignals(Req0Val);
118 RDEC.feedSignals(Req0Val);// "forward" X/U/Z
121 RWE.feedSignals(PASSVal);
122 RDEC.feedSignals(PASSVal == ONE ? ZERO : PASSVal);// "forward" X/U/Z
125 RWE.feedSignals(ZERO);
126 RDEC.feedSignals(ZERO);
128 if (!PASSVal.isBinary())
130 YD.feedSignals(PASSVal);// "forward" X/U/Z
131 YR.feedSignals(PASSVal);// "forward" X/U/Z
132 YF.feedSignals(PASSVal);// "forward" X/U/Z
133 YmuPC.feedSignals(PASSVal);// "forward" X/U/Z
140 switch (I + (PASSVal == ONE ? 16 : 0))
180 YFVal = Req0Val.not();// "forward" X/U/Z
181 YmuPCVal = Req0Val;// "forward" X/U/Z
185 YDVal = Req0Val.not();// "forward" X/U/Z
186 YmuPCVal = Req0Val;// "forward" X/U/Z
189 YFVal = Req0Val.not();// "forward" X/U/Z
190 YDVal = Req0Val;// "forward" X/U/Z
193 throw new IllegalStateException("shouldn't happen");
195 YD.feedSignals(YDVal);
196 YR.feedSignals(YRVal);
197 YF.feedSignals(YFVal);
198 YmuPC.feedSignals(YmuPCVal);
201 switch (I + (PASSVal == ONE ? 16 : 0))
251 STKI1Val = Req0Val;// "forward" X/U/Z
252 STKI0Val = Req0Val;// "forward" X/U/Z
255 throw new IllegalStateException("shouldn't happen");
257 STKI0.feedSignals(STKI0Val);
258 STKI1.feedSignals(STKI1Val);