1 package era.mi.logic.components;
5 import era.mi.logic.Bit;
6 import era.mi.logic.wires.WireArray;
7 import era.mi.logic.wires.WireArray.WireArrayEnd;
9 public class TriStateBuffer extends BasicComponent
14 public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable)
17 if (in.length != out.length)
18 throw new IllegalArgumentException(
19 "Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length);
20 if (enable.length != 1)
21 throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length + ".");
25 enable.addObserver(this);
26 outI = out.createInput();
30 protected void compute()
32 if (enable.getValue() == Bit.ONE)
33 outI.feedSignals(in.getValues());
39 public List<WireArray> getAllInputs()
41 return List.of(in, enable);
45 public List<WireArray> getAllOutputs()
47 return List.of(outI.owner);