X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=0a7133f2e0db4cbf508585363ad95b7c64aaae4b;hb=c18c04011cab0040c2287608eeefc9c3cc4536c2;hp=c21c47687d3589934ac81b5ba209dfe3838166c0;hpb=bcf8d773c7a836c2ee17e17a49c296ebf31d2777;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 c21c4768..0a7133f2 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -1,22 +1,23 @@ 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.wires.WireArray.WireArrayEnd; -public class TriStateBuffer extends BasicComponent{ +public class TriStateBuffer extends BasicComponent +{ WireArray in, enable; - WireArrayInput outI; - - public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) { + WireArrayEnd outI; + + public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) + { super(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) + 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 + "."); this.in = in; in.addObserver(this); @@ -24,11 +25,11 @@ public class TriStateBuffer extends BasicComponent{ enable.addObserver(this); outI = out.createInput(); } - + @Override protected void compute() { - if(enable.getValue() == Bit.ONE) + if (enable.getValue() == Bit.ONE) outI.feedSignals(in.getValues()); else outI.clearSignals(); @@ -37,13 +38,13 @@ public class TriStateBuffer extends BasicComponent{ @Override public List getAllInputs() { - return Collections.unmodifiableList(Arrays.asList(in, enable)); + return List.of(in, enable); } @Override public List getAllOutputs() { - return Collections.unmodifiableList(Arrays.asList(outI.owner)); + return List.of(outI.owner); } }