Created a gate-based implementation of nor12
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 30 Mar 2020 20:10:21 +0000 (22:10 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 30 Mar 2020 20:10:23 +0000 (22:10 +0200)
plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/nor12.json [new file with mode: 0644]
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelnor12.java [deleted file]
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/standardComponentIDMapping.json
plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ModelComponentTestbench.java

diff --git a/plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/nor12.json b/plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/nor12.json
new file mode 100644 (file)
index 0000000..0dddc1e
--- /dev/null
@@ -0,0 +1,726 @@
+{
+  "width": 45.0,
+  "height": 30.0,
+  "interfacePins": [
+    {
+      "location": {
+        "x": 0.0,
+        "y": 15.0
+      },
+      "name": "D",
+      "logicWidth": 12,
+      "usage": "INPUT"
+    },
+    {
+      "location": {
+        "x": 45.0,
+        "y": 15.0
+      },
+      "name": "Y",
+      "logicWidth": 1,
+      "usage": "OUTPUT"
+    }
+  ],
+  "innerScale": 0.2,
+  "submodel": {
+    "components": [
+      {
+        "id": "NandGate",
+        "name": "NandGate#0",
+        "pos": {
+          "x": 135.0,
+          "y": 65.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#1",
+        "pos": {
+          "x": 70.0,
+          "y": 55.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#2",
+        "pos": {
+          "x": 70.0,
+          "y": 90.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#3",
+        "pos": {
+          "x": 100.0,
+          "y": 65.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#4",
+        "pos": {
+          "x": 135.0,
+          "y": 10.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#5",
+        "pos": {
+          "x": 165.0,
+          "y": 65.0
+        },
+        "params": 1
+      },
+      {
+        "id": "NandGate",
+        "name": "NandGate#6",
+        "pos": {
+          "x": 200.0,
+          "y": 65.0
+        },
+        "params": 1
+      },
+      {
+        "id": "Splitter",
+        "name": "Splitter#0",
+        "pos": {
+          "x": 5.0,
+          "y": 20.0
+        },
+        "params": {
+          "logicWidth": 12,
+          "orientation": "RIGHT"
+        }
+      },
+      {
+        "id": "WireCrossPoint",
+        "name": "WireCrossPoint#0",
+        "pos": {
+          "x": 129.0,
+          "y": 74.0
+        },
+        "params": 1
+      },
+      {
+        "id": "WireCrossPoint",
+        "name": "WireCrossPoint#1",
+        "pos": {
+          "x": 64.0,
+          "y": 59.0
+        },
+        "params": 1
+      },
+      {
+        "id": "WireCrossPoint",
+        "name": "WireCrossPoint#2",
+        "pos": {
+          "x": 64.0,
+          "y": 104.0
+        },
+        "params": 1
+      },
+      {
+        "id": "WireCrossPoint",
+        "name": "WireCrossPoint#3",
+        "pos": {
+          "x": 129.0,
+          "y": 14.0
+        },
+        "params": 1
+      },
+      {
+        "id": "WireCrossPoint",
+        "name": "WireCrossPoint#4",
+        "pos": {
+          "x": 194.0,
+          "y": 74.0
+        },
+        "params": 1
+      },
+      {
+        "id": "or4",
+        "name": "or4#0",
+        "pos": {
+          "x": 25.0,
+          "y": 10.0
+        }
+      },
+      {
+        "id": "or4",
+        "name": "or4#1",
+        "pos": {
+          "x": 25.0,
+          "y": 55.0
+        }
+      },
+      {
+        "id": "or4",
+        "name": "or4#2",
+        "pos": {
+          "x": 25.0,
+          "y": 100.0
+        }
+      }
+    ],
+    "wires": [
+      {
+        "pin1": {
+          "compName": "_submodelinterface",
+          "pinName": "D"
+        },
+        "pin2": {
+          "compName": "Splitter#0",
+          "pinName": "I"
+        },
+        "name": "unnamedWire#0",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O11"
+        },
+        "pin2": {
+          "compName": "or4#0",
+          "pinName": "A1"
+        },
+        "name": "unnamedWire#1",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 20.0
+          },
+          {
+            "x": 20.0,
+            "y": 15.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "or4#0",
+          "pinName": "A2"
+        },
+        "pin2": {
+          "compName": "Splitter#0",
+          "pinName": "O10"
+        },
+        "name": "unnamedWire#2",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 25.0
+          },
+          {
+            "x": 20.0,
+            "y": 30.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "or4#0",
+          "pinName": "A3"
+        },
+        "pin2": {
+          "compName": "Splitter#0",
+          "pinName": "O9"
+        },
+        "name": "unnamedWire#3",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 35.0
+          },
+          {
+            "x": 20.0,
+            "y": 40.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O8"
+        },
+        "pin2": {
+          "compName": "or4#0",
+          "pinName": "A4"
+        },
+        "name": "unnamedWire#4",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 50.0
+          },
+          {
+            "x": 20.0,
+            "y": 45.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O7"
+        },
+        "pin2": {
+          "compName": "or4#1",
+          "pinName": "A1"
+        },
+        "name": "unnamedWire#5",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "or4#1",
+          "pinName": "A2"
+        },
+        "pin2": {
+          "compName": "Splitter#0",
+          "pinName": "O6"
+        },
+        "name": "unnamedWire#6",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O5"
+        },
+        "pin2": {
+          "compName": "or4#1",
+          "pinName": "A3"
+        },
+        "name": "unnamedWire#7",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "or4#1",
+          "pinName": "A4"
+        },
+        "pin2": {
+          "compName": "Splitter#0",
+          "pinName": "O4"
+        },
+        "name": "unnamedWire#8",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O3"
+        },
+        "pin2": {
+          "compName": "or4#2",
+          "pinName": "A1"
+        },
+        "name": "unnamedWire#9",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 100.0
+          },
+          {
+            "x": 20.0,
+            "y": 105.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O2"
+        },
+        "pin2": {
+          "compName": "or4#2",
+          "pinName": "A2"
+        },
+        "name": "unnamedWire#10",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 110.0
+          },
+          {
+            "x": 20.0,
+            "y": 115.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O1"
+        },
+        "pin2": {
+          "compName": "or4#2",
+          "pinName": "A3"
+        },
+        "name": "unnamedWire#11",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 120.0
+          },
+          {
+            "x": 20.0,
+            "y": 125.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "Splitter#0",
+          "pinName": "O0"
+        },
+        "pin2": {
+          "compName": "or4#2",
+          "pinName": "A4"
+        },
+        "name": "unnamedWire#12",
+        "path": [
+          {
+            "x": 20.0,
+            "y": 130.0
+          },
+          {
+            "x": 20.0,
+            "y": 135.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#3",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "WireCrossPoint#0",
+          "pinName": ""
+        },
+        "name": "unnamedWire#13",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#0",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#0",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#14",
+        "path": [
+          {
+            "x": 130.0,
+            "y": 80.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#0",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#0",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#15",
+        "path": [
+          {
+            "x": 130.0,
+            "y": 70.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "or4#1",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "WireCrossPoint#1",
+          "pinName": ""
+        },
+        "name": "unnamedWire#16",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#1",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#1",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#17",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#1",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#1",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#18",
+        "path": [
+          {
+            "x": 65.0,
+            "y": 70.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "or4#2",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "WireCrossPoint#2",
+          "pinName": ""
+        },
+        "name": "unnamedWire#19",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#2",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#2",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#20",
+        "path": [
+          {
+            "x": 65.0,
+            "y": 95.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#2",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#2",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#21",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#1",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "NandGate#3",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#22",
+        "path": [
+          {
+            "x": 95.0,
+            "y": 65.0
+          },
+          {
+            "x": 95.0,
+            "y": 70.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#2",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "NandGate#3",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#23",
+        "path": [
+          {
+            "x": 95.0,
+            "y": 100.0
+          },
+          {
+            "x": 95.0,
+            "y": 80.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#0",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "NandGate#5",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#24",
+        "path": [
+          {
+            "x": 160.0,
+            "y": 75.0
+          },
+          {
+            "x": 160.0,
+            "y": 80.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "or4#0",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "WireCrossPoint#3",
+          "pinName": ""
+        },
+        "name": "unnamedWire#25",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#3",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#4",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#26",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#3",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#4",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#27",
+        "path": [
+          {
+            "x": 130.0,
+            "y": 25.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#4",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "NandGate#5",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#28",
+        "path": [
+          {
+            "x": 160.0,
+            "y": 20.0
+          },
+          {
+            "x": 160.0,
+            "y": 70.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#5",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "WireCrossPoint#4",
+          "pinName": ""
+        },
+        "name": "unnamedWire#29",
+        "path": []
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#4",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#6",
+          "pinName": "A"
+        },
+        "name": "unnamedWire#30",
+        "path": [
+          {
+            "x": 195.0,
+            "y": 70.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "WireCrossPoint#4",
+          "pinName": ""
+        },
+        "pin2": {
+          "compName": "NandGate#6",
+          "pinName": "B"
+        },
+        "name": "unnamedWire#31",
+        "path": [
+          {
+            "x": 195.0,
+            "y": 80.0
+          }
+        ]
+      },
+      {
+        "pin1": {
+          "compName": "NandGate#6",
+          "pinName": "Y"
+        },
+        "pin2": {
+          "compName": "_submodelinterface",
+          "pinName": "Y"
+        },
+        "name": "unnamedWire#32",
+        "path": []
+      }
+    ],
+    "version": "0.1.1"
+  },
+  "symbolRendererSnippetID": "simpleRectangularLike",
+  "symbolRendererParams": {
+    "centerText": "nor12",
+    "centerTextHeight": 5.0,
+    "horizontalComponentCenter": 15.0,
+    "pinLabelHeight": 3.5,
+    "pinLabelMargin": 0.5
+  },
+  "outlineRendererSnippetID": "default",
+  "highLevelStateHandlerSnippetID": "default",
+  "version": "0.1.5"
+}
\ No newline at end of file
diff --git a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelnor12.java b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelnor12.java
deleted file mode 100644 (file)
index 4304d4a..0000000
+++ /dev/null
@@ -1,61 +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.wires.CoreWire.ReadEnd;
-import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
-import net.mograsim.logic.model.model.LogicModelModifiable;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedModelComponent;
-import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.model.wires.PinUsage;
-import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
-import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
-
-public class Modelnor12 extends SimpleRectangularHardcodedModelComponent
-{
-       public Modelnor12(LogicModelModifiable model, String name)
-       {
-               super(model, "nor12", name, "=0", false);
-               setSize(35, 20);
-               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
-               addPin(new Pin(model, this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
-
-               init();
-       }
-
-       @Override
-       public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
-       {
-               readWriteEnds.get("Y").feedSignals(getResult(readEnds.get("D").getValues().getBits()));
-               return null;
-       }
-
-       private static Bit getResult(Bit[] DValArr)
-       {
-               for (int i = 0; i < 12; i++)
-                       if (DValArr[i] == X)
-                               return X;
-               for (int i = 0; i < 12; i++)
-                       if (DValArr[i] == U)
-                               return U;
-               for (int i = 0; i < 12; i++)
-                       if (DValArr[i] == ONE)
-                               return ZERO;
-               for (int i = 0; i < 12; i++)
-                       if (DValArr[i] == Z)
-                               return X;
-               return ONE;
-       }
-
-       static
-       {
-               IndirectModelComponentCreator.setComponentSupplier(Modelnor12.class.getCanonicalName(), (m, p, n) -> new Modelnor12(m, n));
-       }
-}
\ No newline at end of file
index 04c7b2a..0f31466 100644 (file)
@@ -9,7 +9,6 @@
   "dff12": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modeldff12",
   "dff4_finewe": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modeldff4_finewe",
   "inc": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modelinc",
-  "nor12": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modelnor12",
   "ram5_12": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modelram5_12",
   "sel4_12": "resloader:Am2900Loader:class:net.mograsim.logic.model.am2900.components.Modelsel4_12",
   "Am2900": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json",
@@ -55,6 +54,7 @@
   "mux2": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/mux2.json",
   "mux3": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/mux3.json",
   "nand3": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/nand3.json",
+  "nor12": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/nor12.json",
   "not4": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/not4.json",
   "or4": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/or4.json",
   "or_4": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/or_4.json",
index 11b759e..491ea62 100644 (file)
@@ -27,7 +27,7 @@ public class ModelComponentTestbench
        {
                Am2900Loader.setup();
 //             ModelComponent comp = new StrictAm2900MachineDefinition().createNew(model).getAm2900();
-               ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "Am2910InstrPLA_");
+               ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "nor12");
 
                List<String> inputPinNames = new ArrayList<>();
                List<String> outputPinNames = new ArrayList<>();