X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fui%2Fam2900%2FAm2901Testbench.java;fp=net.mograsim.logic.ui.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fui%2Fam2900%2FAm2901Testbench.java;h=3b2515edac3103d65ed2db46236f870acc66a9ce;hb=e4a201cb63e74fb7780dae482e2fc953bee58fa5;hp=0000000000000000000000000000000000000000;hpb=443acaf4a6470adf66a73cf0443852ce3843ebe2;p=Mograsim.git diff --git a/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/Am2901Testbench.java b/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/Am2901Testbench.java new file mode 100644 index 00000000..3b2515ed --- /dev/null +++ b/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/Am2901Testbench.java @@ -0,0 +1,86 @@ +package net.mograsim.logic.ui.am2900; + +import net.mograsim.logic.ui.SimpleLogicUIStandalone; +import net.mograsim.logic.ui.model.ViewModelModifiable; +import net.mograsim.logic.ui.model.components.GUIAndGate; +import net.mograsim.logic.ui.model.components.GUIBitDisplay; +import net.mograsim.logic.ui.model.components.GUIManualSwitch; +import net.mograsim.logic.ui.model.components.GUINotGate; +import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; +import net.mograsim.logic.ui.model.components.TextComponent; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff; +import net.mograsim.logic.ui.model.components.mi.nandbased.am2901.GUIAm2901; +import net.mograsim.logic.ui.model.wires.ConnectionPoint; +import net.mograsim.logic.ui.model.wires.WireCrossPoint; +import net.mograsim.logic.ui.util.ModellingTool; + +public class Am2901Testbench +{ + public static void main(String[] args) + { + SimpleLogicUIStandalone.executeVisualisation(Am2901Testbench::createTestbench); + } + + public static void createTestbench(ViewModelModifiable model) + { + SimpleRectangularSubmodelComponent comp = new GUIAm2901(model); + ModellingTool tool = ModellingTool.createFor(model); + + comp.moveTo(240, 0); + + GUIManualSwitch enable = new GUIManualSwitch(model); + 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); + tool.connect(wcp0, enable, ""); + tool.connect(wcp0, and, "A"); + tool.connect(wcp0, not1, "A"); + tool.connect(not1, not2, "Y", "A"); + tool.connect(not2, not3, "Y", "A"); + tool.connect(not3, and, "Y", "B"); + enable.moveTo(20, -32.5); + wcp0.moveTo(35, -26); + not1.moveTo(50, -20); + not2.moveTo(80, -20); + not3.moveTo(110, -20); + and.moveTo(135, -30); + ConnectionPoint last = and.getPin("Y"); + + for (int i = 0; i < comp.getInputPinNames().size(); i++) + { + double x = 55 + 70 * (i % 2); + double y = 10 * i; + + WireCrossPoint wcp = new WireCrossPoint(model, 1); + GUIdff d_ff = new GUIdff(model); + GUIManualSwitch sw = new GUIManualSwitch(model); + + tool.connect(last, wcp); + tool.connect(wcp, d_ff, "C"); + tool.connect(sw, d_ff, "", "D"); + tool.connect(d_ff, comp, "Q", comp.getInputPinNames().get(i)); + last = wcp.getPin(); + + TextComponent label = new TextComponent(model, comp.getInputPinNames().get(i)); + + sw.moveTo(x, y + 7.5); + wcp.moveTo(160, y); + d_ff.moveTo(170, y); + label.moveTo(x - 25, y + 15); + } + + for (int i = 0; i < comp.getOutputPinNames().size(); i++) + { + double x = 300 + 75 * (i % 2); + double y = 10 * i - 2.5; + GUIBitDisplay bd = new GUIBitDisplay(model); + bd.moveTo(x, y); + tool.connect(bd.getInputPin(), comp, comp.getOutputPinNames().get(i)); + + TextComponent label = new TextComponent(model, comp.getOutputPinNames().get(i)); + label.moveTo(x + 50, y + 8); + } + } +} \ No newline at end of file