X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=f672a2d82ea74aa37809e2b1aa5afc6afd79cc2a;hb=f2cd90fa2b844507bc9697d3af1f3e18aac80b37;hp=c21c47687d3589934ac81b5ba209dfe3838166c0;hpb=f2284b0dcfb187ed6473d0a9903eb99ef31d49c5;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..f672a2d8 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -1,49 +1,50 @@ -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; - -public class TriStateBuffer extends BasicComponent{ - WireArray in, enable; - WireArrayInput 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) - 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(); - } - - @Override - protected void compute() - { - if(enable.getValue() == Bit.ONE) - outI.feedSignals(in.getValues()); - else - outI.clearSignals(); - } - - @Override - public List getAllInputs() - { - return Collections.unmodifiableList(Arrays.asList(in, enable)); - } - - @Override - public List getAllOutputs() - { - return Collections.unmodifiableList(Arrays.asList(outI.owner)); - } - -} +package era.mi.logic.components; + +import java.util.List; + +import era.mi.logic.Bit; +import era.mi.logic.wires.WireArray; +import era.mi.logic.wires.WireArray.WireArrayEnd; + +public class TriStateBuffer extends BasicComponent +{ + WireArray in, 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) + 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(); + } + + @Override + protected void compute() + { + if (enable.getValue() == Bit.ONE) + outI.feedSignals(in.getValues()); + else + outI.clearSignals(); + } + + @Override + public List getAllInputs() + { + return List.of(in, enable); + } + + @Override + public List getAllOutputs() + { + return List.of(outI.owner); + } + +}