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.types.BitVector;
13 import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
14 import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
15 import net.mograsim.logic.model.model.LogicModelModifiable;
16 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedModelComponent;
17 import net.mograsim.logic.model.model.wires.Pin;
18 import net.mograsim.logic.model.model.wires.PinUsage;
19 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
20 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
22 public class ModelAm2904ShiftInstrDecode extends SimpleRectangularHardcodedModelComponent
24 public ModelAm2904ShiftInstrDecode(LogicModelModifiable model, String name)
26 super(model, "Am2904ShiftInstrDecode", name, "Shift \ninstruction\ndecode", false);
28 addPin(new Pin(model, this, "I", 5, PinUsage.INPUT, 0, 25), Position.RIGHT);
29 addPin(new Pin(model, this, "_SE", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
36 addPin(new Pin(model, this, "SIO0_MUX", 3, PinUsage.OUTPUT, 60, 5), Position.LEFT);
46 addPin(new Pin(model, this, "SIOn_MUX", 3, PinUsage.OUTPUT, 60, 15), Position.LEFT);
53 addPin(new Pin(model, this, "QIO0_MUX", 3, PinUsage.OUTPUT, 60, 25), Position.LEFT);
60 addPin(new Pin(model, this, "QIOn_MUX", 3, PinUsage.OUTPUT, 60, 35), Position.LEFT);
61 addPin(new Pin(model, this, "OEn", 1, PinUsage.OUTPUT, 60, 45), Position.LEFT);
62 addPin(new Pin(model, this, "OE0", 1, PinUsage.OUTPUT, 60, 55), Position.LEFT);
66 addPin(new Pin(model, this, "MC_MUX", 2, PinUsage.OUTPUT, 60, 65), Position.LEFT);
67 addPin(new Pin(model, this, "MC_EN", 1, PinUsage.OUTPUT, 60, 75), Position.LEFT);
73 public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
75 Bit _SE = readEnds.get("_SE").getValue();
76 BitVector I = readEnds.get("I").getValues();
77 readWriteEnds.get("OEn").feedSignals(I.getMSBit(0).not().and(_SE.not()));
78 readWriteEnds.get("OE0").feedSignals(I.getMSBit(0).and(_SE.not()));
79 if (_SE == Z || _SE == X)
81 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
82 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
83 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
84 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
85 readWriteEnds.get("MC_MUX").feedSignals(X, X);
86 readWriteEnds.get("MC_EN").feedSignals(X);
91 readWriteEnds.get("SIO0_MUX").feedSignals(U, U, U);
92 readWriteEnds.get("SIOn_MUX").feedSignals(U, U, U);
93 readWriteEnds.get("QIO0_MUX").feedSignals(U, U, U);
94 readWriteEnds.get("QIOn_MUX").feedSignals(U, U, U);
95 readWriteEnds.get("MC_MUX").feedSignals(U, U);
96 readWriteEnds.get("MC_EN").feedSignals(U);
98 } else if (_SE == ONE)
100 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
101 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
102 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
103 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
104 readWriteEnds.get("MC_MUX").feedSignals(X, X);
105 readWriteEnds.get("MC_EN").feedSignals(ZERO);
111 for (Bit b : I.getBits())
117 readWriteEnds.get("SIO0_MUX").feedSignals(val, val, val);
118 readWriteEnds.get("SIOn_MUX").feedSignals(val, val, val);
119 readWriteEnds.get("QIO0_MUX").feedSignals(val, val, val);
120 readWriteEnds.get("QIOn_MUX").feedSignals(val, val, val);
121 readWriteEnds.get("MC_MUX").feedSignals(val, val);
122 readWriteEnds.get("MC_EN").feedSignals(val);
125 int IAsInt = I.getUnsignedValue().intValue();
128 readWriteEnds.get("SIO0_MUX").feedSignals(X, X, X);
129 readWriteEnds.get("QIO0_MUX").feedSignals(X, X, X);
136 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
140 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ONE);
145 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ZERO);
148 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ONE);
152 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ZERO);
155 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ZERO);
159 readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ONE);
162 readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ONE);
165 throw new IllegalStateException("can't happen");
170 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
173 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ONE);
176 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ONE, X);
188 readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ONE, X);
193 readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ZERO, X);
196 throw new IllegalStateException("can't happen");
200 readWriteEnds.get("SIOn_MUX").feedSignals(X, X, X);
201 readWriteEnds.get("QIOn_MUX").feedSignals(X, X, X);
206 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
210 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ONE);
220 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, X);
224 readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ONE, X);
228 readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, X);
231 throw new IllegalStateException("can't happen");
240 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
246 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ONE);
251 readWriteEnds.get("QIO0_MUX").feedSignals(ONE, ZERO, X);
255 readWriteEnds.get("QIO0_MUX").feedSignals(ONE, ONE, X);
259 readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ONE, X);
262 throw new IllegalStateException("can't happen");
286 readWriteEnds.get("MC_EN").feedSignals(ZERO);
287 readWriteEnds.get("MC_MUX").feedSignals(X, X);
292 readWriteEnds.get("MC_EN").feedSignals(ONE);
293 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ZERO);
298 readWriteEnds.get("MC_EN").feedSignals(ONE);
299 readWriteEnds.get("MC_MUX").feedSignals(ZERO, ONE);
309 readWriteEnds.get("MC_EN").feedSignals(ONE);
310 readWriteEnds.get("MC_MUX").feedSignals(ONE, X);
313 throw new IllegalStateException("can't happen");
320 IndirectModelComponentCreator.setComponentSupplier(ModelAm2904ShiftInstrDecode.class.getCanonicalName(),
321 (m, p, n) -> new ModelAm2904ShiftInstrDecode(m, n));