1 package net.mograsim.logic.model.am2900.components;
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.Wire.ReadEnd;
14 import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
15 import net.mograsim.logic.model.model.ViewModelModifiable;
16 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
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.IndirectGUIComponentCreator;
20 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
22 public class GUIsel4_12 extends SimpleRectangularHardcodedGUIComponent
24 public GUIsel4_12(ViewModelModifiable model, String name)
26 super(model, name, "4-way SEL\n12 bit");
28 addPin(new Pin(this, "SA", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
29 addPin(new Pin(this, "SB", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
30 addPin(new Pin(this, "SC", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
31 addPin(new Pin(this, "SD", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
32 addPin(new Pin(this, "A", 12, PinUsage.INPUT, 10, 0), Position.BOTTOM);
33 addPin(new Pin(this, "B", 12, PinUsage.INPUT, 30, 0), Position.BOTTOM);
34 addPin(new Pin(this, "C", 12, PinUsage.INPUT, 50, 0), Position.BOTTOM);
35 addPin(new Pin(this, "D", 12, PinUsage.INPUT, 70, 0), Position.BOTTOM);
36 addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 40, 40), Position.TOP);
40 public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
42 Bit SAVal = readEnds.get("SA").getValue();
43 Bit SBVal = readEnds.get("SB").getValue();
44 Bit SCVal = readEnds.get("SC").getValue();
45 Bit SDVal = readEnds.get("SD").getValue();
47 if (SAVal == X || SBVal == X || SCVal == X || SDVal == X)
48 YVal = BitVector.of(X, 12);
49 else if (SAVal == U || SBVal == U || SCVal == U || SDVal == U)
50 YVal = BitVector.of(U, 12);
51 else if (SAVal == Z || SBVal == Z || SCVal == Z || SDVal == Z)
52 YVal = BitVector.of(X, 12);
57 YVal = readEnds.get("A").getValues();
60 YVal = BitVector.of(X, 12);
62 YVal = readEnds.get("B").getValues();
65 YVal = BitVector.of(X, 12);
67 YVal = readEnds.get("C").getValues();
70 YVal = BitVector.of(X, 12);
72 YVal = readEnds.get("D").getValues();
74 YVal = BitVector.of(ZERO, 12);
77 readWriteEnds.get("Y").feedSignals(YVal);
83 IndirectGUIComponentCreator.setComponentSupplier(GUIsel4_12.class.getCanonicalName(), (m, p, n) -> new GUIsel4_12(m, n));