1 package era.mi.logic.components;
3 import java.util.Arrays;
4 import java.util.Collections;
7 import era.mi.logic.Bit;
8 import era.mi.logic.wires.WireArray;
9 import era.mi.logic.wires.WireArray.WireArrayInput;
11 public class TriStateBuffer extends BasicComponent{
15 public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) {
17 if(in.length != out.length)
18 throw new IllegalArgumentException("Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length);
19 if(enable.length != 1)
20 throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length + ".");
24 enable.addObserver(this);
25 outI = out.createInput();
29 protected void compute()
31 if(enable.getValue() == Bit.ONE)
32 outI.feedSignals(in.getValues());
38 public List<WireArray> getAllInputs()
40 return Collections.unmodifiableList(Arrays.asList(in, enable));
44 public List<WireArray> getAllOutputs()
46 return Collections.unmodifiableList(Arrays.asList(outI.owner));