1 package net.mograsim.logic.model.am2900.components.am2904;
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.Z;
7 import static net.mograsim.logic.core.types.Bit.ZERO;
11 import net.mograsim.logic.core.types.Bit;
12 import net.mograsim.logic.core.wires.Wire.ReadEnd;
13 import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
14 import net.mograsim.logic.model.model.ViewModelModifiable;
15 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
16 import net.mograsim.logic.model.model.wires.Pin;
17 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
18 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
20 public class GUIAm2904ShiftInstrDecode extends SimpleRectangularHardcodedGUIComponent
22 public GUIAm2904ShiftInstrDecode(ViewModelModifiable model, String name)
24 super(model, name, "Shift \ninstruction\ndecode");
26 addPin(new Pin(this, "I", 5, 0, 35), Usage.INPUT, Position.RIGHT);
33 addPin(new Pin(this, "SIO0_MUX", 3, 60, 5), Usage.OUTPUT, Position.LEFT);
43 addPin(new Pin(this, "SIOn_MUX", 3, 60, 15), Usage.OUTPUT, Position.LEFT);
50 addPin(new Pin(this, "QIO0_MUX", 3, 60, 25), Usage.OUTPUT, Position.LEFT);
57 addPin(new Pin(this, "QIOn_MUX", 3, 60, 35), Usage.OUTPUT, Position.LEFT);
58 addPin(new Pin(this, "LSHIFT", 1, 60, 45), Usage.OUTPUT, Position.LEFT);
62 addPin(new Pin(this, "MC_MUX", 2, 60, 55), Usage.OUTPUT, Position.LEFT);
63 addPin(new Pin(this, "MC_EN", 1, 60, 65), Usage.OUTPUT, Position.LEFT);
67 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
69 Bit[] IBits = readEnds.get("I").getValues().getBits();
70 readWriteEnds.get("LSHIFT").feedSignals(IBits[0]);
71 // TODO move the following loop to BitVector.
73 for (int i = 0; i < 5; i++)
80 readWriteEnds.get("SIO0_MUX").feedSignals(U, U, U);
81 readWriteEnds.get("SIOn_MUX").feedSignals(U, U, U);
82 readWriteEnds.get("QIO0_MUX").feedSignals(U, U, U);
83 readWriteEnds.get("QIOn_MUX").feedSignals(U, U, U);
84 readWriteEnds.get("MC_MUX").feedSignals(U, U);
85 readWriteEnds.get("MC_EN").feedSignals(U);
89 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
90 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
91 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
92 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
93 readWriteEnds.get("MC_MUX").feedSignals(X, X);
94 readWriteEnds.get("MC_EN").feedSignals(X);
99 throw new IllegalArgumentException("Unknown enum constant: " + IBits[i]);
103 readWriteEnds.get("SIO0_MUX").feedSignals(Z, Z, Z);
104 readWriteEnds.get("QIO0_MUX").feedSignals(Z, Z, Z);
111 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
115 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ONE);
120 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ZERO);
123 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ONE);
127 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ZERO);
130 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ZERO);
134 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ONE);
137 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ONE);
140 throw new IllegalStateException("can't happen");
145 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
148 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ONE);
151 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ONE, Z);
163 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ONE, Z);
168 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ZERO, Z);
171 throw new IllegalStateException("can't happen");
175 readWriteEnds.get("SIOn_MUX").feedSignals(Z, Z, Z);
176 readWriteEnds.get("QIOn_MUX").feedSignals(Z, Z, Z);
181 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
185 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ONE);
195 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, Z);
199 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, Z);
203 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ONE, Z);
206 throw new IllegalStateException("can't happen");
215 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
221 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ONE);
226 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, Z);
230 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, Z);
234 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ONE, Z);
237 throw new IllegalStateException("can't happen");
261 readWriteEnds.get("MC_EN").feedSignals(ZERO);
262 readWriteEnds.get("MC_MUX").feedSignals(Z, Z);
267 readWriteEnds.get("MC_EN").feedSignals(ONE);
268 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ZERO);
273 readWriteEnds.get("MC_EN").feedSignals(ONE);
274 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ONE);
284 readWriteEnds.get("MC_EN").feedSignals(ONE);
285 readWriteEnds.get("MC_MUX").feedSignals(ONE, Z);
288 throw new IllegalStateException("can't happen");
295 IndirectGUIComponentCreator.setComponentSupplier(GUIAm2904ShiftInstrDecode.class.getCanonicalName(),
296 (m, p, n) -> new GUIAm2904ShiftInstrDecode(m, n));