Did some clean up
[Mograsim.git] / era.mi / src / era / mi / logic / components / Mux.java
index d98e0f1..6ac32c6 100644 (file)
@@ -6,7 +6,7 @@ import java.util.Collections;
 import java.util.List;\r
 \r
 import era.mi.logic.wires.WireArray;\r
-import era.mi.logic.wires.WireArray.WireArrayInput;\r
+import era.mi.logic.wires.WireArray.WireArrayEnd;\r
 \r
 /**\r
  * Models a multiplexer. Takes an arbitrary amount of input {@link WireArray}s, one of which, as determined by select, is put through to the\r
@@ -15,9 +15,10 @@ import era.mi.logic.wires.WireArray.WireArrayInput;
  * @author Fabian Stemmler\r
  *\r
  */\r
-public class Mux extends BasicComponent {\r
+public class Mux extends BasicComponent\r
+{\r
        private WireArray select;\r
-       private WireArrayInput outI;\r
+       private WireArrayEnd outI;\r
        private WireArray[] inputs;\r
        private final int outputSize;\r
 \r
@@ -28,12 +29,14 @@ public class Mux extends BasicComponent {
         * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs.\r
         * @param inputs One of these inputs is mapped to the output, depending on the select bits\r
         */\r
-       public Mux(int processTime, WireArray out, WireArray select, WireArray... inputs) {\r
+       public Mux(int processTime, WireArray out, WireArray select, WireArray... inputs)\r
+       {\r
                super(processTime);\r
                outputSize = out.length;\r
 \r
                this.inputs = inputs.clone();\r
-               for (int i = 0; i < this.inputs.length; i++) {\r
+               for (int i = 0; i < this.inputs.length; i++)\r
+               {\r
                        if (inputs[i].length != outputSize)\r
                                throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!");\r
                        inputs[i].addObserver(this);\r
@@ -50,18 +53,22 @@ public class Mux extends BasicComponent {
                outI = out.createInput();\r
        }\r
 \r
-       public WireArray getOut() {\r
+       public WireArray getOut()\r
+       {\r
                return outI.owner;\r
        }\r
 \r
-       public WireArray getSelect() {\r
+       public WireArray getSelect()\r
+       {\r
                return select;\r
        }\r
 \r
        @Override\r
-       public void compute() {\r
+       public void compute()\r
+       {\r
                int selectValue;\r
-               if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length) {\r
+               if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length)\r
+               {\r
                        outI.clearSignals();\r
                        return;\r
                }\r
@@ -71,14 +78,16 @@ public class Mux extends BasicComponent {
        }\r
 \r
        @Override\r
-       public List<WireArray> getAllInputs() {\r
+       public List<WireArray> getAllInputs()\r
+       {\r
                ArrayList<WireArray> wires = new ArrayList<WireArray>(Arrays.asList(inputs));\r
                wires.add(select);\r
                return Collections.unmodifiableList(wires);\r
        }\r
 \r
        @Override\r
-       public List<WireArray> getAllOutputs() {\r
-               return Collections.unmodifiableList(Arrays.asList(outI.owner));\r
+       public List<WireArray> getAllOutputs()\r
+       {\r
+               return List.of(outI.owner);\r
        }\r
 }\r