X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FTriStateBuffer.java;h=a0e7a8b84ae3be40d8860fc3b53e943629168d1d;hb=74aebd92f41d03f4a44c9a455ef8c05465136412;hp=c21c47687d3589934ac81b5ba209dfe3838166c0;hpb=de79184d60c80d6775b368e61d3368de032952e8;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..a0e7a8b8 100644 --- a/era.mi/src/era/mi/logic/components/TriStateBuffer.java +++ b/era.mi/src/era/mi/logic/components/TriStateBuffer.java @@ -8,15 +8,16 @@ import era.mi.logic.Bit; import era.mi.logic.wires.WireArray; import era.mi.logic.wires.WireArray.WireArrayInput; -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) { 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,25 +25,22 @@ public class TriStateBuffer extends BasicComponent{ enable.addObserver(this); outI = out.createInput(); } - + @Override - protected void compute() - { - if(enable.getValue() == Bit.ONE) + protected void compute() { + if (enable.getValue() == Bit.ONE) outI.feedSignals(in.getValues()); else outI.clearSignals(); } @Override - public List getAllInputs() - { + public List getAllInputs() { return Collections.unmodifiableList(Arrays.asList(in, enable)); } @Override - public List getAllOutputs() - { + public List getAllOutputs() { return Collections.unmodifiableList(Arrays.asList(outI.owner)); }