From: Daniel Kirschten Date: Sun, 18 Aug 2019 10:06:43 +0000 (+0200) Subject: Renamed GUImux4_12 to GUIsel4_12 for consistency X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=900b54a409bb115bcc04f46d904a96b539bf7b7d;p=Mograsim.git Renamed GUImux4_12 to GUIsel4_12 for consistency --- diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUImux4_12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUImux4_12.java deleted file mode 100644 index e43888ab..00000000 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUImux4_12.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.mograsim.logic.model.am2900.components; - -import static net.mograsim.logic.core.types.Bit.ONE; -import static net.mograsim.logic.core.types.Bit.U; -import static net.mograsim.logic.core.types.Bit.X; -import static net.mograsim.logic.core.types.Bit.Z; -import static net.mograsim.logic.core.types.Bit.ZERO; - -import java.util.Map; - -import net.mograsim.logic.core.types.Bit; -import net.mograsim.logic.core.types.BitVector; -import net.mograsim.logic.core.wires.Wire.ReadEnd; -import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; -import net.mograsim.logic.model.model.ViewModelModifiable; -import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent; -import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; -import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position; - -public class GUImux4_12 extends SimpleRectangularHardcodedGUIComponent -{ - public GUImux4_12(ViewModelModifiable model, String name) - { - super(model, name, "4-way MUX\n12 bit"); - setSize(80, 40); - addPin(new Pin(this, "SA", 1, 0, 5), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "SB", 1, 0, 15), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "SC", 1, 0, 25), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "SD", 1, 0, 35), Usage.INPUT, Position.RIGHT); - addPin(new Pin(this, "A", 12, 10, 0), Usage.INPUT, Position.BOTTOM); - addPin(new Pin(this, "B", 12, 30, 0), Usage.INPUT, Position.BOTTOM); - addPin(new Pin(this, "C", 12, 50, 0), Usage.INPUT, Position.BOTTOM); - addPin(new Pin(this, "D", 12, 70, 0), Usage.INPUT, Position.BOTTOM); - addPin(new Pin(this, "Y", 12, 40, 40), Usage.OUTPUT, Position.TOP); - } - - @Override - protected Object recalculate(Object lastState, Map readEnds, Map readWriteEnds) - { - Bit SAVal = readEnds.get("SA").getValue(); - Bit SBVal = readEnds.get("SB").getValue(); - Bit SCVal = readEnds.get("SC").getValue(); - Bit SDVal = readEnds.get("SD").getValue(); - BitVector YVal; - if (SAVal == X || SBVal == X || SCVal == X || SDVal == X) - YVal = BitVector.of(X, 12); - else if (SAVal == U || SBVal == U || SCVal == U || SDVal == U) - YVal = BitVector.of(U, 12); - else if (SAVal == Z || SBVal == Z || SCVal == Z || SDVal == Z) - YVal = BitVector.of(X, 12); - else - { - YVal = null; - if (SAVal == ONE) - YVal = readEnds.get("A").getValues(); - if (SBVal == ONE) - if (YVal != null) - YVal = BitVector.of(X, 12); - else - YVal = readEnds.get("B").getValues(); - if (SCVal == ONE) - if (YVal != null) - YVal = BitVector.of(X, 12); - else - YVal = readEnds.get("C").getValues(); - if (SDVal == ONE) - if (YVal != null) - YVal = BitVector.of(X, 12); - else - YVal = readEnds.get("D").getValues(); - if (YVal == null) - YVal = BitVector.of(ZERO, 12); - } - - readWriteEnds.get("Y").feedSignals(YVal); - return null; - } - - static - { - IndirectGUIComponentCreator.setComponentSupplier(GUImux4_12.class.getCanonicalName(), (m, p, n) -> new GUImux4_12(m, n)); - } -} \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIsel4_12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIsel4_12.java new file mode 100644 index 00000000..480a4b13 --- /dev/null +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIsel4_12.java @@ -0,0 +1,84 @@ +package net.mograsim.logic.model.am2900.components; + +import static net.mograsim.logic.core.types.Bit.ONE; +import static net.mograsim.logic.core.types.Bit.U; +import static net.mograsim.logic.core.types.Bit.X; +import static net.mograsim.logic.core.types.Bit.Z; +import static net.mograsim.logic.core.types.Bit.ZERO; + +import java.util.Map; + +import net.mograsim.logic.core.types.Bit; +import net.mograsim.logic.core.types.BitVector; +import net.mograsim.logic.core.wires.Wire.ReadEnd; +import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; +import net.mograsim.logic.model.model.ViewModelModifiable; +import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent; +import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; +import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position; + +public class GUIsel4_12 extends SimpleRectangularHardcodedGUIComponent +{ + public GUIsel4_12(ViewModelModifiable model, String name) + { + super(model, name, "4-way SEL\n12 bit"); + setSize(80, 40); + addPin(new Pin(this, "SA", 1, 0, 5), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "SB", 1, 0, 15), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "SC", 1, 0, 25), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "SD", 1, 0, 35), Usage.INPUT, Position.RIGHT); + addPin(new Pin(this, "A", 12, 10, 0), Usage.INPUT, Position.BOTTOM); + addPin(new Pin(this, "B", 12, 30, 0), Usage.INPUT, Position.BOTTOM); + addPin(new Pin(this, "C", 12, 50, 0), Usage.INPUT, Position.BOTTOM); + addPin(new Pin(this, "D", 12, 70, 0), Usage.INPUT, Position.BOTTOM); + addPin(new Pin(this, "Y", 12, 40, 40), Usage.OUTPUT, Position.TOP); + } + + @Override + protected Object recalculate(Object lastState, Map readEnds, Map readWriteEnds) + { + Bit SAVal = readEnds.get("SA").getValue(); + Bit SBVal = readEnds.get("SB").getValue(); + Bit SCVal = readEnds.get("SC").getValue(); + Bit SDVal = readEnds.get("SD").getValue(); + BitVector YVal; + if (SAVal == X || SBVal == X || SCVal == X || SDVal == X) + YVal = BitVector.of(X, 12); + else if (SAVal == U || SBVal == U || SCVal == U || SDVal == U) + YVal = BitVector.of(U, 12); + else if (SAVal == Z || SBVal == Z || SCVal == Z || SDVal == Z) + YVal = BitVector.of(X, 12); + else + { + YVal = null; + if (SAVal == ONE) + YVal = readEnds.get("A").getValues(); + if (SBVal == ONE) + if (YVal != null) + YVal = BitVector.of(X, 12); + else + YVal = readEnds.get("B").getValues(); + if (SCVal == ONE) + if (YVal != null) + YVal = BitVector.of(X, 12); + else + YVal = readEnds.get("C").getValues(); + if (SDVal == ONE) + if (YVal != null) + YVal = BitVector.of(X, 12); + else + YVal = readEnds.get("D").getValues(); + if (YVal == null) + YVal = BitVector.of(ZERO, 12); + } + + readWriteEnds.get("Y").feedSignals(YVal); + return null; + } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIsel4_12.class.getCanonicalName(), (m, p, n) -> new GUIsel4_12(m, n)); + } +} \ No newline at end of file diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json index 08a0a1c1..92cd2f5b 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json @@ -32,7 +32,6 @@ mograsim version: 0.1.3 "GUIinc12": "class:net.mograsim.logic.model.am2900.components.GUIinc12", "GUImux1": "file:components/GUImux1.json", "GUImux1_4": "file:components/GUImux1_4.json", - "GUImux4_12": "class:net.mograsim.logic.model.am2900.components.GUImux4_12", "GUInand3": "file:components/GUInand3.json", "GUInor12": "class:net.mograsim.logic.model.am2900.components.GUInor12", "GUInot4": "file:components/GUInot4.json", @@ -43,6 +42,7 @@ mograsim version: 0.1.3 "GUIram5_12": "class:net.mograsim.logic.model.am2900.components.GUIram5_12", "GUIsel2_4": "file:components/GUIsel2_4.json", "GUIsel3_4": "file:components/GUIsel3_4.json", + "GUIsel4_12": "class:net.mograsim.logic.model.am2900.components.GUImux4_12", "GUISplitter": "class:net.mograsim.logic.model.model.components.atomic.GUISplitter", "GUIxor": "file:components/GUIxor.json", "WireCrossPoint": "class:net.mograsim.logic.model.model.wires.WireCrossPoint"