Integrated new types, tests still work, not used yet
[Mograsim.git] / era.mi / src / era / mi / logic / components / TriStateBuffer.java
index 8a41424..0ab162f 100644 (file)
@@ -1,52 +1,49 @@
 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.WireArrayEnd;\r
+import era.mi.logic.types.Bit;\r
+import era.mi.logic.wires.Wire.WireEnd;\r
 \r
 public class TriStateBuffer extends BasicComponent\r
 {\r
-       WireArray in, enable;\r
-       WireArrayEnd outI;\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
        {\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
+       public List<WireEnd> getAllInputs()\r
        {\r
-               return Collections.unmodifiableList(Arrays.asList(in, enable));\r
+               return List.of(in, enable);\r
        }\r
 \r
        @Override\r
-       public List<WireArray> getAllOutputs()\r
+       public List<WireEnd> getAllOutputs()\r
        {\r
-               return Collections.unmodifiableList(Arrays.asList(outI.owner));\r
+               return List.of(out);\r
        }\r
 \r
 }\r