1 package era.mi.logic.components;
5 import era.mi.logic.types.Bit;
6 import era.mi.logic.wires.Wire.WireEnd;
8 public class TriStateBuffer extends BasicComponent
13 public TriStateBuffer(int processTime, WireEnd in, WireEnd out, WireEnd enable)
16 if (in.length() != out.length())
17 throw new IllegalArgumentException(
18 "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);
29 protected void compute()
31 if (enable.getValue() == Bit.ONE)
32 out.feedSignals(in.getValues());
38 public List<WireEnd> getAllInputs()
40 return List.of(in, enable);
44 public List<WireEnd> getAllOutputs()