Wires connected to a component now get deleted with the component
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 5 Sep 2019 18:33:46 +0000 (20:33 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 5 Sep 2019 18:33:46 +0000 (20:33 +0200)
31 files changed:
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modeldff12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modeldff4_finewe.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelinc12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelnor12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelram5_12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/Modelsel4_12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/ModelAm2904RegCTInstrDecode.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/ModelAm2904ShiftInstrDecode.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/ModelAm2910InstrPLA.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/ModelAm2910RegCntr.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/ModelAm2910SP.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/ReserializeJSONsSettingUsages.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/states/SelectionState.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/LogicModel.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/ModelComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelFixedOutput.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelManualSwitch.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelMerger.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelSplitter.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelTriStateBuffer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularModelGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SimpleRectangularSubmodelComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/ModelWireCrossPoint.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/MovablePin.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/Pin.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/LegacySubmodelComponentSerializer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/SubmodelComponentSerializer.java
net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java

index a3ec2f5..59aaf84 100644 (file)
@@ -24,9 +24,9 @@ public class Modeldff12 extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "dff12", name, "D flip flop\n12 bits");
                setSize(40, 20);
-               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 20), Position.TOP);
-               addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 10), Position.RIGHT);
-               addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 20, 20), Position.TOP);
+               addPin(new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 10), Position.RIGHT);
+               addPin(new Pin(model, this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
        }
 
        @Override
index 5b565ad..fcb355f 100644 (file)
@@ -26,19 +26,19 @@ public class Modeldff4_finewe extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "dff4_finewe", name, "D flip flop\n4 bits");
                setSize(35, 90);
