X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Ftypes%2FBitVector.java;h=134669494852256df8868924a63aa687e8b1fb00;hb=9c98bb5456a7ead6d92fcc6acd9d1497688b244d;hp=c223e819b5740af02e11d631a46f07053320da04;hpb=9d4faa3eb431c46f0064c2f2a67fc369cf38dfdb;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java index c223e819..13466949 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java @@ -420,13 +420,13 @@ public final class BitVector implements StrictLogicType, Iterable= 0; i--) { - if (Bit.ONE == bits[i]) + if (Bit.ONE == bits[bits.length - i - 1]) { try { - bytes[(i / 8) + 1] |= 1 << (i % 8); + bytes[bytes.length - (i / 8) - 1] |= 1 << (i % 8); } catch (IndexOutOfBoundsException e) { @@ -437,6 +437,31 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable singleBitOperation) + { + Bit[] newBits = bits.clone(); + newBits[msbIndex] = singleBitOperation.apply(newBits[msbIndex]); + return new BitVector(newBits); + } + /** * Iterate over the {@link Bit}s of the BitVector from MSB to LSB (left to right). */ @@ -477,4 +516,15 @@ public final class BitVector implements StrictLogicType, Iterable