Pins are now accessed via name, not index
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / examples / SubmodelComponentTestbench.java
index b2562ca..7218fec 100644 (file)
@@ -4,8 +4,8 @@ import net.mograsim.logic.ui.SimpleLogicUIStandalone;
 import net.mograsim.logic.ui.model.ViewModelModifiable;
 import net.mograsim.logic.ui.model.components.GUIBitDisplay;
 import net.mograsim.logic.ui.model.components.GUIManualSwitch;
-import net.mograsim.logic.ui.model.components.SubmodelComponent;
-import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdlatch4;
+import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
+import net.mograsim.logic.ui.model.components.mi.nandbased.am2901.GUIAm2901ALUInclDecode;
 import net.mograsim.logic.ui.model.wires.GUIWire;
 
 public class SubmodelComponentTestbench
@@ -18,21 +18,20 @@ public class SubmodelComponentTestbench
        @SuppressWarnings("unused") // for GUIWires being created
        public static void createTestbench(ViewModelModifiable model)
        {
-               SubmodelComponent comp = new GUIdlatch4(model);
-               int inputCount = 5;
+               SimpleRectangularSubmodelComponent comp = new GUIAm2901ALUInclDecode(model);
 
                comp.moveTo(100, 0);
-               for (int i = 0; i < inputCount; i++)
+               for (int i = 0; i < comp.getInputPinNames().size(); i++)
                {
                        GUIManualSwitch sw = new GUIManualSwitch(model);
                        sw.moveTo(0, 20 * i);
-                       new GUIWire(model, comp.getPins().get(i), sw.getOutputPin());
+                       new GUIWire(model, comp.getPin(comp.getInputPinNames().get(i)), sw.getOutputPin());
                }
-               for (int i = inputCount; i < comp.getPins().size(); i++)
+               for (int i = 0; i < comp.getOutputPinNames().size(); i++)
                {
                        GUIBitDisplay bd = new GUIBitDisplay(model);
-                       bd.moveTo(200, 20 * (i - inputCount));
-                       new GUIWire(model, comp.getPins().get(i), bd.getInputPin());
+                       bd.moveTo(200, 20 * i);
+                       new GUIWire(model, comp.getPin(comp.getOutputPinNames().get(i)), bd.getInputPin());
                }
        }
 }
\ No newline at end of file