X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FGUIComponentTestbench.java;h=66e321274103ff2c4e9d7d7aea4b5892e15191cf;hb=0dff0f06c05ad9b778c29d05b300b399937097e9;hp=b57522d2b1e7f6a8b46a7e0f3f0fd862f5021df3;hpb=755dd287af38d41b225e5976466111bc69249edb;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java index b57522d2..66e32127 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java @@ -5,7 +5,6 @@ import java.util.Comparator; import java.util.List; import net.mograsim.logic.model.SimpleLogicUIStandalone; -import net.mograsim.logic.model.am2900.components.am2910.GUIAm2910RegCntr; import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.model.components.GUIComponent; import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay; @@ -14,6 +13,7 @@ import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcod import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent.Usage; import net.mograsim.logic.model.model.wires.GUIWire; import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; public class GUIComponentTestbench { @@ -25,8 +25,7 @@ public class GUIComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { -// GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901", "Am2901"); - GUIComponent comp = new GUIAm2910RegCntr(model, "RegCntr"); + GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "file:components/am2904/GUIAm2904MSR.json"); // 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 @@ -42,7 +41,7 @@ public class GUIComponentTestbench outputPinNames.add(p.name); } else for (Pin p : comp.getPins().values()) - if (p.getRelX() == 0) + if (p.getRelX() < comp.getWidth()) inputPinNames.add(p.name); else outputPinNames.add(p.name); @@ -54,22 +53,16 @@ public class GUIComponentTestbench for (int i = 0; i < inputPinNames.size(); i++) { String pinName = inputPinNames.get(i); - if (comp.getPin(pinName).logicWidth == 1) - { - GUIManualSwitch sw = new GUIManualSwitch(model); - sw.moveTo(0, 20 * i); - new GUIWire(model, comp.getPin(pinName), sw.getOutputPin()); - } + GUIManualSwitch sw = new GUIManualSwitch(model, comp.getPin(pinName).logicWidth); + sw.moveTo(0, 20 * i); + new GUIWire(model, comp.getPin(pinName), sw.getOutputPin()); } for (int i = 0; i < outputPinNames.size(); i++) { String pinName = outputPinNames.get(i); - if (comp.getPin(pinName).logicWidth == 1) - { - GUIBitDisplay bd = new GUIBitDisplay(model); - bd.moveTo(200, 20 * i); - new GUIWire(model, comp.getPin(pinName), bd.getInputPin()); - } + GUIBitDisplay bd = new GUIBitDisplay(model, comp.getPin(pinName).logicWidth); + bd.moveTo(200, 20 * i); + new GUIWire(model, comp.getPin(pinName), bd.getInputPin()); } } } \ No newline at end of file