Implemented GUIAm2904ShiftInstrDecode
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 18 Aug 2019 19:02:13 +0000 (21:02 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 18 Aug 2019 19:02:13 +0000 (21:02 +0200)
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/GUIAm2904ShiftInstrDecode.java [new file with mode: 0644]
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/standardComponentIDMapping.json

diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/GUIAm2904ShiftInstrDecode.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/GUIAm2904ShiftInstrDecode.java
new file mode 100644 (file)
index 0000000..64935e8
--- /dev/null
@@ -0,0 +1,298 @@
+package net.mograsim.logic.model.am2900.components.am2904;
+
+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.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 GUIAm2904ShiftInstrDecode extends SimpleRectangularHardcodedGUIComponent
+{
+       public GUIAm2904ShiftInstrDecode(ViewModelModifiable model, String name)
+       {
+               super(model, name, "Shift \ninstruction\ndecode");
+               setSize(60, 70);
+               addPin(new Pin(this, "I", 5, 0, 35), Usage.INPUT, Position.RIGHT);
+               // SIO0 MUX:
+               // 000: 0
+               // 001: 1
+               // 01x: SIOn
+               // 10x: QIOn
+               // 11x: MC
+               addPin(new Pin(this, "SIO0_MUX", 3, 60, 5), Usage.OUTPUT, Position.LEFT);
+               // SIOn MUX:
+               // 000: 0
+               // 001: 1
+               // 010: SIO0
+               // 011: QIO0
+               // 100: MC
+               // 101: MN
+               // 110: IC
+               // 111: IN xor IVOR
+               addPin(new Pin(this, "SIOn_MUX", 3, 60, 15), Usage.OUTPUT, Position.LEFT);
+               // QIO0 MUX:
+               // 000: 0
+               // 001: 1
+               // 01x: SIOn
+               // 10x: QIOn
+               // 11x: MC
+               addPin(new Pin(this, "QIO0_MUX", 3, 60, 25), Usage.OUTPUT, Position.LEFT);
+               // QIOn MUX:
+               // 000: 0
+               // 001: 1
+               // 01x: SIO0
+               // 10x: QIO0
+               // 11x: MN
+               addPin(new Pin(this, "QIOn_MUX", 3, 60, 35), Usage.OUTPUT, Position.LEFT);
+               addPin(new Pin(this, "LSHIFT", 1, 60, 45), Usage.OUTPUT, Position.LEFT);
+               // 00: SIO0
+               // 01: QIO0
+               // 1x: SIOn
+               addPin(new Pin(this, "MC_MUX", 2, 60, 55), Usage.OUTPUT, Position.LEFT);
+               addPin(new Pin(this, "MC_EN", 1, 60, 65), Usage.OUTPUT, Position.LEFT);
+       }
+
+       @Override
+       protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
+       {
+               Bit[] IBits = readEnds.get("I").getValues().getBits();
+               readWriteEnds.get("LSHIFT").feedSignals(IBits[0]);
+               // TODO move the following loop to BitVector.
+               int IAsInt = 0;
+               for (int i = 0; i < 5; i++)
+                       switch (IBits[4 - i])
+                       {
+                       case ONE:
+                               IAsInt |= 1 << i;
+                               break;
+                       case U:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(U);
+                               readWriteEnds.get("SIOn_MUX").feedSignals(U);
+                               readWriteEnds.get("QIO0_MUX").feedSignals(U);
+                               readWriteEnds.get("QIOn_MUX").feedSignals(U);
+                               readWriteEnds.get("MC_MUX").feedSignals(U);
+                               readWriteEnds.get("MC_EN").feedSignals(U);
+                               return null;
+                       case X:
+                       case Z:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(X);
+                               readWriteEnds.get("SIOn_MUX").feedSignals(X);
+                               readWriteEnds.get("QIO0_MUX").feedSignals(X);
+                               readWriteEnds.get("QIOn_MUX").feedSignals(X);
+                               readWriteEnds.get("MC_MUX").feedSignals(X);
+                               readWriteEnds.get("MC_EN").feedSignals(X);
+                               return null;
+                       case ZERO:
+                               break;
+                       default:
+                               throw new IllegalArgumentException("Unknown enum constant: " + IBits[i]);
+                       }
+               if (IAsInt < 16)
+               {
+                       readWriteEnds.get("SIO0_MUX").feedSignals(Z, Z, Z);
+                       readWriteEnds.get("QIO0_MUX").feedSignals(Z, Z, Z);
+                       switch (IAsInt)
+                       {
+                       case 0:
+                       case 2:
+                       case 6:
+                       case 7:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
+                               break;
+                       case 1:
+                       case 3:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ZERO, ONE);
+                               break;
+                       case 4:
+                       case 9:
+                       case 12:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ZERO);
+                               break;
+                       case 5:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ZERO, ONE);
+                               break;
+                       case 8:
+                       case 10:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ZERO);
+                               break;
+                       case 11:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ZERO);
+                               break;
+                       case 13:
+                       case 15:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ZERO, ONE, ONE);
+                               break;
+                       case 14:
+                               readWriteEnds.get("SIOn_MUX").feedSignals(ONE, ONE, ONE);
+                               break;
+                       default:
+                               throw new IllegalStateException("can't happen");
+                       }
+                       switch (IAsInt)
+                       {
+                       case 0:
+                               readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ZERO);
+                               break;
+                       case 1:
+                               readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ZERO, ONE);
+                               break;
+                       case 2:
+                               readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ONE, Z);
+                               break;
+                       case 3:
+                       case 4:
+                       case 5:
+                       case 6:
+                       case 7:
+                       case 11:
+                       case 12:
+                       case 13:
+                       case 14:
+                       case 15:
+                               readWriteEnds.get("QIOn_MUX").feedSignals(ZERO, ONE, Z);
+                               break;
+                       case 8:
+                       case 9:
+                       case 10:
+                               readWriteEnds.get("QIOn_MUX").feedSignals(ONE, ZERO, Z);
+                               break;
+                       default:
+                               throw new IllegalStateException("can't happen");
+                       }
+               } else
+               {
+                       readWriteEnds.get("SIOn_MUX").feedSignals(Z, Z, Z);
+                       readWriteEnds.get("QIOn_MUX").feedSignals(Z, Z, Z);
+                       switch (IAsInt)
+                       {
+                       case 16:
+                       case 18:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
+                               break;
+                       case 17:
+                       case 19:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ZERO, ONE);
+                               break;
+                       case 20:
+                       case 21:
+                       case 22:
+                       case 23:
+                       case 28:
+                       case 29:
+                       case 30:
+                       case 31:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, Z);
+                               break;
+                       case 24:
+                       case 26:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, Z);
+                               break;
+                       case 25:
+                       case 27:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ZERO, ONE, Z);
+                               break;
+                       default:
+                               throw new IllegalStateException("can't happen");
+                       }
+                       switch (IAsInt)
+                       {
+                       case 16:
+                       case 18:
+                       case 20:
+                       case 22:
+                       case 27:
+                               readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ZERO);
+                               break;
+                       case 17:
+                       case 19:
+                       case 21:
+                       case 23:
+                               readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ZERO, ONE);
+                               break;
+                       case 24:
+                       case 25:
+                       case 26:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ZERO, Z);
+                               break;
+                       case 28:
+                       case 30:
+                               readWriteEnds.get("SIO0_MUX").feedSignals(ONE, ONE, Z);
+                               break;
+                       case 29:
+                       case 31:
+                               readWriteEnds.get("QIO0_MUX").feedSignals(ZERO, ONE, Z);
+                               break;
+                       default:
+                               throw new IllegalStateException("can't happen");
+                       }
+               }
+               // MC
+               switch (IAsInt)
+               {
+               case 0:
+               case 1:
+               case 3:
+               case 4:
+               case 5:
+               case 6:
+               case 10:
+               case 11:
+               case 14:
+               case 15:
+               case 18:
+               case 19:
+               case 22:
+               case 23:
+               case 26:
+               case 27:
+               case 30:
+               case 31:
+                       readWriteEnds.get("MC_EN").feedSignals(ZERO);
+                       readWriteEnds.get("MC_MUX").feedSignals(Z, Z);
+                       break;
+               case 2:
+               case 8:
+               case 9:
+                       readWriteEnds.get("MC_EN").feedSignals(ONE);
+                       readWriteEnds.get("MC_MUX").feedSignals(ZERO, ZERO);
+                       break;
+               case 7:
+               case 12:
+               case 13:
+                       readWriteEnds.get("MC_EN").feedSignals(ONE);
+                       readWriteEnds.get("MC_MUX").feedSignals(ZERO, ONE);
+                       break;
+               case 16:
+               case 17:
+               case 20:
+               case 21:
+               case 24:
+               case 25:
+               case 28:
+               case 29:
+                       readWriteEnds.get("MC_EN").feedSignals(ONE);
+                       readWriteEnds.get("MC_MUX").feedSignals(ONE, Z);
+                       break;
+               default:
+                       throw new IllegalStateException("can't happen");
+               }
+               return null;
+       }
+
+       static
+       {
+               IndirectGUIComponentCreator.setComponentSupplier(GUIAm2904ShiftInstrDecode.class.getCanonicalName(),
+                               (m, p, n) -> new GUIAm2904ShiftInstrDecode(m, n));
+       }
+}
\ No newline at end of file
index 45f538c..7ea2278 100644 (file)
@@ -26,7 +26,7 @@ public class GUIComponentTestbench
        public static void createTestbench(ViewModelModifiable model)
        {
                GUIComponent comp = IndirectGUIComponentCreator.createComponent(model,
-                               "class:net.mograsim.logic.model.am2900.components.am2904.GUIAm2904RegCTInstrDecode");
+                               "class:net.mograsim.logic.model.am2900.components.am2904.ShiftInstrDecode");
 
                // guess which pins are outputs and which are inputs
                // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
