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.CoreWire.ReadEnd;
12 import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
13 import net.mograsim.logic.model.model.LogicModelModifiable;
14 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedModelComponent;
15 import net.mograsim.logic.model.model.wires.Pin;
16 import net.mograsim.logic.model.model.wires.PinUsage;
17 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
18 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
20 public class ModelAm2910InstrPLA extends SimpleRectangularHardcodedModelComponent
22 public ModelAm2910InstrPLA(LogicModelModifiable model, String name)
24 super(model, "Am2910InstrPLA", name, "Instr.\nPLA", false);
26 addPin(new Pin(model, this, "PASS", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
27 addPin(new Pin(model, this, "I", 4, PinUsage.INPUT, 0, 20), Position.RIGHT);
28 addPin(new Pin(model, this, "R=0", 1, PinUsage.INPUT, 15, 0), Position.BOTTOM);
29 addPin(new Pin(model, this, "_PL", 1, PinUsage.OUTPUT, 5, 85), Position.TOP);
30 addPin(new Pin(model, this, "_MAP", 1, PinUsage.OUTPUT, 15, 85), Position.TOP);
31 addPin(new Pin(model, this, "_VECT", 1, PinUsage.OUTPUT, 25, 85), Position.TOP);
32 addPin(new Pin(model, this, "RLD", 1, PinUsage.OUTPUT, 30, 5), Position.LEFT);
33 addPin(new Pin(model, this, "RDEC", 1, PinUsage.OUTPUT, 30, 15), Position.LEFT);
34 addPin(new Pin(model, this, "YD", 1, PinUsage.OUTPUT, 30, 25), Position.LEFT);
35 addPin(new Pin(model, this, "YR", 1, PinUsage.OUTPUT, 30, 35), Position.LEFT);
36 addPin(new Pin(model, this, "YF", 1, PinUsage.OUTPUT, 30, 45), Position.LEFT);
37 addPin(new Pin(model, this, "YmuPC", 1, PinUsage.OUTPUT, 30, 55), Position.LEFT);
38 addPin(new Pin(model, this, "STKI0", 1, PinUsage.OUTPUT, 30, 65), Position.LEFT);
39 addPin(new Pin(model, this, "STKI1", 1, PinUsage.OUTPUT, 30, 75), Position.LEFT);
45 public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
47 ReadEnd PASS = readEnds.get("PASS");
48 ReadEnd I = readEnds.get("I");
49 ReadEnd Req0 = readEnds.get("R=0");
50 ReadWriteEnd _PL = readWriteEnds.get("_PL");
51 ReadWriteEnd _MAP = readWriteEnds.get("_MAP");
52 ReadWriteEnd _VECT = readWriteEnds.get("_VECT");
53 ReadWriteEnd RLD = readWriteEnds.get("RLD");
54 ReadWriteEnd RDEC = readWriteEnds.get("RDEC");
55 ReadWriteEnd YD = readWriteEnds.get("YD");
56 ReadWriteEnd YR = readWriteEnds.get("YR");
57 ReadWriteEnd YF = readWriteEnds.get("YF");
58 ReadWriteEnd YmuPC = readWriteEnds.get("YmuPC");
59 ReadWriteEnd STKI0 = readWriteEnds.get("STKI0");
60 ReadWriteEnd STKI1 = readWriteEnds.get("STKI1");
62 Bit PASSVal = PASS.getValue();
63 Bit I3Val = I.getValue(3);
64 Bit I2Val = I.getValue(2);
65 Bit I1Val = I.getValue(1);
66 Bit I0Val = I.getValue(0);
67 Bit Req0Val = Req0.getValue();
69 if (!I3Val.isBinary() || !I2Val.isBinary() || !I1Val.isBinary() || !I0Val.isBinary())
70 if ((I3Val == U || I3Val.isBinary()) || (I2Val == U || I2Val.isBinary()) || (I1Val == U || I1Val.isBinary())
71 || (I0Val == U || I0Val.isBinary()))
100 int IAsInt = (I3Val == ONE ? 8 : 0) + (I2Val == ONE ? 4 : 0) + (I1Val == ONE ? 2 : 0) + (I0Val == ONE ? 1 : 0);
106 else if (IAsInt == 6)
110 _PL.feedSignals(_PLVal);
111 _MAP.feedSignals(_MAPVal);
112 _VECT.feedSignals(_VECTVal);
113 if (IAsInt == 8 || IAsInt == 9 || IAsInt == 15)
115 RLD.feedSignals(ZERO);
116 RDEC.feedSignals(Req0Val);// "forward" X/U/Z
117 } else if (IAsInt == 4)
119 RLD.feedSignals(PASSVal);// "forward" X/U/Z
121 } else if (IAsInt == 12)
123 RLD.feedSignals(ONE);
127 RLD.feedSignals(ZERO);
128 RDEC.feedSignals(ZERO);
130 if (!PASSVal.isBinary())
132 YD.feedSignals(PASSVal);// "forward" X/U/Z
133 YR.feedSignals(PASSVal);// "forward" X/U/Z
134 YF.feedSignals(PASSVal);// "forward" X/U/Z
135 YmuPC.feedSignals(PASSVal);// "forward" X/U/Z
142 switch (IAsInt + (PASSVal == ONE ? 16 : 0))
182 YFVal = Req0Val.not();// "forward" X/U/Z
183 YmuPCVal = Req0Val;// "forward" X/U/Z
187 YDVal = Req0Val.not();// "forward" X/U/Z
188 YmuPCVal = Req0Val;// "forward" X/U/Z
191 YFVal = Req0Val.not();// "forward" X/U/Z
192 YDVal = Req0Val;// "forward" X/U/Z
195 throw new IllegalStateException("shouldn't happen");
197 YD.feedSignals(YDVal);
198 YR.feedSignals(YRVal);
199 YF.feedSignals(YFVal);
200 YmuPC.feedSignals(YmuPCVal);
203 switch (IAsInt + (PASSVal == ONE ? 16 : 0))
253 STKI1Val = Req0Val;// "forward" X/U/Z
254 STKI0Val = Req0Val;// "forward" X/U/Z
257 throw new IllegalStateException("shouldn't happen");
259 STKI0.feedSignals(STKI0Val);
260 STKI1.feedSignals(STKI1Val);
268 IndirectModelComponentCreator.setComponentSupplier(ModelAm2910InstrPLA.class.getCanonicalName(),
269 (m, p, n) -> new ModelAm2910InstrPLA(m, n));