1 package era.mi.logic.components;
5 import era.mi.logic.timeline.Timeline;
6 import era.mi.logic.types.Bit;
7 import era.mi.logic.wires.Wire.ReadEnd;
8 import era.mi.logic.wires.Wire.ReadWriteEnd;
10 public class TriStateBuffer extends BasicComponent
15 public TriStateBuffer(Timeline timeline, int processTime, ReadEnd in, ReadWriteEnd out, ReadEnd enable)
17 super(timeline, processTime);
18 if (in.length() != out.length())
19 throw new IllegalArgumentException(
20 "Tri-state output must have the same amount of bits as the input. Input: " + in.length() + " Output: " + out.length());
21 if (enable.length() != 1)
22 throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length() + ".");
26 enable.addObserver(this);
31 protected void compute()
33 if (enable.getValue() == Bit.ONE)
34 out.feedSignals(in.getValues());
40 public List<ReadEnd> getAllInputs()
42 return List.of(in, enable);
46 public List<ReadWriteEnd> getAllOutputs()