Cleanup; Cleared warnings in the logic core
[Mograsim.git] / net.mograsim.logic.core / src / net / mograsim / logic / core / components / Mux.java
index 5e75f96..4980d77 100644 (file)
@@ -1,95 +1,95 @@
-package net.mograsim.logic.core.components;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import net.mograsim.logic.core.timeline.Timeline;
-import net.mograsim.logic.core.wires.Wire;
-import net.mograsim.logic.core.wires.Wire.ReadEnd;
-import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
-
-/**
- * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the
- * output.
- * 
- * @author Fabian Stemmler
- *
- */
-public class Mux extends BasicComponent
-{
-       private ReadEnd select;
-       private ReadWriteEnd out;
-       private ReadEnd[] inputs;
-       private final int outputSize;
-
-       /**
-        * Input {@link Wire}s and out must be of uniform length
-        * 
-        * @param out    Must be of uniform length with all inputs.
-        * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs.
-        * @param inputs One of these inputs is mapped to the output, depending on the select bits
-        */
-       public Mux(Timeline timeline, int processTime, ReadWriteEnd out, ReadEnd select, ReadEnd... inputs)
-       {
-               super(timeline, processTime);
-               outputSize = out.length();
-
-               this.inputs = inputs.clone();
-               for (int i = 0; i < this.inputs.length; i++)
-               {
-                       if (inputs[i].length() != outputSize)
-                               throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!");
-                       inputs[i].registerObserver(this);
-               }
-
-               this.select = select;
-               select.registerObserver(this);
-
-               int maxInputs = 1 << select.length();
-               if (this.inputs.length > maxInputs)
-                       throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by "
-                                       + select.length() + " select bits (" + maxInputs + ").");
-
-               this.out = out;
-       }
-
-       public ReadEnd getOut()
-       {
-               return out;
-       }
-
-       public ReadEnd getSelect()
-       {
-               return select;
-       }
-
-       @Override
-       public void compute()
-       {
-               int selectValue;
-               if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length)
-               {
-                       out.clearSignals();
-                       return;
-               }
-
-               ReadEnd active = inputs[selectValue];
-               out.feedSignals(active.getValues());
-       }
-
-       @Override
-       public List<ReadEnd> getAllInputs()
-       {
-               ArrayList<ReadEnd> wires = new ArrayList<ReadEnd>(Arrays.asList(inputs));
-               wires.add(select);
-               return Collections.unmodifiableList(wires);
-       }
-
-       @Override
-       public List<ReadWriteEnd> getAllOutputs()
-       {
-               return List.of(out);
-       }
-}
+package net.mograsim.logic.core.components;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import net.mograsim.logic.core.timeline.Timeline;\r
+import net.mograsim.logic.core.wires.Wire;\r
+import net.mograsim.logic.core.wires.Wire.ReadEnd;\r
+import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;\r
+\r
+/**\r
+ * Models a multiplexer. Takes an arbitrary amount of input {@link Wire}s, one of which, as determined by select, is put through to the\r
+ * output.\r
+ * \r
+ * @author Fabian Stemmler\r
+ *\r
+ */\r
+public class Mux extends BasicComponent\r
+{\r
+       private ReadEnd select;\r
+       private ReadWriteEnd out;\r
+       private ReadEnd[] inputs;\r
+       private final int outputSize;\r
+\r
+       /**\r
+        * Input {@link Wire}s and out must be of uniform length\r
+        * \r
+        * @param out    Must be of uniform length with all inputs.\r
+        * @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(Timeline timeline, int processTime, ReadWriteEnd out, ReadEnd select, ReadEnd... inputs)\r
+       {\r
+               super(timeline, processTime);\r
+               outputSize = out.length();\r
+\r
+               this.inputs = inputs.clone();\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].registerObserver(this);\r
+               }\r
+\r
+               this.select = select;\r
+               select.registerObserver(this);\r
+\r
+               int maxInputs = 1 << select.length();\r
+               if (this.inputs.length > maxInputs)\r
+                       throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by "\r
+                                       + select.length() + " select bits (" + maxInputs + ").");\r
+\r
+               this.out = out;\r
+       }\r
+\r
+       public ReadEnd getOut()\r
+       {\r
+               return out;\r
+       }\r
+\r
+       public ReadEnd getSelect()\r
+       {\r
+               return select;\r
+       }\r
+\r
+       @Override\r
+       public void compute()\r
+       {\r
+               int selectValue;\r
+               if (!select.hasNumericValue() || (selectValue = (int) select.getUnsignedValue()) >= inputs.length)\r
+               {\r
+                       out.clearSignals();\r
+                       return;\r
+               }\r
+\r
+               ReadEnd active = inputs[selectValue];\r
+               out.feedSignals(active.getValues());\r
+       }\r
+\r
+       @Override\r
+       public List<ReadEnd> getAllInputs()\r
+       {\r
+               ArrayList<ReadEnd> wires = new ArrayList<>(Arrays.asList(inputs));\r
+               wires.add(select);\r
+               return Collections.unmodifiableList(wires);\r
+       }\r
+\r
+       @Override\r
+       public List<ReadWriteEnd> getAllOutputs()\r
+       {\r
+               return List.of(out);\r
+       }\r
+}\r