X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWireArray.java;h=ca93fcb49866dd8ea34ecb9ec1d5322455324cd8;hb=f2cd90fa2b844507bc9697d3af1f3e18aac80b37;hp=7599a98ea9e1a400ff47d9c58cf6e109b5c256fd;hpb=7d3d8dd3ff0e8362195ed5bbbc7ec4bc9a9b2475;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/wires/WireArray.java b/era.mi/src/era/mi/logic/wires/WireArray.java index 7599a98e..ca93fcb4 100644 --- a/era.mi/src/era/mi/logic/wires/WireArray.java +++ b/era.mi/src/era/mi/logic/wires/WireArray.java @@ -22,7 +22,7 @@ public class WireArray public final int travelTime; private List observers = new ArrayList(); public final int length; - private List inputs = new ArrayList(); + List inputs = new ArrayList(); public WireArray(int length, int travelTime) { @@ -61,12 +61,7 @@ public class WireArray Bit[] bits = input.getValues(); for (int i = 0; i < length; i++) { - if (Bit.Z.equals(bits[i]) || newValues[i].equals(bits[i])) - continue; - else if (Bit.Z.equals(newValues[i])) - newValues[i] = bits[i]; - else - newValues[i] = Bit.X; + newValues[i] = newValues[i].combineWith(bits[i]); } } @@ -78,7 +73,7 @@ public class WireArray } } - private void recalculate() + void recalculate() { switch (inputs.size()) { @@ -228,7 +223,7 @@ public class WireArray return new WireArrayEnd(this); } - private void registerInput(WireArrayEnd toRegister) + void registerInput(WireArrayEnd toRegister) { inputs.add(toRegister); } @@ -244,9 +239,9 @@ public class WireArray { public final WireArray owner; private boolean open; - private Bit[] inputValues; + Bit[] inputValues; - private WireArrayEnd(WireArray owner) + WireArrayEnd(WireArray owner) { super(); this.owner = owner; @@ -257,7 +252,7 @@ public class WireArray private void initValues() { - inputValues = Bit.Z.makeArray(length); + inputValues = Bit.U.makeArray(length); } /** @@ -269,12 +264,11 @@ public class WireArray */ public void feedSignals(Bit... newValues) { - if (newValues.length == length) - { - feedSignals(0, newValues); - } else + if (newValues.length != length) throw new IllegalArgumentException( String.format("Attempted to input %d bits instead of %d bits.", newValues.length, length)); + feedSignals(0, newValues); + } /**