Timeline now passed via constructor
[Mograsim.git] / era.mi / src / era / mi / logic / wires / Wire.java
index 3a71a36..3d4fd90 100644 (file)
@@ -6,7 +6,7 @@ import static era.mi.logic.types.Bit.Z;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
-import era.mi.logic.Simulation;\r
+import era.mi.logic.timeline.Timeline;\r
 import era.mi.logic.types.Bit;\r
 import era.mi.logic.types.BitVector;\r
 import era.mi.logic.types.BitVector.BitVectorMutator;\r
@@ -24,12 +24,14 @@ public class Wire
        private List<ReadEnd> attached = new ArrayList<ReadEnd>();\r
        public final int length;\r
        private List<ReadWriteEnd> inputs = new ArrayList<ReadWriteEnd>();\r
+       private Timeline timeline;\r
 \r
-       public Wire(int length, int travelTime)\r
+       public Wire(Timeline timeline, int length, int travelTime)\r
        {\r
                if (length < 1)\r
                        throw new IllegalArgumentException(\r
                                        String.format("Tried to create an array of wires with length %d, but a length of less than 1 makes no sense.", length));\r
+               this.timeline = timeline;\r
                this.length = length;\r
                this.travelTime = travelTime;\r
                initValues();\r
@@ -379,7 +381,7 @@ public class Wire
                                                String.format("Attempted to input %d bits instead of %d bits.", newValues.length(), length));\r
                        if (!open)\r
                                throw new RuntimeException("Attempted to write to closed WireArrayEnd.");\r
-                       Simulation.TIMELINE.addEvent(e -> setValues(newValues), travelTime);\r
+                       timeline.addEvent(e -> setValues(newValues), travelTime);\r
                }\r
 \r
                /**\r
@@ -394,7 +396,7 @@ public class Wire
                {\r
                        if (!open)\r
                                throw new RuntimeException("Attempted to write to closed WireArrayEnd.");\r
-                       Simulation.TIMELINE.addEvent(e -> setValues(startingBit, bitVector), travelTime);\r
+                       timeline.addEvent(e -> setValues(startingBit, bitVector), travelTime);\r
                }\r
 \r
                private void setValues(int startingBit, BitVector newValues)\r