1 package net.mograsim.logic.ui.model.components.mi.nandbased;
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.SubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
11 public class GUIdff extends SubmodelComponent
13 private final Pin pinC;
14 private final Pin pinD;
15 private final Pin pinQ;
16 private final Pin pin_Q;
18 public GUIdff(ViewModelModifiable model)
20 super(model, "GUIdff");
24 Pin C = addSubmodelInterface(1, 0, 5);
25 Pin D = addSubmodelInterface(1, 0, 20);
26 Pin Q = addSubmodelInterface(1, 35, 5);
27 Pin _Q = addSubmodelInterface(1, 35, 20);
29 this.pinC = getSupermodelPin(C);
30 this.pinD = getSupermodelPin(D);
31 this.pinQ = getSupermodelPin(Q);
32 this.pin_Q = getSupermodelPin(_Q);
34 initSubmodelComponents(C, D, Q, _Q);
37 @SuppressWarnings("unused") // for GUIWires being created
38 private void initSubmodelComponents(Pin C, Pin D, Pin Q, Pin _Q)
40 GUI_rsLatch _rsLatch1 = new GUI_rsLatch(submodelModifiable);
41 GUInand3 nand3 = new GUInand3(submodelModifiable);
42 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
43 GUI_rsLatch _rsLatch2 = new GUI_rsLatch(submodelModifiable);
45 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
46 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
47 WireCrossPoint cp3 = new WireCrossPoint(submodelModifiable, 1);
48 WireCrossPoint cp4 = new WireCrossPoint(submodelModifiable, 1);
50 _rsLatch1.moveTo(40, 5);
53 _rsLatch2.moveTo(120, 35);
59 new GUIWire(submodelModifiable, C, cp1);
60 new GUIWire(submodelModifiable, cp1, _rsLatch1.getPin_R());
61 new GUIWire(submodelModifiable, cp1, nand3.getPinB(), new Point(10, 55));
62 new GUIWire(submodelModifiable, D, nand2.getInputPins().get(1));
63 new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2, new Point(65, 95), new Point(65, 75), new Point(20, 75));
64 new GUIWire(submodelModifiable, cp2, _rsLatch1.getPin_S(), new Point(20, 10));
65 new GUIWire(submodelModifiable, cp2, nand3.getPinC());
66 new GUIWire(submodelModifiable, _rsLatch1.getPin_Q(), cp3, new Point(100, 25));
67 new GUIWire(submodelModifiable, cp3, nand3.getPinA(), new Point(30, 35), new Point(30, 45));
68 new GUIWire(submodelModifiable, cp3, _rsLatch2.getPin_S(), new Point(100, 40));
69 new GUIWire(submodelModifiable, nand3.getPinY(), cp4);
70 new GUIWire(submodelModifiable, cp4, _rsLatch2.getPin_R());
71 new GUIWire(submodelModifiable, cp4, nand2.getInputPins().get(0), new Point(100, 80), new Point(30, 80),
73 new GUIWire(submodelModifiable, _rsLatch2.getPinQ(), Q, new Point(165, 40), new Point(165, 25));
74 new GUIWire(submodelModifiable, _rsLatch2.getPin_Q(), _Q, new Point(165, 55), new Point(165, 100));