X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=ee4205664d570568ac9314930d996e1ad95bd3a5;hb=b7ce41467a2cbd9f45554982730741810e99feaa;hp=4000ae66e1778fbc506a61def85d0ce19ce681c7;hpb=49f569b513c36e8ad421fd5a547bf34bd830652a;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 4000ae66..ee420566 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -1,33 +1,50 @@ package era.mi.logic.components; -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) { +import java.util.List; + +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 +{ + ReadEnd in, enable; + ReadWriteEnd out; + + public TriStateBuffer(int processTime, ReadEnd in, ReadWriteEnd out, ReadEnd 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 + "."); + 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(); + this.out = out; } - + @Override protected void compute() { - if(enable.getValue() == Bit.ONE) - outI.feedSignals(in.getValues()); + if (enable.getValue() == Bit.ONE) + out.feedSignals(in.getValues()); else - outI.clearSignals(); + out.clearSignals(); + } + + @Override + public List getAllInputs() + { + return List.of(in, enable); + } + + @Override + public List getAllOutputs() + { + return List.of(out); } }