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.GUIComponent;
6 import net.mograsim.logic.ui.model.components.atomic.GUIAndGate;
7 import net.mograsim.logic.ui.model.components.atomic.GUIBitDisplay;
8 import net.mograsim.logic.ui.model.components.atomic.GUIManualSwitch;
9 import net.mograsim.logic.ui.model.components.atomic.GUINotGate;
10 import net.mograsim.logic.ui.model.components.atomic.TextComponent;
11 import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff;
12 import net.mograsim.logic.ui.model.components.mi.nandbased.am2901.GUIAm2901;
13 import net.mograsim.logic.ui.model.components.submodels.SimpleRectangularSubmodelComponent;
14 import net.mograsim.logic.ui.model.wires.Pin;
15 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
16 import net.mograsim.logic.ui.util.ModellingTool;
18 public class Am2901Testbench
20 public static void main(String[] args)
22 SimpleLogicUIStandalone.executeVisualisation(Am2901Testbench::createTestbench);
25 public static void createTestbench(ViewModelModifiable model)
27 SimpleRectangularSubmodelComponent comp = new GUIAm2901(model);
28 ModellingTool tool = ModellingTool.createFor(model);
32 GUIManualSwitch enable = new GUIManualSwitch(model);
33 WireCrossPoint wcp0 = new WireCrossPoint(model, 1);
34 GUINotGate not1 = new GUINotGate(model, 1);
35 GUINotGate not2 = new GUINotGate(model, 1);
36 GUINotGate not3 = new GUINotGate(model, 1);
37 GUIAndGate and = new GUIAndGate(model, 1);
38 tool.connect(wcp0, enable, "");
39 tool.connect(wcp0, and, "A");
40 tool.connect(wcp0, not1, "A");
41 tool.connect(not1, not2, "Y", "A");
42 tool.connect(not2, not3, "Y", "A");
43 tool.connect(not3, and, "Y", "B");
44 enable.moveTo(20, -32.5);
48 not3.moveTo(110, -20);
50 Pin last = and.getPin("Y");
52 for (int i = 0; i < comp.getInputPinNames().size(); i++)
54 double x = 55 + 70 * (i % 2);
57 WireCrossPoint wcp = new WireCrossPoint(model, 1);
58 GUIComponent d_ff = new GUIdff(model);
59 GUIManualSwitch sw = new GUIManualSwitch(model);
61 tool.connect(last, wcp);
62 tool.connect(wcp, d_ff, "C");
63 tool.connect(sw, d_ff, "", "D");
64 tool.connect(d_ff, comp, "Q", comp.getInputPinNames().get(i));
67 TextComponent label = new TextComponent(model, comp.getInputPinNames().get(i));
69 sw.moveTo(x, y + 7.5);
72 label.moveTo(x - 25, y + 15);
75 for (int i = 0; i < comp.getOutputPinNames().size(); i++)
77 double x = 300 + 75 * (i % 2);
78 double y = 10 * i - 2.5;
79 GUIBitDisplay bd = new GUIBitDisplay(model);
81 tool.connect(bd.getInputPin(), comp, comp.getOutputPinNames().get(i));
83 TextComponent label = new TextComponent(model, comp.getOutputPinNames().get(i));
84 label.moveTo(x + 50, y + 8);