X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=123e2c54a709e6b52de375f4075e5fae151ab8ef;hb=6c67a9ff8361cd9fc082f40e2676f2c8b5911fe4;hp=a0e7a8b84ae3be40d8860fc3b53e943629168d1d;hpb=74aebd92f41d03f4a44c9a455ef8c05465136412;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/components/TriStateBuffer.java b/era.mi/src/era/mi/logic/components/TriStateBuffer.java index a0e7a8b8..123e2c54 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -1,47 +1,51 @@ package era.mi.logic.components; -import java.util.Arrays; -import java.util.Collections; import java.util.List; -import era.mi.logic.Bit; -import era.mi.logic.wires.WireArray; -import era.mi.logic.wires.WireArray.WireArrayInput; +import era.mi.logic.timeline.Timeline; +import era.mi.logic.types.Bit; +import era.mi.logic.wires.Wire.ReadEnd; +import era.mi.logic.wires.Wire.ReadWriteEnd; -public class TriStateBuffer extends BasicComponent { - WireArray in, enable; - WireArrayInput outI; +public class TriStateBuffer extends BasicComponent +{ + ReadEnd in, enable; + ReadWriteEnd out; - public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) { - super(processTime); - if (in.length != out.length) + public TriStateBuffer(Timeline timeline, int processTime, ReadEnd in, ReadWriteEnd out, ReadEnd enable) + { + super(timeline, processTime); + if (in.length() != out.length()) throw new IllegalArgumentException( - "Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length); - if (enable.length != 1) - throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length + "."); + "Tri-state output must have the same amount of bits as the input. Input: " + in.length() + " Output: " + out.length()); + if (enable.length() != 1) + throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length() + "."); this.in = in; in.addObserver(this); this.enable = enable; enable.addObserver(this); - outI = out.createInput(); + this.out = out; } @Override - protected void compute() { + protected void compute() + { if (enable.getValue() == Bit.ONE) - outI.feedSignals(in.getValues()); + out.feedSignals(in.getValues()); else - outI.clearSignals(); + out.clearSignals(); } @Override - public List getAllInputs() { - return Collections.unmodifiableList(Arrays.asList(in, enable)); + public List getAllInputs() + { + return List.of(in, enable); } @Override - public List getAllOutputs() { - return Collections.unmodifiableList(Arrays.asList(outI.owner)); + public List getAllOutputs() + { + return List.of(out); } }