Merge commit '28314e7a9a3c3ebfcc4db8e9f1875507063ae6e6' into development
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / am2901 / GUIAm2901QReg.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased.am2901;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
6 import net.mograsim.logic.ui.model.components.mi.nandbased.GUIand;
7 import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff;
8 import net.mograsim.logic.ui.model.wires.GUIWire;
9 import net.mograsim.logic.ui.model.wires.Pin;
10 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
11
12 public class GUIAm2901QReg extends SimpleRectangularSubmodelComponent
13 {
14         public GUIAm2901QReg(ViewModelModifiable model)
15         {
16                 super(model, 1, "GUIAm2901QReg");
17                 setSubmodelScale(.4);
18                 setInputPins("C", "WE", "D1", "D2", "D3", "D4");
19                 setOutputPins("Q1", "Q2", "Q3", "Q4");
20                 initSubmodelComponents();
21         }
22
23         @SuppressWarnings("unused") // for GUIWires being created
24         private void initSubmodelComponents()
25         {
26                 Pin C = getInputSubmodelPins().get(0);
27                 Pin WE = getInputSubmodelPins().get(1);
28                 Pin D1 = getInputSubmodelPins().get(2);
29                 Pin D2 = getInputSubmodelPins().get(3);
30                 Pin D3 = getInputSubmodelPins().get(4);
31                 Pin D4 = getInputSubmodelPins().get(5);
32                 Pin Q1 = getOutputSubmodelPins().get(0);
33                 Pin Q2 = getOutputSubmodelPins().get(1);
34                 Pin Q3 = getOutputSubmodelPins().get(2);
35                 Pin Q4 = getOutputSubmodelPins().get(3);
36
37                 GUIand and = new GUIand(submodelModifiable);
38                 GUIdff dff1 = new GUIdff(submodelModifiable);
39                 GUIdff dff2 = new GUIdff(submodelModifiable);
40                 GUIdff dff3 = new GUIdff(submodelModifiable);
41                 GUIdff dff4 = new GUIdff(submodelModifiable);
42
43                 WireCrossPoint cpC1 = new WireCrossPoint(submodelModifiable, 1);
44                 WireCrossPoint cpC2 = new WireCrossPoint(submodelModifiable, 1);
45                 WireCrossPoint cpC3 = new WireCrossPoint(submodelModifiable, 1);
46
47                 and.moveTo(5, 15);
48                 dff1.moveTo(50, 7.5);
49                 dff2.moveTo(50, 32.5);
50                 dff3.moveTo(50, 57.5);
51                 dff4.moveTo(50, 82.5);
52                 cpC1.moveCenterTo(42.5, 20);
53                 cpC2.moveCenterTo(42.5, 37.5);
54                 cpC3.moveCenterTo(42.5, 62.5);
55
56                 new GUIWire(submodelModifiable, C, and.getInputPins().get(0));
57                 new GUIWire(submodelModifiable, WE, and.getInputPins().get(1));
58                 new GUIWire(submodelModifiable, and.getOutputPins().get(0), cpC1, new Point[0]);
59                 new GUIWire(submodelModifiable, cpC1, dff1.getInputPins().get(0), new Point(42.5, 12.5));
60                 new GUIWire(submodelModifiable, cpC1, cpC2, new Point[0]);
61                 new GUIWire(submodelModifiable, cpC2, dff2.getInputPins().get(0), new Point[0]);
62                 new GUIWire(submodelModifiable, cpC2, cpC3, new Point[0]);
63                 new GUIWire(submodelModifiable, cpC3, dff3.getInputPins().get(0), new Point[0]);
64                 new GUIWire(submodelModifiable, cpC3, dff4.getInputPins().get(0), new Point(42.5, 87.5));
65                 new GUIWire(submodelModifiable, D1, dff1.getInputPins().get(1), new Point(17.5, 62.5), new Point(17.5, 42.5), new Point(45, 42.5),
66                                 new Point(45, 22.5));
67                 new GUIWire(submodelModifiable, D2, dff2.getInputPins().get(1), new Point(22.5, 87.5), new Point(22.5, 47.5));
68                 new GUIWire(submodelModifiable, D3, dff3.getInputPins().get(1), new Point(27.5, 112.5), new Point(27.5, 72.5));
69                 new GUIWire(submodelModifiable, D4, dff4.getInputPins().get(1), new Point(32.5, 137.5), new Point(32.5, 97.5));
70                 new GUIWire(submodelModifiable, dff1.getOutputPins().get(0), Q1, new Point[0]);
71                 new GUIWire(submodelModifiable, dff2.getOutputPins().get(0), Q2, new Point[0]);
72                 new GUIWire(submodelModifiable, dff3.getOutputPins().get(0), Q3, new Point[0]);
73                 new GUIWire(submodelModifiable, dff4.getOutputPins().get(0), Q4, new Point[0]);
74         }
75 }