package era.mi.logic.components;\r
\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
import java.util.List;\r
\r
import era.mi.logic.Bit;\r
-import era.mi.logic.wires.WireArray;\r
-import era.mi.logic.wires.WireArray.WireArrayInput;\r
+import era.mi.logic.wires.Wire.WireEnd;\r
\r
-public class TriStateBuffer extends BasicComponent {\r
- WireArray in, enable;\r
- WireArrayInput outI;\r
+public class TriStateBuffer extends BasicComponent\r
+{\r
+ WireEnd in, enable;\r
+ WireEnd out;\r
\r
- public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) {\r
+ public TriStateBuffer(int processTime, WireEnd in, WireEnd out, WireEnd enable)\r
+ {\r
super(processTime);\r
- if (in.length != out.length)\r
+ if (in.length() != out.length())\r
throw new IllegalArgumentException(\r
- "Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length);\r
- if (enable.length != 1)\r
- throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length + ".");\r
+ "Tri-state output must have the same amount of bits as the input. Input: " + in.length() + " Output: " + out.length());\r
+ if (enable.length() != 1)\r
+ throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length() + ".");\r
this.in = in;\r
in.addObserver(this);\r
this.enable = enable;\r
enable.addObserver(this);\r
- outI = out.createInput();\r
+ this.out = out;\r
}\r
\r
@Override\r
- protected void compute() {\r
+ protected void compute()\r
+ {\r
if (enable.getValue() == Bit.ONE)\r
- outI.feedSignals(in.getValues());\r
+ out.feedSignals(in.getValues());\r
else\r
- outI.clearSignals();\r
+ out.clearSignals();\r
}\r
\r
@Override\r
- public List<WireArray> getAllInputs() {\r
- return Collections.unmodifiableList(Arrays.asList(in, enable));\r
+ public List<WireEnd> getAllInputs()\r
+ {\r
+ return List.of(in, enable);\r
}\r
\r
@Override\r
- public List<WireArray> getAllOutputs() {\r
- return Collections.unmodifiableList(Arrays.asList(outI.owner));\r
+ public List<WireEnd> getAllOutputs()\r
+ {\r
+ return List.of(out);\r
}\r
\r
}\r