1 package era.mi.logic.components;
5 import era.mi.logic.types.Bit;
6 import era.mi.logic.wires.Wire.ReadEnd;
7 import era.mi.logic.wires.Wire.ReadWriteEnd;
9 public class TriStateBuffer extends BasicComponent
14 public TriStateBuffer(int processTime, ReadEnd in, ReadWriteEnd out, ReadEnd 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);
30 protected void compute()
32 if (enable.getValue() == Bit.ONE)
33 out.feedSignals(in.getValues());
39 public List<ReadEnd> getAllInputs()
41 return List.of(in, enable);
45 public List<ReadWriteEnd> getAllOutputs()