X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=c0dd76e80b376efea81f2091e61ff5b986975b8b;hb=dcbba0b189fd37135adc4487f1b8b645e7045bc4;hp=5c02a4e347b1ba984a67d6c0788943d9ee09610f;hpb=4712d3e6ee08461b7754dbfba1c9e82372bb474d;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 5c02a4e3..c0dd76e8 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -1,52 +1,49 @@ 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.WireArrayEnd; +import era.mi.logic.types.Bit; +import era.mi.logic.wires.Wire.WireEnd; public class TriStateBuffer extends BasicComponent { - WireArray in, enable; - WireArrayEnd outI; + WireEnd in, enable; + WireEnd out; - public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) + public TriStateBuffer(int processTime, WireEnd in, WireEnd out, WireEnd enable) { super(processTime); - if (in.length != out.length) + 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() { if (enable.getValue() == Bit.ONE) - outI.feedSignals(in.getValues()); + out.feedSignals(in.getValues()); else - outI.clearSignals(); + out.clearSignals(); } @Override - public List getAllInputs() + public List getAllInputs() { - return Collections.unmodifiableList(Arrays.asList(in, enable)); + return List.of(in, enable); } @Override - public List getAllOutputs() + public List getAllOutputs() { - return Collections.unmodifiableList(Arrays.asList(outI.owner)); + return List.of(out); } }