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.Wire;
9 import era.mi.logic.wires.Wire.WireEnd;
11 public class TriStateBuffer extends BasicComponent
16 public TriStateBuffer(int processTime, WireEnd in, WireEnd out, WireEnd enable)
19 if (in.length() != out.length())
20 throw new IllegalArgumentException(
21 "Tri-state output must have the same amount of bits as the input. Input: " + in.length() + " Output: " + out.length());
22 if (enable.length() != 1)
23 throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length() + ".");
27 enable.addObserver(this);
32 protected void compute()
34 if (enable.getValue() == Bit.ONE)
35 out.feedSignals(in.getValues());
41 public List<WireEnd> getAllInputs()
43 return Collections.unmodifiableList(Arrays.asList(in, enable));
47 public List<WireEnd> getAllOutputs()
49 return Collections.unmodifiableList(Arrays.asList(out));