Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / examples / RSLatchExample.java
1 package net.mograsim.logic.model.examples;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.SimpleLogicUIStandalone;
5 import net.mograsim.logic.model.model.LogicModelModifiable;
6 import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch;
7 import net.mograsim.logic.model.model.components.atomic.ModelNotGate;
8 import net.mograsim.logic.model.model.components.atomic.ModelOrGate;
9 import net.mograsim.logic.model.model.wires.ModelWire;
10 import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
11
12 public class RSLatchExample
13 {
14         public static void main(String[] args)
15         {
16                 SimpleLogicUIStandalone.executeVisualisation(RSLatchExample::createRSLatchExample);
17         }
18
19         @SuppressWarnings("unused") // for Wires being created
20         public static void createRSLatchExample(LogicModelModifiable model)
21         {
22                 ModelManualSwitch rIn = new ModelManualSwitch(model, 1);
23                 rIn.moveTo(100, 100);
24                 ModelManualSwitch sIn = new ModelManualSwitch(model, 1);
25                 sIn.moveTo(100, 200);
26
27                 ModelOrGate or1 = new ModelOrGate(model, 1);
28                 or1.moveTo(160, 102.5);
29                 new ModelWire(model, rIn.getOutputPin(), or1.getPin("A"));
30
31                 ModelOrGate or2 = new ModelOrGate(model, 1);
32                 or2.moveTo(160, 192.5);
33                 new ModelWire(model, sIn.getOutputPin(), or2.getPin("B"));
34
35                 ModelNotGate not1 = new ModelNotGate(model, 1);
36                 not1.moveTo(200, 107.5);
37                 new ModelWire(model, or1.getPin("Y"), not1.getPin("A"));
38
39                 ModelNotGate not2 = new ModelNotGate(model, 1);
40                 not2.moveTo(200, 197.5);
41                 new ModelWire(model, or2.getPin("Y"), not2.getPin("A"));
42
43                 ModelWireCrossPoint p1 = new ModelWireCrossPoint(model, 1);
44                 p1.moveCenterTo(250, 112.5);
45                 new ModelWire(model, not1.getPin("Y"), p1);
46                 new ModelWire(model, p1, or2.getPin("A"), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
47
48                 ModelWireCrossPoint p2 = new ModelWireCrossPoint(model, 1);
49                 p2.moveCenterTo(250, 202.5);
50                 new ModelWire(model, not2.getPin("Y"), p2);
51                 new ModelWire(model, p2, or1.getPin("B"), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
52
53                 ModelWireCrossPoint o1 = new ModelWireCrossPoint(model, 1);
54                 o1.moveCenterTo(270, 112.5);
55                 new ModelWire(model, p1, o1);
56
57                 ModelWireCrossPoint o2 = new ModelWireCrossPoint(model, 1);
58                 o2.moveCenterTo(270, 202.5);
59                 new ModelWire(model, p2, o2);
60         }
61 }