SimpleRectangularSubmodelComponent now supports pin names
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / am2901 / GUIAm2901ALUFuncDecode.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.GUINandGate;
6 import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.ui.model.components.mi.nandbased.GUIand;
8 import net.mograsim.logic.ui.model.components.mi.nandbased.GUInand3;
9 import net.mograsim.logic.ui.model.wires.GUIWire;
10 import net.mograsim.logic.ui.model.wires.Pin;
11 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
12
13 public class GUIAm2901ALUFuncDecode extends SimpleRectangularSubmodelComponent
14 {
15         public GUIAm2901ALUFuncDecode(ViewModelModifiable model)
16         {
17                 super(model, 1, "GUIAm2901ALUFuncDecode");
18                 setSubmodelScale(.25);
19                 setInputPins("I5", "I4", "I3");
20                 setOutputPins("CinE", "L", "SBE");
21                 initSubmodelComponents();
22         }
23
24         @SuppressWarnings("unused") // for GUIWires being created
25         private void initSubmodelComponents()
26         {
27                 Pin I5 = getInputSubmodelPins().get(0);
28                 Pin I4 = getInputSubmodelPins().get(1);
29                 Pin I3 = getInputSubmodelPins().get(2);
30                 Pin CinE = getOutputSubmodelPins().get(0);
31                 Pin L = getOutputSubmodelPins().get(1);
32                 Pin SBE = getOutputSubmodelPins().get(2);
33
34                 GUINandGate notI5 = new GUINandGate(submodelModifiable, 1);
35                 GUINandGate notI4 = new GUINandGate(submodelModifiable, 1);
36                 GUInand3 nandI4I3NotI5 = new GUInand3(submodelModifiable);
37                 GUINandGate nandI5NotI4 = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate nandI3I4 = new GUINandGate(submodelModifiable, 1);
39                 GUINandGate nandL = new GUINandGate(submodelModifiable, 1);
40                 GUIand andSBE = new GUIand(submodelModifiable);
41
42                 WireCrossPoint cpI51 = new WireCrossPoint(submodelModifiable, 1);
43                 WireCrossPoint cpI52 = new WireCrossPoint(submodelModifiable, 1);
44                 WireCrossPoint cpI41 = new WireCrossPoint(submodelModifiable, 1);
45                 WireCrossPoint cpI42 = new WireCrossPoint(submodelModifiable, 1);
46                 WireCrossPoint cpI43 = new WireCrossPoint(submodelModifiable, 1);
47                 WireCrossPoint cpI3 = new WireCrossPoint(submodelModifiable, 1);
48                 WireCrossPoint cpNotI51 = new WireCrossPoint(submodelModifiable, 1);
49                 WireCrossPoint cpNotI52 = new WireCrossPoint(submodelModifiable, 1);
50
51                 notI5.moveTo(15, 10);
52                 notI4.moveTo(15, 50);
53                 nandI4I3NotI5.moveTo(55, 10);
54                 nandI5NotI4.moveTo(55, 45);
55                 nandI3I4.moveTo(55, 70);
56                 nandL.moveTo(100, 50);
57                 andSBE.moveTo(100, 95);
58                 cpI51.moveCenterTo(5, 20);
59                 cpI52.moveCenterTo(5, 25);
60                 cpI41.moveCenterTo(10, 60);
61                 cpI42.moveCenterTo(10, 55);
62                 cpI43.moveCenterTo(10, 65);
63                 cpI3.moveCenterTo(50, 75);
64                 cpNotI51.moveCenterTo(40, 20);
65                 cpNotI52.moveCenterTo(40, 35);
66
67                 new GUIWire(submodelModifiable, I5, cpI51, new Point[0]);
68                 new GUIWire(submodelModifiable, cpI51, notI5.getInputPins().get(0), new Point(5, 15));
69                 new GUIWire(submodelModifiable, cpI51, cpI52, new Point[0]);
70                 new GUIWire(submodelModifiable, cpI52, notI5.getInputPins().get(1), new Point[0]);
71                 new GUIWire(submodelModifiable, cpI52, nandI5NotI4.getInputPins().get(0), new Point(5, 45), new Point(45, 45), new Point(45, 50));
72                 new GUIWire(submodelModifiable, I4, cpI41, new Point[0]);
73                 new GUIWire(submodelModifiable, cpI41, cpI42, new Point[0]);
74                 new GUIWire(submodelModifiable, cpI42, nandI4I3NotI5.getInputPins().get(0), new Point(10, 40), new Point(45, 40),
75                                 new Point(45, 15));
76                 new GUIWire(submodelModifiable, cpI42, notI4.getInputPins().get(0), new Point[0]);
77                 new GUIWire(submodelModifiable, cpI41, cpI43, new Point[0]);
78                 new GUIWire(submodelModifiable, cpI43, notI4.getInputPins().get(1), new Point[0]);
79                 new GUIWire(submodelModifiable, cpI43, nandI3I4.getInputPins().get(1), new Point(10, 85));
80                 new GUIWire(submodelModifiable, I3, cpI3, new Point(50, 100));
81                 new GUIWire(submodelModifiable, cpI3, nandI4I3NotI5.getInputPins().get(1), new Point(50, 25));
82                 new GUIWire(submodelModifiable, cpI3, nandI3I4.getInputPins().get(0), new Point[0]);
83                 new GUIWire(submodelModifiable, notI5.getOutputPin(), cpNotI51, new Point[0]);
84                 new GUIWire(submodelModifiable, cpNotI51, CinE, new Point(40, 5), new Point(115, 5), new Point(115, 20));
85                 new GUIWire(submodelModifiable, cpNotI51, cpNotI52, new Point[0]);
86                 new GUIWire(submodelModifiable, cpNotI52, nandI4I3NotI5.getInputPins().get(2), new Point[0]);
87                 new GUIWire(submodelModifiable, cpNotI52, andSBE.getInputPins().get(1), new Point(40, 110));
88                 new GUIWire(submodelModifiable, notI4.getOutputPin(), nandI5NotI4.getInputPins().get(1), new Point[0]);
89                 new GUIWire(submodelModifiable, nandI4I3NotI5.getOutputPins().get(0), nandL.getInputPins().get(0));
90                 new GUIWire(submodelModifiable, nandI5NotI4.getOutputPin(), nandL.getInputPins().get(1));
91                 new GUIWire(submodelModifiable, nandI3I4.getOutputPin(), andSBE.getInputPins().get(0));
92                 new GUIWire(submodelModifiable, nandL.getOutputPin(), L, new Point[0]);
93                 new GUIWire(submodelModifiable, andSBE.getOutputPins().get(0), SBE, new Point[0]);
94         }
95 }