-               addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "_WE1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
-               addPin(new Pin(this, "_WE2", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
-               addPin(new Pin(this, "_WE3", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
-               addPin(new Pin(this, "_WE4", 1, PinUsage.INPUT, 0, 45), Position.RIGHT);
-               addPin(new Pin(this, "D1", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
-               addPin(new Pin(this, "D2", 1, PinUsage.INPUT, 0, 65), Position.RIGHT);
-               addPin(new Pin(this, "D3", 1, PinUsage.INPUT, 0, 75), Position.RIGHT);
-               addPin(new Pin(this, "D4", 1, PinUsage.INPUT, 0, 85), Position.RIGHT);
-               addPin(new Pin(this, "Q1", 1, PinUsage.OUTPUT, 35, 5), Position.LEFT);
-               addPin(new Pin(this, "Q2", 1, PinUsage.OUTPUT, 35, 15), Position.LEFT);
-               addPin(new Pin(this, "Q3", 1, PinUsage.OUTPUT, 35, 25), Position.LEFT);
-               addPin(new Pin(this, "Q4", 1, PinUsage.OUTPUT, 35, 35), Position.LEFT);
+               addPin(new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "_WE1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+               addPin(new Pin(model, this, "_WE2", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+               addPin(new Pin(model, this, "_WE3", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
+               addPin(new Pin(model, this, "_WE4", 1, PinUsage.INPUT, 0, 45), Position.RIGHT);
+               addPin(new Pin(model, this, "D1", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
+               addPin(new Pin(model, this, "D2", 1, PinUsage.INPUT, 0, 65), Position.RIGHT);
+               addPin(new Pin(model, this, "D3", 1, PinUsage.INPUT, 0, 75), Position.RIGHT);
+               addPin(new Pin(model, this, "D4", 1, PinUsage.INPUT, 0, 85), Position.RIGHT);
+               addPin(new Pin(model, this, "Q1", 1, PinUsage.OUTPUT, 35, 5), Position.LEFT);
+               addPin(new Pin(model, this, "Q2", 1, PinUsage.OUTPUT, 35, 15), Position.LEFT);
+               addPin(new Pin(model, this, "Q3", 1, PinUsage.OUTPUT, 35, 25), Position.LEFT);
+               addPin(new Pin(model, this, "Q4", 1, PinUsage.OUTPUT, 35, 35), Position.LEFT);
        }
 
        @Override
index 7979ae3..2f4483a 100644 (file)
@@ -24,9 +24,9 @@ public class Modelinc12 extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "inc12", name, "Incrementer");
                setSize(40, 20);
-               addPin(new Pin(this, "A", 12, PinUsage.INPUT, 20, 20), Position.TOP);
-               addPin(new Pin(this, "CI", 1, PinUsage.INPUT, 40, 10), Position.LEFT);
-               addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "A", 12, PinUsage.INPUT, 20, 20), Position.TOP);
+               addPin(new Pin(model, this, "CI", 1, PinUsage.INPUT, 40, 10), Position.LEFT);
+               addPin(new Pin(model, this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
        }
 
        @Override
index 6ca7b14..758c17e 100644 (file)
@@ -24,8 +24,8 @@ public class Modelnor12 extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "nor12", name, "=0");
                setSize(35, 20);
-               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
-               addPin(new Pin(this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
+               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
+               addPin(new Pin(model, this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
        }
 
        @Override
index 5be6303..a381b0c 100644 (file)
@@ -28,12 +28,12 @@ public class Modelram5_12 extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "ram5_12", name, "RAM\n5 x 12 Bit");
                setSize(40, 40);
-               addPin(new Pin(this, "A", 3, PinUsage.INPUT, 10, 0), Position.BOTTOM);
-               addPin(new Pin(this, "B", 3, PinUsage.INPUT, 30, 0), Position.BOTTOM);
-               addPin(new Pin(this, "WE", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
-               addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 0, 30), Position.RIGHT);
-               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 40), Position.TOP);
+               addPin(new Pin(model, this, "A", 3, PinUsage.INPUT, 10, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "B", 3, PinUsage.INPUT, 30, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "WE", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+               addPin(new Pin(model, this, "Y", 12, PinUsage.OUTPUT, 0, 30), Position.RIGHT);
+               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 20, 40), Position.TOP);
        }
 
        @Override
index b13a4d0..3aa416d 100644 (file)
@@ -25,15 +25,15 @@ public class Modelsel4_12 extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "sel4_12", name, "4-way SEL\n12 bit");
                setSize(80, 40);
-               addPin(new Pin(this, "SA", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "SB", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
-               addPin(new Pin(this, "SC", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
-               addPin(new Pin(this, "SD", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
-               addPin(new Pin(this, "A", 12, PinUsage.INPUT, 10, 0), Position.BOTTOM);
-               addPin(new Pin(this, "B", 12, PinUsage.INPUT, 30, 0), Position.BOTTOM);
-               addPin(new Pin(this, "C", 12, PinUsage.INPUT, 50, 0), Position.BOTTOM);
-               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 70, 0), Position.BOTTOM);
-               addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 40, 40), Position.TOP);
+               addPin(new Pin(model, this, "SA", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "SB", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+               addPin(new Pin(model, this, "SC", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+               addPin(new Pin(model, this, "SD", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
+               addPin(new Pin(model, this, "A", 12, PinUsage.INPUT, 10, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "B", 12, PinUsage.INPUT, 30, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "C", 12, PinUsage.INPUT, 50, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 70, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "Y", 12, PinUsage.OUTPUT, 40, 40), Position.TOP);
        }
 
        @Override
index 999f8bf..e5cc1ea 100644 (file)
@@ -24,20 +24,20 @@ public class ModelAm2904RegCTInstrDecode extends SimpleRectangularHardcodedModel
        {
                super(model, "Am2904RegCTInstrDecode", name, "Instruction\ndecode");
                setSize(80, 80);
-               addPin(new Pin(this, "I12-11", 2, PinUsage.INPUT, 0, 30), Position.RIGHT);
-               addPin(new Pin(this, "I5-0", 6, PinUsage.INPUT, 0, 50), Position.RIGHT);
+               addPin(new Pin(model, this, "I12-11", 2, PinUsage.INPUT, 0, 30), Position.RIGHT);
+               addPin(new Pin(model, this, "I5-0", 6, PinUsage.INPUT, 0, 50), Position.RIGHT);
                // muSR MUX:
                // 00: 0
                // 01: 1
                // 10: M
                // 11: I
-               addPin(new Pin(this, "muSR_MUX", 2, PinUsage.OUTPUT, 80, 10), Position.LEFT);
-               addPin(new Pin(this, "muSR_OVRRET", 1, PinUsage.OUTPUT, 80, 20), Position.LEFT);
-               addPin(new Pin(this, "muSR_CINV", 1, PinUsage.OUTPUT, 80, 30), Position.LEFT);
-               addPin(new Pin(this, "muSR_WEZ", 1, PinUsage.OUTPUT, 80, 40), Position.LEFT);
-               addPin(new Pin(this, "muSR_WEC", 1, PinUsage.OUTPUT, 80, 50), Position.LEFT);
-               addPin(new Pin(this, "muSR_WEN", 1, PinUsage.OUTPUT, 80, 60), Position.LEFT);
-               addPin(new Pin(this, "muSR_WEOVR", 1, PinUsage.OUTPUT, 80, 70), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_MUX", 2, PinUsage.OUTPUT, 80, 10), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_OVRRET", 1, PinUsage.OUTPUT, 80, 20), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_CINV", 1, PinUsage.OUTPUT, 80, 30), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_WEZ", 1, PinUsage.OUTPUT, 80, 40), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_WEC", 1, PinUsage.OUTPUT, 80, 50), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_WEN", 1, PinUsage.OUTPUT, 80, 60), Position.LEFT);
+               addPin(new Pin(model, this, "muSR_WEOVR", 1, PinUsage.OUTPUT, 80, 70), Position.LEFT);
                // MSR MUX:
                // 000: 0
                // 001: 1
@@ -47,19 +47,19 @@ public class ModelAm2904RegCTInstrDecode extends SimpleRectangularHardcodedModel
                // 101: I, invert C
                // 110: Swap OVR and C
                // 111: _M
-               addPin(new Pin(this, "MSR_MUX", 3, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
-               addPin(new Pin(this, "OEN", 1, PinUsage.OUTPUT, 60, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "MSR_MUX", 3, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "OEN", 1, PinUsage.OUTPUT, 60, 0), Position.BOTTOM);
                // Y MUX:
                // 00: mu
                // 01: mu
                // 10: M
                // 11: I
-               addPin(new Pin(this, "Y_MUX", 2, PinUsage.OUTPUT, 10, 80), Position.TOP);
+               addPin(new Pin(model, this, "Y_MUX", 2, PinUsage.OUTPUT, 10, 80), Position.TOP);
                // CT MUX:
                // see Am2900 Family Data Book, Am2904, Table 4 (CT_MUX2-0 = I3-1)
-               addPin(new Pin(this, "CT_MUX", 3, PinUsage.OUTPUT, 30, 80), Position.TOP);
-               addPin(new Pin(this, "CT_INV", 1, PinUsage.OUTPUT, 40, 80), Position.TOP);
-               addPin(new Pin(this, "CT_EXP", 1, PinUsage.OUTPUT, 50, 80), Position.TOP);
+               addPin(new Pin(model, this, "CT_MUX", 3, PinUsage.OUTPUT, 30, 80), Position.TOP);
+               addPin(new Pin(model, this, "CT_INV", 1, PinUsage.OUTPUT, 40, 80), Position.TOP);
+               addPin(new Pin(model, this, "CT_EXP", 1, PinUsage.OUTPUT, 50, 80), Position.TOP);
                // C0 MUX:
                // 00xx: 0
                // 01xx: 1
@@ -68,7 +68,7 @@ public class ModelAm2904RegCTInstrDecode extends SimpleRectangularHardcodedModel
                // 1101: _muC
                // 1110: MC
                // 1111: _MC
-               addPin(new Pin(this, "C0_MUX", 4, PinUsage.OUTPUT, 70, 80), Position.TOP);
+               addPin(new Pin(model, this, "C0_MUX", 4, PinUsage.OUTPUT, 70, 80), Position.TOP);
        }
 
        @Override
index 74cdd44..ef7b2c1 100644 (file)
@@ -25,15 +25,15 @@ public class ModelAm2904ShiftInstrDecode extends SimpleRectangularHardcodedModel
        {
                super(model, "Am2904ShiftInstrDecode", name, "Shift \ninstruction\ndecode");
                setSize(60, 80);
-               addPin(new Pin(this, "I", 5, PinUsage.INPUT, 0, 25), Position.RIGHT);
-               addPin(new Pin(this, "_SE", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
+               addPin(new Pin(model, this, "I", 5, PinUsage.INPUT, 0, 25), Position.RIGHT);
+               addPin(new Pin(model, this, "_SE", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
                // SIO0 MUX:
                // 000: 0
                // 001: 1
                // 01x: SIOn
                // 10x: QIOn
                // 11x: MC
-               addPin(new Pin(this, "SIO0_MUX", 3, PinUsage.OUTPUT, 60, 5), Position.LEFT);
+               addPin(new Pin(model, this, "SIO0_MUX", 3, PinUsage.OUTPUT, 60, 5), Position.LEFT);
                // SIOn MUX:
                // 000: 0
                // 001: 1
@@ -43,28 +43,28 @@ public class ModelAm2904ShiftInstrDecode extends SimpleRectangularHardcodedModel
                // 101: MN
                // 110: IC
                // 111: IN xor IVOR
-               addPin(new Pin(this, "SIOn_MUX", 3, PinUsage.OUTPUT, 60, 15), Position.LEFT);
+               addPin(new Pin(model, this, "SIOn_MUX", 3, PinUsage.OUTPUT, 60, 15), Position.LEFT);
                // QIO0 MUX:
                // 000: 0
                // 001: 1
                // 01x: SIOn
                // 10x: QIOn
                // 11x: MC
-               addPin(new Pin(this, "QIO0_MUX", 3, PinUsage.OUTPUT, 60, 25), Position.LEFT);
+               addPin(new Pin(model, this, "QIO0_MUX", 3, PinUsage.OUTPUT, 60, 25), Position.LEFT);
                // QIOn MUX:
                // 000: 0
                // 001: 1
                // 01x: SIO0
                // 10x: QIO0
                // 11x: MN
-               addPin(new Pin(this, "QIOn_MUX", 3, PinUsage.OUTPUT, 60, 35), Position.LEFT);
-               addPin(new Pin(this, "OEn", 1, PinUsage.OUTPUT, 60, 45), Position.LEFT);
-               addPin(new Pin(this, "OE0", 1, PinUsage.OUTPUT, 60, 55), Position.LEFT);
+               addPin(new Pin(model, this, "QIOn_MUX", 3, PinUsage.OUTPUT, 60, 35), Position.LEFT);
+               addPin(new Pin(model, this, "OEn", 1, PinUsage.OUTPUT, 60, 45), Position.LEFT);
+               addPin(new Pin(model, this, "OE0", 1, PinUsage.OUTPUT, 60, 55), Position.LEFT);
                // 00: SIO0
                // 01: QIO0
                // 1x: SIOn
-               addPin(new Pin(this, "MC_MUX", 2, PinUsage.OUTPUT, 60, 65), Position.LEFT);
-               addPin(new Pin(this, "MC_EN", 1, PinUsage.OUTPUT, 60, 75), Position.LEFT);
+               addPin(new Pin(model, this, "MC_MUX", 2, PinUsage.OUTPUT, 60, 65), Position.LEFT);
+               addPin(new Pin(model, this, "MC_EN", 1, PinUsage.OUTPUT, 60, 75), Position.LEFT);
        }
 
        @Override
index 414c0a5..928578f 100644 (file)
@@ -23,20 +23,20 @@ public class ModelAm2910InstrPLA extends SimpleRectangularHardcodedModelComponen
        {
                super(model, "Am2910InstrPLA", name, "Instr.\nPLA");
                setSize(30, 85);
-               addPin(new Pin(this, "PASS", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "I", 4, PinUsage.INPUT, 0, 20), Position.RIGHT);
-               addPin(new Pin(this, "R=0", 1, PinUsage.INPUT, 15, 0), Position.BOTTOM);
-               addPin(new Pin(this, "_PL", 1, PinUsage.OUTPUT, 5, 85), Position.TOP);
-               addPin(new Pin(this, "_MAP", 1, PinUsage.OUTPUT, 15, 85), Position.TOP);
-               addPin(new Pin(this, "_VECT", 1, PinUsage.OUTPUT, 25, 85), Position.TOP);
-               addPin(new Pin(this, "RWE", 1, PinUsage.OUTPUT, 30, 5), Position.LEFT);
-               addPin(new Pin(this, "RDEC", 1, PinUsage.OUTPUT, 30, 15), Position.LEFT);
-               addPin(new Pin(this, "YD", 1, PinUsage.OUTPUT, 30, 25), Position.LEFT);
-               addPin(new Pin(this, "YR", 1, PinUsage.OUTPUT, 30, 35), Position.LEFT);
-               addPin(new Pin(this, "YF", 1, PinUsage.OUTPUT, 30, 45), Position.LEFT);
-               addPin(new Pin(this, "YmuPC", 1, PinUsage.OUTPUT, 30, 55), Position.LEFT);
-               addPin(new Pin(this, "STKI0", 1, PinUsage.OUTPUT, 30, 65), Position.LEFT);
-               addPin(new Pin(this, "STKI1", 1, PinUsage.OUTPUT, 30, 75), Position.LEFT);
+               addPin(new Pin(model, this, "PASS", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "I", 4, PinUsage.INPUT, 0, 20), Position.RIGHT);
+               addPin(new Pin(model, this, "R=0", 1, PinUsage.INPUT, 15, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "_PL", 1, PinUsage.OUTPUT, 5, 85), Position.TOP);
+               addPin(new Pin(model, this, "_MAP", 1, PinUsage.OUTPUT, 15, 85), Position.TOP);
+               addPin(new Pin(model, this, "_VECT", 1, PinUsage.OUTPUT, 25, 85), Position.TOP);
+               addPin(new Pin(model, this, "RWE", 1, PinUsage.OUTPUT, 30, 5), Position.LEFT);
+               addPin(new Pin(model, this, "RDEC", 1, PinUsage.OUTPUT, 30, 15), Position.LEFT);
+               addPin(new Pin(model, this, "YD", 1, PinUsage.OUTPUT, 30, 25), Position.LEFT);
+               addPin(new Pin(model, this, "YR", 1, PinUsage.OUTPUT, 30, 35), Position.LEFT);
+               addPin(new Pin(model, this, "YF", 1, PinUsage.OUTPUT, 30, 45), Position.LEFT);
+               addPin(new Pin(model, this, "YmuPC", 1, PinUsage.OUTPUT, 30, 55), Position.LEFT);
+               addPin(new Pin(model, this, "STKI0", 1, PinUsage.OUTPUT, 30, 65), Position.LEFT);
+               addPin(new Pin(model, this, "STKI1", 1, PinUsage.OUTPUT, 30, 75), Position.LEFT);
        }
 
        @Override
index 193b58b..f300e6f 100644 (file)
@@ -24,12 +24,12 @@ public class ModelAm2910RegCntr extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "Am2910RegCntr", name, "Register/\nCounter");
                setSize(40, 40);
-               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 0), Position.BOTTOM);
-               addPin(new Pin(this, "_RLD", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "WE", 1, PinUsage.INPUT, 0, 20), Position.RIGHT);
-               addPin(new Pin(this, "DEC", 1, PinUsage.INPUT, 0, 30), Position.RIGHT);
-               addPin(new Pin(this, "C", 1, PinUsage.INPUT, 40, 20), Position.LEFT);
-               addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 40), Position.TOP);
+               addPin(new Pin(model, this, "D", 12, PinUsage.INPUT, 20, 0), Position.BOTTOM);
+               addPin(new Pin(model, this, "_RLD", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "WE", 1, PinUsage.INPUT, 0, 20), Position.RIGHT);
+               addPin(new Pin(model, this, "DEC", 1, PinUsage.INPUT, 0, 30), Position.RIGHT);
+               addPin(new Pin(model, this, "C", 1, PinUsage.INPUT, 40, 20), Position.LEFT);
+               addPin(new Pin(model, this, "Y", 12, PinUsage.OUTPUT, 20, 40), Position.TOP);
        }
 
        @Override
index a4491d2..dbcfa06 100644 (file)
@@ -24,12 +24,12 @@ public class ModelAm2910SP extends SimpleRectangularHardcodedModelComponent
        {
                super(model, "Am2910SP", name, "Stack\npointer");
                setSize(40, 30);
-               addPin(new Pin(this, "STKI0", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
-               addPin(new Pin(this, "STKI1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
-               addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
-               addPin(new Pin(this, "A", 3, PinUsage.OUTPUT, 10, 30), Position.TOP);
-               addPin(new Pin(this, "B", 3, PinUsage.OUTPUT, 30, 30), Position.TOP);
-               addPin(new Pin(this, "_FULL", 1, PinUsage.OUTPUT, 40, 15), Position.LEFT);
+               addPin(new Pin(model, this, "STKI0", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+               addPin(new Pin(model, this, "STKI1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+               addPin(new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+               addPin(new Pin(model, this, "A", 3, PinUsage.OUTPUT, 10, 30), Position.TOP);
+               addPin(new Pin(model, this, "B", 3, PinUsage.OUTPUT, 30, 30), Position.TOP);
+               addPin(new Pin(model, this, "_FULL", 1, PinUsage.OUTPUT, 40, 15), Position.LEFT);
        }
 
        @Override
index a102f76..bd4d458 100644 (file)
@@ -77,11 +77,11 @@ public class ReserializeJSONsSettingUsages
        {
                Set<ModelWire> wiresConnectedToPin = comp.submodel.getWiresByName().values().stream()
                                .filter(w -> w.getPin1() == interfacePin || w.getPin2() == interfacePin).collect(Collectors.toSet());
-               wiresConnectedToPin.forEach(comp.getSubmodelModifiable()::destroyWire);
-               comp.removeSubmodelInterface(interfacePin.name);
-               comp.addSubmodelInterface(
-                               new MovablePin(comp, interfacePin.name, interfacePin.logicWidth, usage, interfacePin.getRelX(), interfacePin.getRelY()));
                LogicModelModifiable submodelModifiable = comp.getSubmodelModifiable();
+               wiresConnectedToPin.forEach(submodelModifiable::destroyWire);
+               comp.removeSubmodelInterface(interfacePin.name);
+               comp.addSubmodelInterface(new MovablePin(submodelModifiable, comp, interfacePin.name, interfacePin.logicWidth, usage,
+                               interfacePin.getRelX(), interfacePin.getRelY()));
                wiresConnectedToPin.forEach(w -> new ModelWire(submodelModifiable, w.getPin1(), w.getPin2()));
        }
 }
\ No newline at end of file
index 4a02db4..baa2eff 100644 (file)
@@ -104,8 +104,8 @@ public class SelectionState extends EditorState
                        {
                                try
                                {
-                                       Pin p = editor.toBeEdited.addSubmodelInterface(new MovablePin(editor.toBeEdited, result[0], Integer.parseInt(result[1]),
-                                                       PinUsage.valueOf(result[2]), clicked.x, clicked.y));
+                                       Pin p = editor.toBeEdited.addSubmodelInterface(new MovablePin(editor.getSubmodel(), editor.toBeEdited, result[0],
+                                                       Integer.parseInt(result[1]), PinUsage.valueOf(result[2]), clicked.x, clicked.y));
                                        editor.handleManager.getInterfacePinHandle(p).reqMove(clicked.x, clicked.y);
                                }
                                catch (NumberFormatException e)
index eb6f7ee..227d9b1 100644 (file)
@@ -75,7 +75,8 @@ public class LogicModel
        }
 
        /**
-        * Adds the given wire to the list of wires and calls all wireAddedListeners.
+        * Adds the given wire to the list of wires and calls all wireAddedListeners. Don't call this method from application code as it is
+        * automatically called in {@link ModelWire}'s constructor.
         * 
         * @author Daniel Kirschten
         */
index d2ead74..40ab62f 100644 (file)
@@ -79,7 +79,7 @@ public abstract class ModelComponent implements JSONSerializable
         */
        protected void destroyed()
        {
-               pinsByName.values().forEach(p -> pinRemovedListeners.forEach(l -> l.accept(p)));
+               pinsByName.values().forEach(this::removePinWithoutRedraw);
        }
 
        // pins
@@ -112,11 +112,16 @@ public abstract class ModelComponent implements JSONSerializable
         */
        protected void removePin(String name)
        {
-               Pin pin = pinsByName.remove(name);
-               callPinRemovedListeners(pin);
+               removePinWithoutRedraw(pinsByName.remove(name));
                model.requestRedraw();
        }
 
+       private void removePinWithoutRedraw(Pin pin)
+       {
+               pin.destroyed();
+               callPinRemovedListeners(pin);
+       }
+
        /**
         * Returns a collection of pins of this component.
         * 
index 9573b3d..6e65cb8 100644 (file)
@@ -43,7 +43,7 @@ public class ModelBitDisplay extends ModelComponent
                logicObs = (i) -> model.requestRedraw();
 
                setSize(width, height);
-               addPin(this.inputPin = new Pin(this, "", logicWidth, PinUsage.INPUT, 0, height / 2));
+               addPin(this.inputPin = new Pin(model, this, "", logicWidth, PinUsage.INPUT, 0, height / 2));
        }
 
        @Override
index 6bf2ecb..96a9d48 100644 (file)
@@ -50,7 +50,7 @@ public class ModelClock extends ModelComponent
                oc = new OrientationCalculator(params.orientation, width, height);
                setSize(oc.width(), oc.height());
 
-               this.outputPin = new Pin(this, "", 1, PinUsage.OUTPUT, oc.newX(width, height / 2), oc.newY(width, height / 2));
+               this.outputPin = new Pin(model, this, "", 1, PinUsage.OUTPUT, oc.newX(width, height / 2), oc.newY(width, height / 2));
                addPin(outputPin);
        }
 
index 2ff06f2..b889fad 100644 (file)
@@ -34,7 +34,7 @@ public class ModelFixedOutput extends ModelComponent
                super(model, name);
                this.bits = bits;
                setSize(width, height);
-               addPin(new Pin(this, "out", bits.length(), PinUsage.OUTPUT, width, height / 2));
+               addPin(new Pin(model, this, "out", bits.length(), PinUsage.OUTPUT, width, height / 2));
        }
 
        @Override
index 25d3a69..ff991e0 100644 (file)
@@ -46,7 +46,7 @@ public class ModelManualSwitch extends ModelComponent
                logicObs = (i) -> model.requestRedraw();
 
                setSize(width, height);
-               addPin(this.outputPin = new Pin(this, "", logicWidth, PinUsage.OUTPUT, width, height / 2));
+               addPin(this.outputPin = new Pin(model, this, "", logicWidth, PinUsage.OUTPUT, width, height / 2));
        }
 
        @Override
index fbea650..ec98d78 100644 (file)
@@ -41,8 +41,8 @@ public class ModelMerger extends ModelComponent
                setSize(width, (logicWidth - 1) * heightPerPin);
                double inputHeight = (logicWidth - 1) * heightPerPin;
                for (int i = 0; i < logicWidth; i++, inputHeight -= 10)
-                       addPin(new Pin(this, "I" + i, 1, PinUsage.TRISTATE, 0, inputHeight));
-               addPin(this.outputPin = new Pin(this, "O", logicWidth, PinUsage.TRISTATE, width, (logicWidth - 1) * heightPerPin / 2));
+                       addPin(new Pin(model, this, "I" + i, 1, PinUsage.TRISTATE, 0, inputHeight));
+               addPin(this.outputPin = new Pin(model, this, "O", logicWidth, PinUsage.TRISTATE, width, (logicWidth - 1) * heightPerPin / 2));
                inputEnds = new ReadEnd[logicWidth];
        }
 
index 24d6578..805831f 100644 (file)
@@ -39,10 +39,10 @@ public class ModelSplitter extends ModelComponent
                super(model, name);
                this.logicWidth = logicWidth;
                setSize(width, (logicWidth - 1) * heightPerPin);
-               addPin(this.inputPin = new Pin(this, "I", logicWidth, PinUsage.TRISTATE, 0, (logicWidth - 1) * heightPerPin / 2));
+               addPin(this.inputPin = new Pin(model, this, "I", logicWidth, PinUsage.TRISTATE, 0, (logicWidth - 1) * heightPerPin / 2));
                double outputHeight = (logicWidth - 1) * heightPerPin;
                for (int i = 0; i < logicWidth; i++, outputHeight -= 10)
-                       addPin(new Pin(this, "O" + i, 1, PinUsage.TRISTATE, width, outputHeight));
+                       addPin(new Pin(model, this, "O" + i, 1, PinUsage.TRISTATE, width, outputHeight));
                outputEnds = new ReadEnd[logicWidth];
        }
 
index 45e653c..6791aff 100644 (file)
@@ -48,9 +48,9 @@ public class ModelTriStateBuffer extends ModelComponent
                double hHalf = height / 2;
                double hQuar = height / 4;
 
-               this.input = new Pin(this, "IN", params.logicWidth, PinUsage.INPUT, oc.newX(0, hHalf), oc.newY(0, hHalf));
-               this.output = new Pin(this, "OUT", params.logicWidth, PinUsage.OUTPUT, oc.newX(width, hHalf), oc.newY(width, hHalf));
-               this.enable = new Pin(this, "EN", 1, PinUsage.INPUT, oc.newX(wHalf, hQuar), oc.newY(wHalf, hQuar));
+               this.input = new Pin(model, this, "IN", params.logicWidth, PinUsage.INPUT, oc.newX(0, hHalf), oc.newY(0, hHalf));
+               this.output = new Pin(model, this, "OUT", params.logicWidth, PinUsage.OUTPUT, oc.newX(width, hHalf), oc.newY(width, hHalf));
+               this.enable = new Pin(model, this, "EN", 1, PinUsage.INPUT, oc.newX(wHalf, hQuar), oc.newY(wHalf, hQuar));
                this.path = new double[] { oc.newX(0, 0), oc.newY(0, 0), oc.newX(width, hHalf), oc.newY(width, hHalf), oc.newX(0, height),
                                oc.newY(0, height) };
 
index ea16e4c..f455b3c 100644 (file)
@@ -36,7 +36,8 @@ public class SimpleRectangularModelGate extends ModelComponent
        private MovablePin outputPin;
        private final List<Pin> inputPins;
 
-       protected SimpleRectangularModelGate(LogicModelModifiable model, String id, String label, boolean isInverted, int logicWidth, String name)
+       protected SimpleRectangularModelGate(LogicModelModifiable model, String id, String label, boolean isInverted, int logicWidth,
+                       String name)
        {
                super(model, name);
                this.id = id;
@@ -44,7 +45,7 @@ public class SimpleRectangularModelGate extends ModelComponent
                this.logicWidth = logicWidth;
                this.isInverted = isInverted;
                this.rectWidth = width - (isInverted ? invertedCircleDiam : 0);
-               this.outputPin = new MovablePin(this, "Y", logicWidth, PinUsage.OUTPUT, width, 0);
+               this.outputPin = new MovablePin(model, this, "Y", logicWidth, PinUsage.OUTPUT, width, 0);
                addPin(outputPin);
                this.inputPins = new ArrayList<>();
                setInputCount(1);
@@ -61,7 +62,8 @@ public class SimpleRectangularModelGate extends ModelComponent
                        for (int i = oldInputCount; i < inputCount; i++)
                        {
                                // TODO what for more than 24 input pins?
-                               Pin pin = new Pin(this, String.valueOf((char) ('A' + i)), logicWidth, PinUsage.INPUT, 0, pinDistance / 2 + i * pinDistance);
+                               Pin pin = new Pin(model, this, String.valueOf((char) ('A' + i)), logicWidth, PinUsage.INPUT, 0,
+                                               pinDistance / 2 + i * pinDistance);
                                inputPins.add(pin);
                                addPin(pin);
                        }
index 5e01fe0..90c6fa5 100644 (file)
@@ -81,7 +81,8 @@ public class SimpleRectangularSubmodelComponent extends SubmodelComponent
                        String pinName = newPinNames[i];
                        int oldPinIndex = pinNamesListThisSide.indexOf(pinName);
                        if (oldPinIndex == -1)
-                               super.addSubmodelInterface(new MovablePin(this, pinName, logicWidth, usage, relX, pinDistance / 2 + i * pinDistance));
+                               super.addSubmodelInterface(
+                                               new MovablePin(model, this, pinName, logicWidth, usage, relX, pinDistance / 2 + i * pinDistance));
                        else
                                getSupermodelMovablePin(pinName).setRelPos(relX, pinDistance / 2 + i * pinDistance);
                }
index a08c093..4a2f46c 100644 (file)
@@ -159,7 +159,7 @@ public abstract class SubmodelComponent extends ModelComponent
                default:
                        throw new IllegalArgumentException("Unknown enum constant: " + supermodelPin.usage);
                }
-               MovablePin submodelPin = new MovablePin(submodelInterface, name, supermodelPin.logicWidth, submodelPinUsage,
+               MovablePin submodelPin = new MovablePin(model, submodelInterface, name, supermodelPin.logicWidth, submodelPinUsage,
                                supermodelPin.getRelX() / submodelScale, supermodelPin.getRelY() / submodelScale);
 
                submodelPin.addPinMovedListener(p ->
index 75b619d..0a63499 100644 (file)
@@ -58,7 +58,7 @@ public class ModelWireCrossPoint extends ModelComponent
                logicObs = (i) -> model.requestRedraw();
 
                setSize(CIRCLE_DIAM, CIRCLE_DIAM);
-               addPin(this.pin = new Pin(this, "", logicWidth, PinUsage.TRISTATE, CIRCLE_RADIUS, CIRCLE_RADIUS));
+               addPin(this.pin = new Pin(model, this, "", logicWidth, PinUsage.TRISTATE, CIRCLE_RADIUS, CIRCLE_RADIUS));
        }
 
        // pins
index 4ec62c7..c2291f8 100644 (file)
@@ -1,5 +1,6 @@
 package net.mograsim.logic.model.model.wires;
 
+import net.mograsim.logic.model.model.LogicModelModifiable;
 import net.mograsim.logic.model.model.components.ModelComponent;
 
 /**
@@ -9,9 +10,10 @@ import net.mograsim.logic.model.model.components.ModelComponent;
  */
 public class MovablePin extends Pin
 {
-       public MovablePin(ModelComponent component, String name, int logicWidth, PinUsage usage, double relX, double relY)
+       public MovablePin(LogicModelModifiable model, ModelComponent component, String name, int logicWidth, PinUsage usage, double relX,
+                       double relY)
        {
-               super(component, name, logicWidth, usage, relX, relY);
+               super(model, component, name, logicWidth, usage, relX, relY);
        }
 
        @Override
index eb8df88..11a6908 100644 (file)
@@ -1,11 +1,14 @@
 package net.mograsim.logic.model.model.wires;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 import java.util.function.Consumer;
 
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.mograsim.logic.model.model.LogicModelModifiable;
 import net.mograsim.logic.model.model.components.ModelComponent;
 
 /**
@@ -18,6 +21,10 @@ import net.mograsim.logic.model.model.components.ModelComponent;
  */
 public class Pin
 {
+       /**
+        * The {@link LogicModel} the component this pin belongs to is a part of.
+        */
+       private final LogicModelModifiable model;
        /**
         * The {@link ModelComponent} this pin belongs to.
         */
@@ -56,8 +63,9 @@ public class Pin
         * 
         * @author Daniel Kirschten
         */
-       public Pin(ModelComponent component, String name, int logicWidth, PinUsage usage, double relX, double relY)
+       public Pin(LogicModelModifiable model, ModelComponent component, String name, int logicWidth, PinUsage usage, double relX, double relY)
        {
+               this.model = model;
                this.component = component;
                this.name = name;
                this.logicWidth = logicWidth;
@@ -71,6 +79,19 @@ public class Pin
                component.addComponentMovedListener(c -> callPinMovedListeners());
        }
 
+       /**
+        * Destroys this pin by removing all wires connected to it from the model the component is a part of.<br>
+        * Don't call this method from application code as it is automatically called in {@link ModelComponent#removePin(String)}.
+        */
+       public void destroyed()
+       {
+               Set<ModelWire> connectedWires = new HashSet<>();
+               for (ModelWire w : model.getWiresByName().values())
+                       if (w.getPin1() == this || w.getPin2() == this)
+                               connectedWires.add(w);
+               connectedWires.forEach(model::destroyWire);
+       }
+
        // "graphical" operations
 
        /**
index 37b05a9..531913f 100644 (file)
@@ -173,8 +173,8 @@ public final class LegacySubmodelComponentSerializer
                comp.setSize(params.width, params.height);
                for (LegacyInterfacePinParams iPinParams : params.interfacePins)
                        // TRISTATE because we don't have a better choice
-                       comp.addSubmodelInterface(new MovablePin(comp, iPinParams.name, iPinParams.logicWidth, PinUsage.TRISTATE, iPinParams.location.x,
-                                       iPinParams.location.y));
+                       comp.addSubmodelInterface(new MovablePin(model, comp, iPinParams.name, iPinParams.logicWidth, PinUsage.TRISTATE,
+                                       iPinParams.location.x, iPinParams.location.y));
                LegacySubmodelParameters submodelParams = params.submodel;
                LogicModelModifiable submodelModifiable = comp.getSubmodelModifiable();
                Map<String, ModelComponent> componentsByName = submodelModifiable.getComponentsByName();
index ce770ac..b4b2ff9 100644 (file)
@@ -172,7 +172,7 @@ public final class SubmodelComponentSerializer
                comp.setSize(params.width, params.height);
                for (InterfacePinParams iPinParams : params.interfacePins)
                        // TRISTATE because we don't have a better choice
-                       comp.addSubmodelInterface(new MovablePin(comp, iPinParams.name, iPinParams.logicWidth,
+                       comp.addSubmodelInterface(new MovablePin(model, comp, iPinParams.name, iPinParams.logicWidth,
                                        hasUsageSerialized ? iPinParams.usage : PinUsage.TRISTATE, iPinParams.location.x, iPinParams.location.y));
                LogicModelModifiable submodelModifiable = comp.getSubmodelModifiable();
                LogicModelSerializer.deserialize(comp.getSubmodelModifiable(), params.submodel);
index 78bd16f..f874e46 100644 (file)
@@ -39,9 +39,9 @@ public class ModelMemoryWA extends ModelComponent
 
                setSize(width, height);
                //TODO check the usages
-               addPin(addrPin = new Pin(this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, 0, 10));
-               addPin(dataPin = new Pin(this, "D", definition.getCellWidth(), PinUsage.TRISTATE, 0, 30));
-               addPin(rWPin = new Pin(this, "RW", 1, PinUsage.INPUT, 0, 50));
+               addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, 0, 10));
+               addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, 0, 30));
+               addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, 0, 50));
        }
 
        public Pin getAddressPin()