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