Merge branch 'development' of
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / model / components / mi / nandbased / am2901 / GUIAm2901ALUOneBit.java
1 package net.mograsim.logic.model.model.components.mi.nandbased.am2901;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.model.ViewModelModifiable;
5 import net.mograsim.logic.model.model.components.atomic.GUINandGate;
6 import net.mograsim.logic.model.model.components.mi.nandbased.GUIand;
7 import net.mograsim.logic.model.model.components.mi.nandbased.GUIfulladder;
8 import net.mograsim.logic.model.model.components.mi.nandbased.GUImux1;
9 import net.mograsim.logic.model.model.components.mi.nandbased.GUIxor;
10 import net.mograsim.logic.model.model.components.submodels.SimpleRectangularSubmodelComponent;
11 import net.mograsim.logic.model.model.wires.GUIWire;
12 import net.mograsim.logic.model.model.wires.Pin;
13 import net.mograsim.logic.model.model.wires.WireCrossPoint;
14 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
15
16 public class GUIAm2901ALUOneBit extends SimpleRectangularSubmodelComponent
17 {
18         public GUIAm2901ALUOneBit(ViewModelModifiable model)
19         {
20                 this(model, null);
21         }
22
23         public GUIAm2901ALUOneBit(ViewModelModifiable model, String name)
24         {
25                 super(model, 1, "GUIAm2901ALUOneBit", name);
26                 setSubmodelScale(.2);
27                 setInputPins("Cin", "CoutE", "CinE", "R", "RN", "S", "SN", "FN", "L");
28                 setOutputPins("Cout", "F");
29                 initSubmodelComponents();
30         }
31
32         @SuppressWarnings("unused") // for GUIWires being created
33         private void initSubmodelComponents()
34         {
35                 Pin Cin = getSubmodelPin("Cin");
36                 Pin CoutE = getSubmodelPin("CoutE");
37                 Pin CinE = getSubmodelPin("CinE");
38                 Pin R = getSubmodelPin("R");
39                 Pin RN = getSubmodelPin("RN");
40                 Pin S = getSubmodelPin("S");
41                 Pin SN = getSubmodelPin("SN");
42                 Pin FN = getSubmodelPin("FN");
43                 Pin L = getSubmodelPin("L");
44                 Pin Cout = getSubmodelPin("Cout");
45                 Pin F = getSubmodelPin("F");
46
47                 GUIand Cinand = new GUIand(submodelModifiable);
48                 GUIxor Rxor = new GUIxor(submodelModifiable);
49                 GUIxor Sxor = new GUIxor(submodelModifiable);
50                 GUIfulladder add = new GUIfulladder(submodelModifiable);
51                 GUINandGate nand = new GUINandGate(submodelModifiable, 1);
52                 GUIand Coutand = new GUIand(submodelModifiable);
53                 GUImux1 Fsel = new GUImux1(submodelModifiable);
54                 GUIxor Fxor = new GUIxor(submodelModifiable);
55
56                 WireCrossPoint cpRXored = new WireCrossPoint(submodelModifiable, 1);
57                 WireCrossPoint cpSXored = new WireCrossPoint(submodelModifiable, 1);
58
59                 Cinand.moveTo(10, 20);
60                 Rxor.moveTo(10, 190);
61                 Sxor.moveTo(10, 290);
62                 add.moveTo(60, 20);
63                 nand.moveTo(60, 55);
64                 Coutand.moveTo(135, 20);
65                 Fsel.moveTo(90, 70);
66                 Fxor.moveTo(135, 70);
67                 cpRXored.moveCenterTo(50, 60);
68                 cpSXored.moveCenterTo(55, 70);
69
70                 new GUIWire(submodelModifiable, Cin, Cinand.getPin("A"), new Point[0]);
71                 new GUIWire(submodelModifiable, CoutE, Coutand.getPin("A"), new Point(5, 75), new Point(5, 10), new Point(130, 10),
72                                 new Point(130, 25));
73                 new GUIWire(submodelModifiable, CinE, Cinand.getPin("B"), new Point(7.5, 125), new Point(7.5, 35));
74                 new GUIWire(submodelModifiable, R, Rxor.getPin("A"));
75                 new GUIWire(submodelModifiable, RN, Rxor.getPin("B"));
76                 new GUIWire(submodelModifiable, S, Sxor.getPin("A"));
77                 new GUIWire(submodelModifiable, SN, Sxor.getPin("B"));
78                 new GUIWire(submodelModifiable, FN, Fxor.getPin("B"), new Point(130, 375), new Point(130, 85));
79                 new GUIWire(submodelModifiable, L, Fsel.getPin("S0"), new Point(87.5, 425), new Point(87.5, 75));
80                 new GUIWire(submodelModifiable, Cinand.getPin("Y"), add.getPin("A"), new Point[0]);
81                 new GUIWire(submodelModifiable, Rxor.getPin("Y"), cpRXored, new Point(50, 195));
82                 new GUIWire(submodelModifiable, cpRXored, add.getPin("B"), new Point(50, 35));
83                 new GUIWire(submodelModifiable, cpRXored, nand.getPin("A"), new Point[0]);
84                 new GUIWire(submodelModifiable, Sxor.getPin("Y"), cpSXored, new Point(55, 295));
85                 new GUIWire(submodelModifiable, cpSXored, add.getPin("C"), new Point(55, 45));
86                 new GUIWire(submodelModifiable, cpSXored, nand.getPin("B"), new Point[0]);
87                 new GUIWire(submodelModifiable, add.getPin("Y"), Fsel.getPin("I0"), new Point(100, 25), new Point(100, 65), new Point(85, 65),
88                                 new Point(85, 85));
89                 new GUIWire(submodelModifiable, add.getPin("Z"), Coutand.getPin("B"), new Point[0]);
90                 new GUIWire(submodelModifiable, nand.getPin("Y"), Fsel.getPin("I1"), new Point(82.5, 65), new Point(82.5, 95));
91                 new GUIWire(submodelModifiable, Fsel.getPin("Y"), Fxor.getPin("A"), new Point[0]);
92                 new GUIWire(submodelModifiable, Coutand.getPin("Y"), Cout, new Point[0]);
93                 new GUIWire(submodelModifiable, Fxor.getPin("Y"), F, new Point[0]);
94         }
95
96         static
97         {
98                 IndirectGUIComponentCreator.setComponentSupplier(GUIAm2901ALUOneBit.class.getCanonicalName(),
99                                 (m, p, n) -> new GUIAm2901ALUOneBit(m, n));
100         }
101 }