X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=inline;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWireArray.java;h=58f27bc2d0856aae3e821c16788fe2234047f207;hb=c18c04011cab0040c2287608eeefc9c3cc4536c2;hp=164e153a122269b46ad04d1ad152ded4a332bf74;hpb=9c5575eb465fefb5a32c854b79dc175ce582bc94;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 164e153a..58f27bc2 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; @@ -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); + } /**