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.serializing.IndirectGUIComponentCreator;
19 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
21 public class GUIsel4_12 extends SimpleRectangularHardcodedGUIComponent
23 public GUIsel4_12(ViewModelModifiable model, String name)
25 super(model, name, "4-way SEL\n12 bit");
27 addPin(new Pin(this, "SA", 1, 0, 5), Usage.INPUT, Position.RIGHT);
28 addPin(new Pin(this, "SB", 1, 0, 15), Usage.INPUT, Position.RIGHT);
29 addPin(new Pin(this, "SC", 1, 0, 25), Usage.INPUT, Position.RIGHT);
30 addPin(new Pin(this, "SD", 1, 0, 35), Usage.INPUT, Position.RIGHT);
31 addPin(new Pin(this, "A", 12, 10, 0), Usage.INPUT, Position.BOTTOM);
32 addPin(new Pin(this, "B", 12, 30, 0), Usage.INPUT, Position.BOTTOM);
33 addPin(new Pin(this, "C", 12, 50, 0), Usage.INPUT, Position.BOTTOM);
34 addPin(new Pin(this, "D", 12, 70, 0), Usage.INPUT, Position.BOTTOM);
35 addPin(new Pin(this, "Y", 12, 40, 40), Usage.OUTPUT, Position.TOP);
39 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
41 Bit SAVal = readEnds.get("SA").getValue();
42 Bit SBVal = readEnds.get("SB").getValue();
43 Bit SCVal = readEnds.get("SC").getValue();
44 Bit SDVal = readEnds.get("SD").getValue();
46 if (SAVal == X || SBVal == X || SCVal == X || SDVal == X)
47 YVal = BitVector.of(X, 12);
48 else if (SAVal == U || SBVal == U || SCVal == U || SDVal == U)
49 YVal = BitVector.of(U, 12);
50 else if (SAVal == Z || SBVal == Z || SCVal == Z || SDVal == Z)
51 YVal = BitVector.of(X, 12);
56 YVal = readEnds.get("A").getValues();
59 YVal = BitVector.of(X, 12);
61 YVal = readEnds.get("B").getValues();
64 YVal = BitVector.of(X, 12);
66 YVal = readEnds.get("C").getValues();
69 YVal = BitVector.of(X, 12);
71 YVal = readEnds.get("D").getValues();
73 YVal = BitVector.of(ZERO, 12);
76 readWriteEnds.get("Y").feedSignals(YVal);
82 IndirectGUIComponentCreator.setComponentSupplier(GUIsel4_12.class.getCanonicalName(), (m, p, n) -> new GUIsel4_12(m, n));