X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWire.java;fp=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWire.java;h=9a1738773674c9dad5bde68cad62d6ba3f22a620;hb=6c67a9ff8361cd9fc082f40e2676f2c8b5911fe4;hp=823e03213ecf3e6822fc8c21c82a95f5f2aee21a;hpb=6d944b4deae46eef98beabdea0dab90c455e14a8;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/wires/Wire.java b/era.mi/src/era/mi/logic/wires/Wire.java index 823e0321..9a173877 100644 --- a/era.mi/src/era/mi/logic/wires/Wire.java +++ b/era.mi/src/era/mi/logic/wires/Wire.java @@ -6,7 +6,7 @@ import static era.mi.logic.types.Bit.Z; import java.util.ArrayList; import java.util.List; -import era.mi.logic.Simulation; +import era.mi.logic.timeline.Timeline; import era.mi.logic.types.Bit; import era.mi.logic.types.BitVector; import era.mi.logic.types.BitVector.BitVectorMutator; @@ -24,12 +24,14 @@ public class Wire private List attached = new ArrayList(); public final int length; private List inputs = new ArrayList(); + private Timeline timeline; - public Wire(int length, int travelTime) + public Wire(Timeline timeline, int length, int travelTime) { if (length < 1) throw new IllegalArgumentException( String.format("Tried to create an array of wires with length %d, but a length of less than 1 makes no sense.", length)); + this.timeline = timeline; this.length = length; this.travelTime = travelTime; initValues(); @@ -379,7 +381,7 @@ public class Wire String.format("Attempted to input %d bits instead of %d bits.", newValues.length(), length)); if (!open) throw new RuntimeException("Attempted to write to closed WireArrayEnd."); - Simulation.TIMELINE.addEvent(e -> setValues(newValues), travelTime); + timeline.addEvent(e -> setValues(newValues), travelTime); } /** @@ -394,7 +396,7 @@ public class Wire { if (!open) throw new RuntimeException("Attempted to write to closed WireArrayEnd."); - Simulation.TIMELINE.addEvent(e -> setValues(startingBit, bitVector), travelTime); + timeline.addEvent(e -> setValues(startingBit, bitVector), travelTime); } private void setValues(int startingBit, BitVector newValues)