X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWire.java;h=9a1738773674c9dad5bde68cad62d6ba3f22a620;hb=80bfbd8ebf0ad8a7ad98584544a0c73f43e6f3b6;hp=9dba1fe56b842e548938d3887b8c3d69f8596400;hpb=b7ce41467a2cbd9f45554982730741810e99feaa;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 9dba1fe5..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(); @@ -189,7 +191,7 @@ public class Wire /** * Create and register a {@link ReadWriteEnd} object, which is tied to this {@link Wire}. This {@link ReadWriteEnd} can be written to. */ - public ReadWriteEnd createEnd() + public ReadWriteEnd createReadWriteEnd() { return new ReadWriteEnd(); } @@ -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) @@ -484,7 +486,7 @@ public class Wire { ReadEnd[] inputs = new ReadEnd[w.length]; for (int i = 0; i < w.length; i++) - inputs[i] = w[i].createEnd(); + inputs[i] = w[i].createReadWriteEnd(); return inputs; } } \ No newline at end of file