X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Fam2901%2FAm2901Testbench.java;h=414054e9fd32d98a2461ad1ace14271631f60864;hb=8bed58cd47f4e53a0a83e066d38864aa6875502f;hp=b54713e81ad0260fd1cf3300804df236fc3834ad;hpb=976f7f2be00457b5cda2489545635ccd076c9afd;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2901/Am2901Testbench.java b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2901/Am2901Testbench.java index b54713e8..414054e9 100644 --- a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2901/Am2901Testbench.java +++ b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2901/Am2901Testbench.java @@ -8,39 +8,42 @@ import net.mograsim.logic.core.types.Bit; import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.model.SimpleLogicUIStandalone; import net.mograsim.logic.model.SimpleLogicUIStandalone.VisualisationObjects; -import net.mograsim.logic.model.model.ViewModelModifiable; -import net.mograsim.logic.model.model.components.GUIComponent; -import net.mograsim.logic.model.model.components.atomic.GUIAndGate; -import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay; -import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch; -import net.mograsim.logic.model.model.components.atomic.GUINotGate; -import net.mograsim.logic.model.model.components.atomic.TextComponent; -import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; +import net.mograsim.logic.model.am2900.Am2900Loader; +import net.mograsim.logic.model.model.LogicModelModifiable; +import net.mograsim.logic.model.model.components.ModelComponent; +import net.mograsim.logic.model.model.components.atomic.ModelAndGate; +import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay; +import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch; +import net.mograsim.logic.model.model.components.atomic.ModelNotGate; +import net.mograsim.logic.model.model.components.atomic.ModelTextComponent; import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.model.wires.WireCrossPoint; -import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; +import net.mograsim.logic.model.model.wires.PinUsage; +import net.mograsim.logic.model.model.wires.ModelWireCrossPoint; +import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; import net.mograsim.logic.model.util.ModellingTool; +@Deprecated public class Am2901Testbench { public static void main(String[] args) { + Am2900Loader.setup(); SimpleLogicUIStandalone.executeVisualisation(Am2901Testbench::createTestbench, Am2901Testbench::beforeRun); } - public static void createTestbench(ViewModelModifiable model) + public static void createTestbench(LogicModelModifiable model) { - GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901"); + ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "Am2901"); ModellingTool tool = ModellingTool.createFor(model); comp.moveTo(240, 0); - GUIManualSwitch enable = new GUIManualSwitch(model, 1); - WireCrossPoint wcp0 = new WireCrossPoint(model, 1); - GUINotGate not1 = new GUINotGate(model, 1); - GUINotGate not2 = new GUINotGate(model, 1); - GUINotGate not3 = new GUINotGate(model, 1); - GUIAndGate and = new GUIAndGate(model, 1); + ModelManualSwitch enable = new ModelManualSwitch(model, 1); + ModelWireCrossPoint wcp0 = new ModelWireCrossPoint(model, 1); + ModelNotGate not1 = new ModelNotGate(model, 1); + ModelNotGate not2 = new ModelNotGate(model, 1); + ModelNotGate not3 = new ModelNotGate(model, 1); + ModelAndGate and = new ModelAndGate(model, 1); tool.connect(wcp0, enable, ""); tool.connect(wcp0, and, "A"); tool.connect(wcp0, not1, "A"); @@ -55,12 +58,10 @@ public class Am2901Testbench and.moveTo(135, -30); Pin last = and.getPin("Y"); - // 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 List inputPinNames = new ArrayList<>(); List outputPinNames = new ArrayList<>(); for (Pin p : comp.getPins().values()) - if (p.getRelX() == 0) + if (p.usage == PinUsage.INPUT) inputPinNames.add(p.name); else outputPinNames.add(p.name); @@ -73,9 +74,9 @@ public class Am2901Testbench double x = 55 + 70 * (i % 2); double y = 10 * i; - WireCrossPoint wcp = new WireCrossPoint(model, 1); - GUIComponent d_ff = IndirectGUIComponentCreator.createComponent(model, "GUIdff"); - GUIManualSwitch sw = new GUIManualSwitch(model, 1); + ModelWireCrossPoint wcp = new ModelWireCrossPoint(model, 1); + ModelComponent d_ff = IndirectModelComponentCreator.createComponent(model, "dff"); + ModelManualSwitch sw = new ModelManualSwitch(model, 1); tool.connect(last, wcp); tool.connect(wcp, d_ff, "C"); @@ -83,7 +84,7 @@ public class Am2901Testbench tool.connect(d_ff, comp, "Q", inputPinNames.get(i)); last = wcp.getPin(); - TextComponent label = new TextComponent(model, inputPinNames.get(i)); + ModelTextComponent label = new ModelTextComponent(model, inputPinNames.get(i)); sw.moveTo(x, y + 7.5); wcp.moveTo(160, y); @@ -95,22 +96,22 @@ public class Am2901Testbench { double x = 300 + 75 * (i % 2); double y = 10 * i - 2.5; - GUIBitDisplay bd = new GUIBitDisplay(model, 1); + ModelBitDisplay bd = new ModelBitDisplay(model, 1); bd.moveTo(x, y); tool.connect(bd.getInputPin(), comp, outputPinNames.get(i)); - TextComponent label = new TextComponent(model, outputPinNames.get(i)); + ModelTextComponent label = new ModelTextComponent(model, outputPinNames.get(i)); label.moveTo(x + 25, y); } } public static void beforeRun(VisualisationObjects vis) { - ((SubmodelComponent) vis.model.getComponentsByName().get("testbench")).submodel.getComponentsByName().values().forEach(c -> + vis.model.getComponentsByName().values().forEach(c -> { - if (c instanceof GUIManualSwitch) + if (c instanceof ModelManualSwitch) { - GUIManualSwitch cCasted = (GUIManualSwitch) c; + ModelManualSwitch cCasted = (ModelManualSwitch) c; cCasted.setHighLevelState("out", BitVector.of(Bit.ZERO, cCasted.logicWidth)); } });