From c9cca272f312bdea6cf661e861508fca2431a9d2 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sat, 10 Aug 2019 20:04:31 +0200 Subject: [PATCH] Made Am2910 components usable in Editor --- .../components/am2910/GUIAm2910.json | 122 ++++++++++++++++++ .../model/am2900/components/GUIdff12.java | 6 + .../model/am2900/components/GUIinc12.java | 5 + .../model/am2900/components/GUImux4_12.java | 14 +- .../model/am2900/components/GUInor12.java | 6 + .../model/am2900/components/GUIram5_12.java | 12 +- .../components/am2910/GUIAm2910InstrPLA.java | 7 + .../components/am2910/GUIAm2910RegCntr.java | 7 + .../am2900/components/am2910/GUIAm2910SP.java | 12 +- .../META-INF/MANIFEST.MF | 3 +- .../IndirectGUIComponentCreator.java | 1 + .../standardComponentIDMapping.json | 8 ++ 12 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 net.mograsim.logic.model.am2900/components/am2910/GUIAm2910.json diff --git a/net.mograsim.logic.model.am2900/components/am2910/GUIAm2910.json b/net.mograsim.logic.model.am2900/components/am2910/GUIAm2910.json new file mode 100644 index 00000000..0c246155 --- /dev/null +++ b/net.mograsim.logic.model.am2900/components/am2910/GUIAm2910.json @@ -0,0 +1,122 @@ +mograsim version: 0.1.3 +{ + "width": 35.0, + "height": 270.0, + "interfacePins": [ + { + "location": { + "x": 0.0, + "y": 45.0 + }, + "name": "_MAP", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 255.0 + }, + "name": "_CCEN", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 265.0 + }, + "name": "C", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 95.0 + }, + "name": "D", + "logicWidth": 12 + }, + { + "location": { + "x": 0.0, + "y": 55.0 + }, + "name": "_CI", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 65.0 + }, + "name": "_FULL", + "logicWidth": 1 + }, + { + "location": { + "x": 35.0, + "y": 85.0 + }, + "name": "_RLD", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 75.0 + }, + "name": "I", + "logicWidth": 4 + }, + { + "location": { + "x": 35.0, + "y": 115.0 + }, + "name": "Y", + "logicWidth": 12 + }, + { + "location": { + "x": 35.0, + "y": 65.0 + }, + "name": "_PL", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 105.0 + }, + "name": "_VECT", + "logicWidth": 1 + }, + { + "location": { + "x": 0.0, + "y": 85.0 + }, + "name": "_CC", + "logicWidth": 1 + } + ], + "submodel": { + "innerScale": 0.2, + "subComps": [], + "innerWires": [] + }, + "symbolRendererSnippetID": "class:net.mograsim.logic.model.snippets.symbolrenderers.SimpleRectangularLikeSymbolRenderer", + "symbolRendererParams": { + "centerText": "GUIAm2901", + "centerTextHeight": 5.0, + "horizontalComponentCenter": 17.5, + "pinLabelHeight": 3.5, + "pinLabelMargin": 0.5 + }, + "outlineRendererSnippetID": "class:net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer", + "highLevelStateHandlerSnippetID": "class:net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandler", + "highLevelStateHandlerParams": { + "subcomponentHighLevelStates": {}, + "atomicHighLevelStates": {} + } +} \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff12.java index 9cf4d97e..5dd2f961 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff12.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff12.java @@ -13,6 +13,7 @@ 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 GUIdff12 extends SimpleRectangularHardcodedGUIComponent @@ -46,4 +47,9 @@ public class GUIdff12 extends SimpleRectangularHardcodedGUIComponent return QC; } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIdff12.class.getCanonicalName(), (m, p, n) -> new GUIdff12(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java index 20925444..0b94583c 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java @@ -15,6 +15,7 @@ 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 GUIinc12 extends SimpleRectangularHardcodedGUIComponent @@ -69,4 +70,8 @@ public class GUIinc12 extends SimpleRectangularHardcodedGUIComponent return null; } + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIinc12.class.getCanonicalName(), (m, p, n) -> new GUIinc12(m, n)); + } } \ No newline at end of file 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 index af227da1..e43888ab 100644 --- 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 @@ -1,16 +1,21 @@ 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 static 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 GUImux4_12 extends SimpleRectangularHardcodedGUIComponent @@ -71,4 +76,9 @@ public class GUImux4_12 extends SimpleRectangularHardcodedGUIComponent 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/GUInor12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUInor12.java index 22800a31..61499945 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUInor12.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUInor12.java @@ -14,6 +14,7 @@ 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 GUInor12 extends SimpleRectangularHardcodedGUIComponent @@ -49,4 +50,9 @@ public class GUInor12 extends SimpleRectangularHardcodedGUIComponent return X; return ONE; } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUInor12.class.getCanonicalName(), (m, p, n) -> new GUInor12(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIram5_12.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIram5_12.java index 7dcea022..1bf80c80 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIram5_12.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIram5_12.java @@ -1,6 +1,10 @@ package net.mograsim.logic.model.am2900.components; -import static net.mograsim.logic.core.types.Bit.*; +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.Arrays; import java.util.Map; @@ -12,6 +16,7 @@ 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 GUIram5_12 extends SimpleRectangularHardcodedGUIComponent @@ -76,4 +81,9 @@ public class GUIram5_12 extends SimpleRectangularHardcodedGUIComponent // TODO maybe this is the wrong way around return (bits[0] == ONE ? 4 : 0) + (bits[1] == ONE ? 2 : 0) + (bits[2] == ONE ? 1 : 0); } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIram5_12.class.getCanonicalName(), (m, p, n) -> new GUIram5_12(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java index b112d032..ebd69f62 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java @@ -13,6 +13,7 @@ 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 GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent @@ -260,4 +261,10 @@ public class GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent } return null; } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIAm2910InstrPLA.class.getCanonicalName(), + (m, p, n) -> new GUIAm2910InstrPLA(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java index 3db7b9d7..3c1ca2e9 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java @@ -13,6 +13,7 @@ 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 GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent @@ -83,4 +84,10 @@ public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent return QC; } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIAm2910RegCntr.class.getCanonicalName(), + (m, p, n) -> new GUIAm2910RegCntr(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910SP.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910SP.java index b19e3bb0..c4b44f36 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910SP.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910SP.java @@ -1,7 +1,11 @@ package net.mograsim.logic.model.am2900.components.am2910; +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.ZERO; + import java.util.Map; -import static net.mograsim.logic.core.types.Bit.*; import net.mograsim.logic.core.types.Bit; import net.mograsim.logic.core.types.BitVector; @@ -10,6 +14,7 @@ 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 GUIAm2910SP extends SimpleRectangularHardcodedGUIComponent @@ -84,4 +89,9 @@ public class GUIAm2910SP extends SimpleRectangularHardcodedGUIComponent // TODO maybe this is the wrong way around return BitVector.of((i & 0b100) > 0 ? ONE : ZERO, (i & 0b10) > 0 ? ONE : ZERO, (i & 0b1) > 0 ? ONE : ZERO); } + + static + { + IndirectGUIComponentCreator.setComponentSupplier(GUIAm2910SP.class.getCanonicalName(), (m, p, n) -> new GUIAm2910SP(m, n)); + } } \ No newline at end of file diff --git a/net.mograsim.logic.model.editor/META-INF/MANIFEST.MF b/net.mograsim.logic.model.editor/META-INF/MANIFEST.MF index 728aa67e..d5222818 100644 --- a/net.mograsim.logic.model.editor/META-INF/MANIFEST.MF +++ b/net.mograsim.logic.model.editor/META-INF/MANIFEST.MF @@ -8,7 +8,8 @@ Export-Package: net.mograsim.logic.model.editor, net.mograsim.logic.model.editor.states, net.mograsim.logic.model.editor.ui Require-Bundle: net.mograsim.logic.model;bundle-version="0.1.0", - net.mograsim.preferences;bundle-version="0.1.0" + net.mograsim.preferences;bundle-version="0.1.0", + net.mograsim.logic.model.am2900;bundle-version="0.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: net.mograsim.logic.model.editor Bundle-Vendor: Mograsim Team diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java index 884e3ba8..090ca86d 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java @@ -99,6 +99,7 @@ public class IndirectGUIComponentCreator ComponentSupplier componentSupplier = componentSuppliers.get(className); if (componentSupplier != null) return componentSupplier.create(model, params, name); + throw new IllegalArgumentException("Component supplier not found for ID " + id + " (resolved: " + resolvedID + ")"); } else // we know id has to start with "file:" here // because standardComponentIDs only contains strings starting with "class:" or "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 d599c2f1..4b036ccf 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 @@ -34,5 +34,13 @@ mograsim version: 0.1.3 "GUIsel2_4": "file:components/GUIsel2_4.json", "GUIsel3_4": "file:components/GUIsel3_4.json", "GUIxor": "file:components/GUIxor.json", + "GUIAm2910InstrPLA": "class:net.mograsim.logic.model.am2900.components.am2910.GUIAm2910InstrPLA", + "GUIAm2910RegCntr": "class:net.mograsim.logic.model.am2900.components.am2910.GUIAm2910RegCntr", + "GUIAm2910SP": "class:net.mograsim.logic.model.am2900.components.am2910.GUIAm2910SP", + "GUIdff12": "class:net.mograsim.logic.model.am2900.components.GUIdff12", + "GUIinc12": "class:net.mograsim.logic.model.am2900.components.GUIinc12", + "GUImux4_12": "class:net.mograsim.logic.model.am2900.components.GUImux4_12", + "GUInor12": "class:net.mograsim.logic.model.am2900.components.GUInor12", + "GUIram5_12": "class:net.mograsim.logic.model.am2900.components.GUIram5_12", "WireCrossPoint": "class:net.mograsim.logic.model.model.wires.WireCrossPoint" } \ No newline at end of file -- 2.17.1