X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fwires%2FWire.java;h=d85fc206ce65ff33214081ac5231d161472983e2;hb=b1e7855af2dfc15b4d6c1253dd77db02925162f3;hp=5eac8894371b687fc7f7102a507ee3ff46a5c12c;hpb=c1d0ddc342c482051fa6c455bb286617135bd3c3;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/wires/Wire.java b/era.mi/src/era/mi/logic/wires/Wire.java index 5eac8894..d85fc206 100644 --- a/era.mi/src/era/mi/logic/wires/Wire.java +++ b/era.mi/src/era/mi/logic/wires/Wire.java @@ -19,7 +19,7 @@ public class Wire { private Bit[] values; public final int travelTime; - private List observers = new ArrayList(); + private List observers = new ArrayList(); public final int length; private List inputs = new ArrayList(); @@ -182,21 +182,21 @@ public class Wire } /** - * Adds an {@link WireArrayObserver}, who will be notified when the value of the {@link Wire} is updated. + * Adds an {@link WireObserver}, who will be notified when the value of the {@link Wire} is updated. * - * @param ob The {@link WireArrayObserver} to be notified of changes. - * @return true if the given {@link WireArrayObserver} was not already registered, false otherwise + * @param ob The {@link WireObserver} to be notified of changes. + * @return true if the given {@link WireObserver} was not already registered, false otherwise * * @author Fabian Stemmler */ - public boolean addObserver(WireArrayObserver ob) + public boolean addObserver(WireObserver ob) { return observers.add(ob); } private void notifyObservers(Bit[] oldValues) { - for (WireArrayObserver o : observers) + for (WireObserver o : observers) o.update(this, oldValues); } @@ -215,8 +215,8 @@ public class Wire /** * A {@link WireEnd} feeds a constant signal into the {@link Wire} it is tied to. The combination of all inputs determines the - * {@link Wire}s final value. X dominates all other inputs Z does not affect the final value, unless there are no other inputs than - * Z 0 and 1 turn into X when they are mixed + * {@link Wire}s final value. X dominates all other inputs Z does not affect the final value, unless there are no other inputs than Z 0 + * and 1 turn into X when they are mixed * * @author Fabian Stemmler */ @@ -299,16 +299,15 @@ public class Wire { return inputValues[index]; } - + /** - * @return A copy (safe to modify) of the values the {@link WireEnd} is currently feeding into the associated - * {@link Wire}. + * @return A copy (safe to modify) of the values the {@link WireEnd} is currently feeding into the associated {@link Wire}. */ public Bit[] getInputValues() { return getInputValues(0, length); } - + public Bit[] getInputValues(int start, int end) { int length = end - start; @@ -359,7 +358,7 @@ public class Wire { return Wire.this.getValue(index); } - + /** * @param index Index of the requested bit. * @return The value of the indexed bit. @@ -373,8 +372,8 @@ public class Wire /** * @param start Start of the wanted segment. (inclusive) - * @param end End of the wanted segment. (exclusive) - * @return The values of the segment of {@link Bit}s indexed. + * @param end End of the wanted segment. (exclusive) + * @return The values of the segment of {@link Bit}s indexed. * * @author Fabian Stemmler */ @@ -382,13 +381,12 @@ public class Wire { return Wire.this.getValues(start, end); } - /** * The {@link Wire} is interpreted as an unsigned integer with n bits. * - * @return true if all bits are either Bit.ONE or Bit.ZERO (they do not all have to have the same - * value), not Bit.X or Bit.Z. false is returned otherwise. + * @return true if all bits are either Bit.ONE or Bit.ZERO (they do not all have to have the + * same value), not Bit.X or Bit.Z. false is returned otherwise. * * @author Fabian Stemmler */ @@ -420,12 +418,12 @@ public class Wire { return Wire.this.getSignedValue(); } - + @Override public String toString() { return Arrays.toString(values); - //return String.format("%s \nFeeding: %s", WireArray.this.toString(), Arrays.toString(inputValues)); + // return String.format("%s \nFeeding: %s", WireArray.this.toString(), Arrays.toString(inputValues)); } public void disconnect() @@ -439,22 +437,22 @@ public class Wire return length; } - public boolean addObserver(WireArrayObserver ob) + public boolean addObserver(WireObserver ob) { return Wire.this.addObserver(ob); } - + public Wire getWire() { return Wire.this; } } - + @Override public String toString() { return String.format("wire 0x%08x value: %s inputs: %s", hashCode(), Arrays.toString(values), inputs); - //Arrays.toString(values), inputs.stream().map(i -> Arrays.toString(i.inputValues)).reduce((s1, s2) -> s1 + s2) + // Arrays.toString(values), inputs.stream().map(i -> Arrays.toString(i.inputValues)).reduce((s1, s2) -> s1 + s2) } public static WireEnd[] extractEnds(Wire[] w)