fixed Connector and added some useful methods to WireArray and Util
[Mograsim.git] / era.mi / src / era / mi / logic / Util.java
index 6bca6d0..6aec884 100644 (file)
@@ -84,6 +84,29 @@ public final class Util
        }
        return out;
     }
+    
+    public static Bit[] arrayOfZ(int length)
+    {
+    Bit[] out = new Bit[length];
+    Arrays.fill(out, Bit.Z);
+    return out;
+    }
+    
+    /**
+     * uses the {@link Bit#combineWith(Bit)} method, does not create a new array,
+     * the result is stored in the fist array.
+     * 
+     * @author Christian Femers
+     */
+    public static Bit[] combineInto(Bit[] dest, Bit[] addition)
+    {
+    if (dest.length != addition.length)
+        throw new IllegalArgumentException("Bit Arrays were not of equal length.");
+    for (int i = 0; i < addition.length; i++) {
+           dest[i] = dest[i].combineWith(addition[i]);
+       }
+    return dest;
+    }
 
     interface BitOp
     {