From a807d568a22ff7281f82c186e0f8c4c197168fc6 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 5 Jun 2019 13:15:14 +0200 Subject: [PATCH] Implemented GUIdlatch --- .../examples/SubmodelComponentTestbench.java | 4 +- .../components/mi/nandbased/GUI_rsLatch.java | 1 - .../components/mi/nandbased/GUIdlatch.java | 84 +++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java index fae762b9..f63e1798 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java @@ -5,7 +5,7 @@ import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUIBitDisplay; import net.mograsim.logic.ui.model.components.GUIManualSwitch; import net.mograsim.logic.ui.model.components.SubmodelComponent; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdlatch; import net.mograsim.logic.ui.model.wires.GUIWire; public class SubmodelComponentTestbench @@ -18,7 +18,7 @@ public class SubmodelComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { - SubmodelComponent comp = new GUIdff(model); + SubmodelComponent comp = new GUIdlatch(model); int inputCount = 2; comp.moveTo(100, 0); diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java index 6f3e951e..b6f030cf 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java @@ -37,7 +37,6 @@ public class GUI_rsLatch extends SubmodelComponent @SuppressWarnings("unused") // for GUIWires being created private void initSubmodelComponents(Pin _S, Pin _R, Pin Q, Pin _Q) { - GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java new file mode 100644 index 00000000..1a9d3a0b --- /dev/null +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdlatch.java @@ -0,0 +1,84 @@ +package net.mograsim.logic.ui.model.components.mi.nandbased; + +import net.haspamelodica.swt.helper.swtobjectwrappers.Point; +import net.mograsim.logic.ui.model.ViewModelModifiable; +import net.mograsim.logic.ui.model.components.GUINandGate; +import net.mograsim.logic.ui.model.components.SubmodelComponent; +import net.mograsim.logic.ui.model.wires.GUIWire; +import net.mograsim.logic.ui.model.wires.Pin; +import net.mograsim.logic.ui.model.wires.WireCrossPoint; + +public class GUIdlatch extends SubmodelComponent +{ + private final Pin pinD; + private final Pin pinE; + private final Pin pinQ; + private final Pin pin_Q; + + public GUIdlatch(ViewModelModifiable model) + { + super(model, "GUIdlatch"); + setSize(35, 25); + setSubmodelScale(.4); + + Pin D = addSubmodelInterface(1, 0, 5); + Pin E = addSubmodelInterface(1, 0, 20); + Pin Q = addSubmodelInterface(1, 35, 5); + Pin _Q = addSubmodelInterface(1, 35, 20); + + this.pinD = getSupermodelPin(D); + this.pinE = getSupermodelPin(E); + this.pinQ = getSupermodelPin(Q); + this.pin_Q = getSupermodelPin(_Q); + + initSubmodelComponents(D, E, Q, _Q); + } + + @SuppressWarnings("unused") // for GUIWires being created + private void initSubmodelComponents(Pin D, Pin E, Pin Q, Pin _Q) + { + GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); + GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); + GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable); + + WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); + WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); + + nand1.moveTo(10, 7.5); + nand2.moveTo(15, 35); + _rsLatch.moveTo(45, 7.5); + cp1.moveTo(5, 50); + cp2.moveTo(35, 17.5); + + new GUIWire(submodelModifiable, D, nand1.getInputPins().get(0)); + new GUIWire(submodelModifiable, E, cp1.getPin()); + new GUIWire(submodelModifiable, cp1.getPin(), nand1.getInputPins().get(1), new Point(5, 22.5)); + new GUIWire(submodelModifiable, cp1.getPin(), nand2.getInputPins().get(1)); + new GUIWire(submodelModifiable, nand1.getOutputPin(), cp2.getPin()); + new GUIWire(submodelModifiable, cp2.getPin(), nand2.getInputPins().get(0), new Point(35, 30), new Point(10, 30), new Point(10, 40)); + new GUIWire(submodelModifiable, cp2.getPin(), _rsLatch.getPin_S(), new Point(35, 12.5)); + new GUIWire(submodelModifiable, nand2.getOutputPin(), _rsLatch.getPin_R(), new Point(40, 45), new Point(40, 27.5)); + new GUIWire(submodelModifiable, _rsLatch.getPinQ(), Q); + new GUIWire(submodelModifiable, _rsLatch.getPin_Q(), _Q, new Point(82.5, 27.5), new Point(82.5, 50)); + } + + public Pin getPinD() + { + return pinD; + } + + public Pin getPinE() + { + return pinE; + } + + public Pin getPinQ() + { + return pinQ; + } + + public Pin getPin_Q() + { + return pin_Q; + } +} \ No newline at end of file -- 2.17.1