X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fwires%2FWire.java;h=8b28511e90a5a4c2efab433ecb76fca7604b8999;hb=153f81323a215691a0477af3fd1dd4a9d5b02958;hp=581abb670d0b4a0dcc7c4d1cae00635078859ef7;hpb=3e6ac3d7fd389191d02c1c6982fbf093421ce4f2;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java index 581abb67..8b28511e 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java @@ -389,9 +389,9 @@ public class Wire public void feedSignals(BitVector newValues) { - if (newValues.length() != width) + if (newValues.width() != width) throw new IllegalArgumentException( - String.format("Attempted to input %d bits instead of %d bits.", newValues.length(), width)); + String.format("Attempted to input %d bits instead of %d bits.", newValues.width(), width)); if (!open) throw new IllegalStateException("Attempted to write to closed WireArrayEnd."); timeline.addEvent(e -> setValues(newValues), travelTime); @@ -422,7 +422,7 @@ public class Wire if (!inputValues.equalsWithOffset(newValues, startingBit)) { Bit[] vals = inputValues.getBits(); - System.arraycopy(newValues.getBits(), 0, vals, startingBit, newValues.length()); + System.arraycopy(newValues.getBits(), 0, vals, startingBit, newValues.width()); inputValues = BitVector.of(vals); Wire.this.recalculate(); } @@ -544,20 +544,20 @@ public class Wire * Fuses the selected bits of two wires together. If the bits change in one Wire, the other is changed accordingly immediately. Warning: * The bits are permanently fused together. * - * @param a The {@link Wire} to be (partially) fused with b - * @param b The {@link Wire} to be (partially) fused with a - * @param fromA The first bit of {@link Wire} a to be fused - * @param fromB The first bit of {@link Wire} b to be fused - * @param length The amount of bits to fuse + * @param a The {@link Wire} to be (partially) fused with b + * @param b The {@link Wire} to be (partially) fused with a + * @param fromA The first bit of {@link Wire} a to be fused + * @param fromB The first bit of {@link Wire} b to be fused + * @param width The amount of bits to fuse */ - public static void fuse(Wire a, Wire b, int fromA, int fromB, int length) + public static void fuse(Wire a, Wire b, int fromA, int fromB, int width) { ReadWriteEnd rA = a.createReadWriteEnd(), rB = b.createReadWriteEnd(); rA.setWriting(false); rB.setWriting(false); rA.setValues(BitVector.of(Bit.Z, a.width)); rB.setValues(BitVector.of(Bit.Z, b.width)); - Fusion aF = new Fusion(rB, fromA, fromB, length), bF = new Fusion(rA, fromB, fromA, length); + Fusion aF = new Fusion(rB, fromA, fromB, width), bF = new Fusion(rA, fromB, fromA, width); rA.registerObserver(aF); rB.registerObserver(bF); aF.update(rA); @@ -580,14 +580,14 @@ public class Wire private static class Fusion implements LogicObserver { private ReadWriteEnd target; - int fromSource, fromTarget, length; + int fromSource, fromTarget, width; - public Fusion(ReadWriteEnd target, int fromSource, int fromTarget, int length) + public Fusion(ReadWriteEnd target, int fromSource, int fromTarget, int width) { this.target = target; this.fromSource = fromSource; this.fromTarget = fromTarget; - this.length = length; + this.width = width; } @Override @@ -599,7 +599,7 @@ public class Wire else { target.setWriting(true); - BitVector targetInput = source.wireValuesExcludingMe().subVector(fromSource, fromSource + length); + BitVector targetInput = source.wireValuesExcludingMe().subVector(fromSource, fromSource + width); target.setValues(fromTarget, targetInput); } }