Reformatted everything. Eclipse built-in Linewrapping/Comments 140 chars
[Mograsim.git] / era.mi / src / era / mi / logic / components / gates / MultiInputGate.java
index b85939e..f7af52e 100644 (file)
@@ -9,25 +9,22 @@ import era.mi.logic.components.BasicComponent;
 import era.mi.logic.wires.WireArray;
 import era.mi.logic.wires.WireArray.WireArrayInput;
 
-public abstract class MultiInputGate extends BasicComponent
-{
+public abstract class MultiInputGate extends BasicComponent {
        protected WireArray[] in;
        protected WireArray out;
        protected WireArrayInput outI;
        protected final int length;
        protected Operation op;
-       
-       protected MultiInputGate(int processTime, Operation op, WireArray out, WireArray... in)
-       {
+
+       protected MultiInputGate(int processTime, Operation op, WireArray out, WireArray... in) {
                super(processTime);
                this.op = op;
                length = out.length;
                this.in = in.clone();
-               if(in.length < 1)
+               if (in.length < 1)
                        throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
-               for(WireArray w : in)
-               {
-                       if(w.length != length)
+               for (WireArray w : in) {
+                       if (w.length != length)
                                throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
                        w.addObserver(this);
                }
@@ -35,29 +32,24 @@ public abstract class MultiInputGate extends BasicComponent
                outI = out.createInput();
        }
 
-
        @Override
-       public List<WireArray> getAllInputs()
-       {
+       public List<WireArray> getAllInputs() {
                return Collections.unmodifiableList(Arrays.asList(in));
        }
 
        @Override
-       public List<WireArray> getAllOutputs()
-       {
+       public List<WireArray> getAllOutputs() {
                return Collections.unmodifiableList(Arrays.asList(out));
        }
-       
-       protected void compute()
-       {
+
+       protected void compute() {
                Bit[] result = in[0].getValues();
-               for(int i = 1; i < in.length; i++)
+               for (int i = 1; i < in.length; i++)
                        result = op.execute(result, in[i].getValues());
                outI.feedSignals(result);
        }
-       
-       protected interface Operation
-       {
+
+       protected interface Operation {
                public Bit[] execute(Bit[] a, Bit[] b);
        }
 }