From 374f20df48d4c20625cb50fb0e226de1647a655d Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 25 Mar 2020 19:10:54 +0100 Subject: [PATCH] Built a XNOR gate --- .../logic/model/am2900/components/xnor.json | 379 ++++++++++++++++++ .../am2900/standardComponentIDMapping.json | 1 + .../examples/ModelComponentTestbench.java | 5 +- 3 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/xnor.json diff --git a/plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/xnor.json b/plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/xnor.json new file mode 100644 index 00000000..176ee95a --- /dev/null +++ b/plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/xnor.json @@ -0,0 +1,379 @@ +{ + "width": 45.0, + "height": 20.0, + "interfacePins": [ + { + "location": { + "x": 0.0, + "y": 5.0 + }, + "name": "A", + "logicWidth": 1, + "usage": "INPUT" + }, + { + "location": { + "x": 0.0, + "y": 15.0 + }, + "name": "B", + "logicWidth": 1, + "usage": "INPUT" + }, + { + "location": { + "x": 45.0, + "y": 5.0 + }, + "name": "Y", + "logicWidth": 1, + "usage": "OUTPUT" + } + ], + "innerScale": 0.4, + "submodel": { + "components": [ + { + "id": "NandGate", + "name": "NandGate#0", + "pos": { + "x": 35.0, + "y": 2.5 + }, + "params": 1 + }, + { + "id": "NandGate", + "name": "NandGate#1", + "pos": { + "x": 35.0, + "y": 27.5 + }, + "params": 1 + }, + { + "id": "NandGate", + "name": "NandGate#2", + "pos": { + "x": 60.0, + "y": 2.5 + }, + "params": 1 + }, + { + "id": "NandGate", + "name": "NandGate#3", + "pos": { + "x": 10.0, + "y": 15.0 + }, + "params": 1 + }, + { + "id": "NandGate", + "name": "NandGate#4", + "pos": { + "x": 85.0, + "y": 2.5 + }, + "params": 1 + }, + { + "id": "WireCrossPoint", + "name": "WireCrossPoint#0", + "pos": { + "x": 31.5, + "y": 11.5 + }, + "params": 1 + }, + { + "id": "WireCrossPoint", + "name": "WireCrossPoint#1", + "pos": { + "x": 4.0, + "y": 36.5 + }, + "params": 1 + }, + { + "id": "WireCrossPoint", + "name": "WireCrossPoint#2", + "pos": { + "x": 4.0, + "y": 11.5 + }, + "params": 1 + }, + { + "id": "WireCrossPoint", + "name": "WireCrossPoint#3", + "pos": { + "x": 31.5, + "y": 36.5 + }, + "params": 1 + } + ], + "wires": [ + { + "pin1": { + "compName": "NandGate#0", + "pinName": "Y" + }, + "pin2": { + "compName": "NandGate#2", + "pinName": "A" + }, + "name": "unnamedWire#0", + "path": [ + { + "x": 57.5, + "y": 12.5 + }, + { + "x": 57.5, + "y": 7.5 + } + ] + }, + { + "pin1": { + "compName": "NandGate#1", + "pinName": "Y" + }, + "pin2": { + "compName": "NandGate#2", + "pinName": "B" + }, + "name": "unnamedWire#1", + "path": [ + { + "x": 57.5, + "y": 37.5 + }, + { + "x": 57.5, + "y": 17.5 + } + ] + }, + { + "pin1": { + "compName": "NandGate#2", + "pinName": "Y" + }, + "pin2": { + "compName": "NandGate#4", + "pinName": "A" + }, + "name": "unnamedWire#2", + "path": [ + { + "x": 82.5, + "y": 12.5 + }, + { + "x": 82.5, + "y": 7.5 + } + ] + }, + { + "pin1": { + "compName": "NandGate#3", + "pinName": "Y" + }, + "pin2": { + "compName": "NandGate#4", + "pinName": "B" + }, + "name": "unnamedWire#3", + "path": [ + { + "x": 82.5, + "y": 25.0 + }, + { + "x": 82.5, + "y": 17.5 + } + ] + }, + { + "pin1": { + "compName": "WireCrossPoint#0", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#0", + "pinName": "A" + }, + "name": "unnamedWire#4", + "path": [ + { + "x": 32.5, + "y": 7.5 + } + ] + }, + { + "pin1": { + "compName": "_submodelinterface", + "pinName": "B" + }, + "pin2": { + "compName": "WireCrossPoint#1", + "pinName": "" + }, + "name": "unnamedWire#5", + "path": [] + }, + { + "pin1": { + "compName": "WireCrossPoint#0", + "pinName": "" + }, + "pin2": { + "compName": "WireCrossPoint#2", + "pinName": "" + }, + "name": "unnamedWire#6", + "path": [] + }, + { + "pin1": { + "compName": "WireCrossPoint#1", + "pinName": "" + }, + "pin2": { + "compName": "WireCrossPoint#3", + "pinName": "" + }, + "name": "unnamedWire#7", + "path": [] + }, + { + "pin1": { + "compName": "WireCrossPoint#2", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#3", + "pinName": "A" + }, + "name": "unnamedWire#8", + "path": [ + { + "x": 5.0, + "y": 20.0 + } + ] + }, + { + "pin1": { + "compName": "WireCrossPoint#0", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#0", + "pinName": "B" + }, + "name": "unnamedWire#9", + "path": [ + { + "x": 32.5, + "y": 17.5 + } + ] + }, + { + "pin1": { + "compName": "WireCrossPoint#1", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#3", + "pinName": "B" + }, + "name": "unnamedWire#10", + "path": [ + { + "x": 5.0, + "y": 30.0 + } + ] + }, + { + "pin1": { + "compName": "NandGate#4", + "pinName": "Y" + }, + "pin2": { + "compName": "_submodelinterface", + "pinName": "Y" + }, + "name": "unnamedWire#11", + "path": [] + }, + { + "pin1": { + "compName": "WireCrossPoint#3", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#1", + "pinName": "B" + }, + "name": "unnamedWire#12", + "path": [ + { + "x": 32.5, + "y": 42.5 + } + ] + }, + { + "pin1": { + "compName": "WireCrossPoint#3", + "pinName": "" + }, + "pin2": { + "compName": "NandGate#1", + "pinName": "A" + }, + "name": "unnamedWire#13", + "path": [ + { + "x": 32.5, + "y": 32.5 + } + ] + }, + { + "pin1": { + "compName": "_submodelinterface", + "pinName": "A" + }, + "pin2": { + "compName": "WireCrossPoint#2", + "pinName": "" + }, + "name": "unnamedWire#14", + "path": [] + } + ], + "version": "0.1.1" + }, + "symbolRendererSnippetID": "simpleRectangularLike", + "symbolRendererParams": { + "centerText": "xnor", + "centerTextHeight": 5.0, + "horizontalComponentCenter": 22.5, + "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/standardComponentIDMapping.json b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/standardComponentIDMapping.json index df563105..8e34e2e2 100644 --- a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/standardComponentIDMapping.json +++ b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/standardComponentIDMapping.json @@ -63,5 +63,6 @@ "sel1": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/sel1.json", "sel2_4": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/sel2_4.json", "sel3_4": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/sel3_4.json", + "xnor": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/xnor.json", "xor": "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/xor.json" } \ No newline at end of file diff --git a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ModelComponentTestbench.java b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ModelComponentTestbench.java index 2a72e4a4..81934503 100644 --- a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ModelComponentTestbench.java +++ b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ModelComponentTestbench.java @@ -6,7 +6,6 @@ import java.util.List; import net.mograsim.logic.model.SimpleLogicUIStandalone; import net.mograsim.logic.model.am2900.Am2900Loader; -import net.mograsim.logic.model.am2900.machine.StrictAm2900MachineDefinition; import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.components.ModelComponent; import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay; @@ -14,6 +13,7 @@ import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch; import net.mograsim.logic.model.model.wires.ModelWire; import net.mograsim.logic.model.model.wires.Pin; import net.mograsim.logic.model.model.wires.PinUsage; +import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; public class ModelComponentTestbench { @@ -26,7 +26,8 @@ public class ModelComponentTestbench public static void createTestbench(LogicModelModifiable model) { Am2900Loader.setup(); - ModelComponent comp = new StrictAm2900MachineDefinition().createNew(model).getAm2900(); +// ModelComponent comp = new StrictAm2900MachineDefinition().createNew(model).getAm2900(); + ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "xnor"); List inputPinNames = new ArrayList<>(); List outputPinNames = new ArrayList<>(); -- 2.17.1