Added DeserializedSubmodelComponent Editor project
[Mograsim.git] / net.mograsim.logic.ui.am2900 / test / net / mograsim / logic / ui / am2900 / Am2901Testbench.java
1 package net.mograsim.logic.ui.am2900;
2
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;
16
17 public class Am2901Testbench
18 {
19         public static void main(String[] args)
20         {
21                 SimpleLogicUIStandalone.executeVisualisation(Am2901Testbench::createTestbench);
22         }
23
24         public static void createTestbench(ViewModelModifiable model)
25         {
26                 SimpleRectangularSubmodelComponent comp = new GUIAm2901(model);
27                 ModellingTool tool = ModellingTool.createFor(model);
28
29                 comp.moveTo(240, 0);
30
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);
44                 wcp0.moveTo(35, -26);
45                 not1.moveTo(50, -20);
46                 not2.moveTo(80, -20);
47                 not3.moveTo(110, -20);
48                 and.moveTo(135, -30);
49                 ConnectionPoint last = and.getPin("Y");
50
51                 for (int i = 0; i < comp.getInputPinNames().size(); i++)
52                 {
53                         double x = 55 + 70 * (i % 2);
54                         double y = 10 * i;
55
56                         WireCrossPoint wcp = new WireCrossPoint(model, 1);
57                         GUIdff d_ff = new GUIdff(model);
58                         GUIManualSwitch sw = new GUIManualSwitch(model);
59
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));
64                         last = wcp.getPin();
65
66                         TextComponent label = new TextComponent(model, comp.getInputPinNames().get(i));
67
68                         sw.moveTo(x, y + 7.5);
69                         wcp.moveTo(160, y);
70                         d_ff.moveTo(170, y);
71                         label.moveTo(x - 25, y + 15);
72                 }
73
74                 for (int i = 0; i < comp.getOutputPinNames().size(); i++)
75                 {
76                         double x = 300 + 75 * (i % 2);
77                         double y = 10 * i - 2.5;
78                         GUIBitDisplay bd = new GUIBitDisplay(model);
79                         bd.moveTo(x, y);
80                         tool.connect(bd.getInputPin(), comp, comp.getOutputPinNames().get(i));
81
82                         TextComponent label = new TextComponent(model, comp.getOutputPinNames().get(i));
83                         label.moveTo(x + 50, y + 8);
84                 }
85         }
86 }