1 package net.mograsim.logic.ui.am2900;
3 import net.mograsim.logic.ui.SimpleLogicUIStandalone;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.atomic.GUIAndGate;
6 import net.mograsim.logic.ui.model.components.atomic.GUIBitDisplay;
7 import net.mograsim.logic.ui.model.components.atomic.GUIManualSwitch;
8 import net.mograsim.logic.ui.model.components.atomic.GUINotGate;
9 import net.mograsim.logic.ui.model.components.atomic.TextComponent;
10 import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff;
11 import net.mograsim.logic.ui.model.components.mi.nandbased.am2901.GUIAm2901;
12 import net.mograsim.logic.ui.model.components.submodels.SimpleRectangularSubmodelComponent;
13 import net.mograsim.logic.ui.model.wires.ConnectionPoint;
14 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
15 import net.mograsim.logic.ui.util.ModellingTool;
17 public class Am2901Testbench
19 public static void main(String[] args)
21 SimpleLogicUIStandalone.executeVisualisation(Am2901Testbench::createTestbench);
24 public static void createTestbench(ViewModelModifiable model)
26 SimpleRectangularSubmodelComponent comp = new GUIAm2901(model);
27 ModellingTool tool = ModellingTool.createFor(model);
31 GUIManualSwitch enable = new GUIManualSwitch(model);
32 WireCrossPoint wcp0 = new WireCrossPoint(model, 1);
33 GUINotGate not1 = new GUINotGate(model, 1);
34 GUINotGate not2 = new GUINotGate(model, 1);
35 GUINotGate not3 = new GUINotGate(model, 1);
36 GUIAndGate and = new GUIAndGate(model, 1);
37 tool.connect(wcp0, enable, "");
38 tool.connect(wcp0, and, "A");
39 tool.connect(wcp0, not1, "A");
40 tool.connect(not1, not2, "Y", "A");
41 tool.connect(not2, not3, "Y", "A");
42 tool.connect(not3, and, "Y", "B");
43 enable.moveTo(20, -32.5);
47 not3.moveTo(110, -20);
49 ConnectionPoint last = and.getPin("Y");
51 for (int i = 0; i < comp.getInputPinNames().size(); i++)
53 double x = 55 + 70 * (i % 2);
56 WireCrossPoint wcp = new WireCrossPoint(model, 1);
57 GUIdff d_ff = new GUIdff(model);
58 GUIManualSwitch sw = new GUIManualSwitch(model);
60 tool.connect(last, wcp);
61 tool.connect(wcp, d_ff, "C");
62 tool.connect(sw, d_ff, "", "D");
63 tool.connect(d_ff, comp, "Q", comp.getInputPinNames().get(i));
66 TextComponent label = new TextComponent(model, comp.getInputPinNames().get(i));
68 sw.moveTo(x, y + 7.5);
71 label.moveTo(x - 25, y + 15);
74 for (int i = 0; i < comp.getOutputPinNames().size(); i++)
76 double x = 300 + 75 * (i % 2);
77 double y = 10 * i - 2.5;
78 GUIBitDisplay bd = new GUIBitDisplay(model);
80 tool.connect(bd.getInputPin(), comp, comp.getOutputPinNames().get(i));
82 TextComponent label = new TextComponent(model, comp.getOutputPinNames().get(i));
83 label.moveTo(x + 50, y + 8);