index 11e4634..8db8578 100644 (file)
@@ -35,7 +35,7 @@ import net.mograsim.preferences.Preferences;
  */
 public class LogicUICanvas extends ZoomableCanvas
 {
-       private static final boolean OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL = false;
+       private static final boolean OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL = true;
 
        private final ViewModel model;
 
index 9fa80d0..726e36e 100644 (file)
@@ -8,6 +8,7 @@ mograsim version: 0.1.3
   "GUIAm2901ALUInclSourceDecodeInclFunctionDecode": "file:components/am2901/GUIAm2901ALUInclSourceDecodeInclFunctionDecode.json",
   "GUIAm2901ALUOneBit": "file:components/am2901/GUIAm2901ALUOneBit.json",
   "GUIAm2904RegCTInstrDecode": "class:net.mograsim.logic.model.am2900.components.am2904.GUIAm2904RegCTInstrDecode",
+  "GUIAm2904ShiftInstrDecode": "class:net.mograsim.logic.model.am2900.components.am2904.GUIAm2904ShiftInstrDecode",
   "GUIAm2901DestDecode": "file:components/am2901/GUIAm2901DestDecode.json",
   "GUIAm2901SourceDecode": "file:components/am2901/GUIAm2901SourceDecode.json",
   "GUIAm2910InstrPLA": "class:net.mograsim.logic.model.am2900.components.am2910.GUIAm2910InstrPLA",