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.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 GUIAm2904ShiftInstrDecode extends SimpleRectangularHardcodedGUIComponent
21 public GUIAm2904ShiftInstrDecode(ViewModelModifiable model, String name)
23 super(model, name, "Shift \ninstruction\ndecode");
25 addPin(new Pin(this, "I", 5, 0, 35), Usage.INPUT, Position.RIGHT);
32 addPin(new Pin(this, "SIO0_MUX", 3, 60, 5), Usage.OUTPUT, Position.LEFT);
42 addPin(new Pin(this, "SIOn_MUX", 3, 60, 15), Usage.OUTPUT, Position.LEFT);
49 addPin(new Pin(this, "QIO0_MUX", 3, 60, 25), Usage.OUTPUT, Position.LEFT);
56 addPin(new Pin(this, "QIOn_MUX", 3, 60, 35), Usage.OUTPUT, Position.LEFT);
57 addPin(new Pin(this, "LSHIFT", 1, 60, 45), Usage.OUTPUT, Position.LEFT);
61 addPin(new Pin(this, "MC_MUX", 2, 60, 55), Usage.OUTPUT, Position.LEFT);
62 addPin(new Pin(this, "MC_EN", 1, 60, 65), Usage.OUTPUT, Position.LEFT);
66 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
68 Bit[] IBits = readEnds.get("I").getValues().getBits();
69 readWriteEnds.get("LSHIFT").feedSignals(IBits[0]);
70 // TODO move the following loop to BitVector.
72 for (int i = 0; i < 5; i++)
79 readWriteEnds.get("SIO0_MUX").feedSignals(U, U, U);
80 readWriteEnds.get("SIOn_MUX").feedSignals(U, U, U);
81 readWriteEnds.get("QIO0_MUX").feedSignals(U, U, U);
82 readWriteEnds.get("QIOn_MUX").feedSignals(U, U, U);
83 readWriteEnds.get("MC_MUX").feedSignals(U, U);
84 readWriteEnds.get("MC_EN").feedSignals(U);
88 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
89 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
90 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
91 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
92 readWriteEnds.get("MC_MUX").feedSignals(X, X);
93 readWriteEnds.get("MC_EN").feedSignals(X);
98 throw new IllegalArgumentException("Unknown enum constant: " + IBits[i]);
102 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
103 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
110 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
114 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ONE);
119 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ZERO);
122 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ONE);
126 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ZERO);
129 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ZERO);
133 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ONE);
136 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ONE);
139 throw new IllegalStateException("can't happen");
144 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
147 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ONE);
150 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ONE, X);
162 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ONE, X);
167 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ZERO, X);
170 throw new IllegalStateException("can't happen");
174 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
175 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
180 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
184 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ONE);
194 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, X);
198 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, X);
202 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ONE, X);
205 throw new IllegalStateException("can't happen");
214 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
220 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ONE);
225 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, X);
229 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, X);
233 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ONE, X);
236 throw new IllegalStateException("can't happen");
260 readWriteEnds.get("MC_EN").feedSignals(ZERO);
261 readWriteEnds.get("MC_MUX").feedSignals(X, X);
266 readWriteEnds.get("MC_EN").feedSignals(ONE);
267 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ZERO);
272 readWriteEnds.get("MC_EN").feedSignals(ONE);
273 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ONE);
283 readWriteEnds.get("MC_EN").feedSignals(ONE);
284 readWriteEnds.get("MC_MUX").feedSignals(ONE, X);
287 throw new IllegalStateException("can't happen");
294 IndirectGUIComponentCreator.setComponentSupplier(GUIAm2904ShiftInstrDecode.class.getCanonicalName(),
295 (m, p, n) -> new GUIAm2904ShiftInstrDecode(m, n));