From: Daniel Kirschten Date: Mon, 26 Aug 2019 09:06:02 +0000 (+0200) Subject: Further renaming of length to width X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=153f81323a215691a0477af3fd1dd4a9d5b02958;p=Mograsim.git Further renaming of length to width --- diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Demux.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Demux.java index ec36b88e..5cf80747 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Demux.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Demux.java @@ -24,7 +24,7 @@ public class Demux extends BasicComponent /** * Output {@link Wire}s and in must be of uniform width * - * @param in Must be of uniform length with all outputs. + * @param in Must be of uniform width with all outputs. * @param select Indexes the output array to which the input is mapped. Must have enough bits to index all outputs. * @param outputs One of these outputs receives the input signal, depending on the select bits */ diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java index 40f0005a..25445ee1 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java @@ -55,8 +55,8 @@ public class ManualSwitch extends Component implements LogicObservable public void setState(BitVector bits) { - if (bits.length() != output.width()) - throw new IllegalArgumentException("Incorrect bit vector length"); + if (bits.width() != output.width()) + throw new IllegalArgumentException("Incorrect bit vector width"); if (bits.equals(output.getInputValues())) return; output.feedSignals(bits); diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Merger.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Merger.java index 07303a2e..acc05d3c 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Merger.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Merger.java @@ -27,15 +27,15 @@ public class Merger extends Component implements LogicObserver this.out = union; this.beginningIndex = new int[inputs.length]; - int length = 0; + int width = 0; for (int i = 0; i < inputs.length; i++) { - beginningIndex[i] = length; - length += inputs[i].width(); + beginningIndex[i] = width; + width += inputs[i].width(); inputs[i].registerObserver(this); } - if (length != union.width()) + if (width != union.width()) throw new IllegalArgumentException( "The output of merging n WireArrays into one must have width = a1.width() + a2.width() + ... + an.width()."); } diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java index 6ef41b28..3776bde9 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java @@ -25,9 +25,9 @@ public class Mux extends BasicComponent private final int outputSize; /** - * Input {@link Wire}s and out must be of uniform length + * Input {@link Wire}s and out must be of uniform width * - * @param out Must be of uniform length with all inputs. + * @param out Must be of uniform width with all inputs. * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs. * @param inputs One of these inputs is mapped to the output, depending on the select bits */ diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java index da7b8c91..e6278104 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java @@ -69,9 +69,9 @@ public enum Bit implements StrictLogicType return bits; } - public BitVector toVector(int length) + public BitVector toVector(int width) { - return BitVector.of(this, length); + return BitVector.of(this, width); } @Override 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 e17ae6e1..aed0288d 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 @@ -50,11 +50,11 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable, Iterable op) @@ -227,11 +227,11 @@ public final class BitVector implements StrictLogicType, Iterablewith all bits set to null. Use with care! + * Returns a new mutator of the specified width, with all bits set to null. Use with care! */ - public static BitVectorMutator ofLength(int length) + public static BitVectorMutator ofWidth(int width) { - return new BitVectorMutator(new Bit[length]); + return new BitVectorMutator(new Bit[width]); } /** @@ -344,17 +344,17 @@ public final class BitVector implements StrictLogicType, Iterable, Iterableoffset to the right.
- * Therefore offset + other.length() <= this.length() needs to be true. + * Therefore offset + other.width() <= this.wdith() needs to be true. * - * @throws ArrayIndexOutOfBoundsException if offset + other.length() > this.length() + * @throws ArrayIndexOutOfBoundsException if offset + other.width() > this.width() * * @see Object#equals(Object) */ @@ -395,7 +395,7 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable 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); } } diff --git a/net.mograsim.logic.core/test/net/mograsim/logic/core/types/BitVectorTest.java b/net.mograsim.logic.core/test/net/mograsim/logic/core/types/BitVectorTest.java index 11b5febf..b83a5ff9 100644 --- a/net.mograsim.logic.core/test/net/mograsim/logic/core/types/BitVectorTest.java +++ b/net.mograsim.logic.core/test/net/mograsim/logic/core/types/BitVectorTest.java @@ -128,7 +128,7 @@ class BitVectorTest assertEquals(SINGLE_U, SINGLE_0.join(SINGLE_U)); assertEquals(SINGLE_X, SINGLE_X.join(SINGLE_Z)); - // higher length + // higher width var result = BitVector.of(U, X, ZERO, ONE, Z).join(BitVector.of(ONE, ZERO, ZERO, ONE, Z)); assertEquals(BitVector.of(U, X, ZERO, ONE, Z), result); } @@ -146,7 +146,7 @@ class BitVectorTest assertEquals(SINGLE_0, SINGLE_0.and(SINGLE_U)); assertEquals(SINGLE_X, SINGLE_X.and(SINGLE_Z)); - // higher length + // higher width var result = BitVector.of(U, X, ZERO, ONE, ONE).and(BitVector.of(ONE, ONE, ZERO, ZERO, ONE)); assertEquals(BitVector.of(U, X, ZERO, ZERO, ONE), result); } @@ -164,7 +164,7 @@ class BitVectorTest assertEquals(SINGLE_1, SINGLE_1.or(SINGLE_U)); assertEquals(SINGLE_X, SINGLE_X.or(SINGLE_Z)); - // higher length + // higher width var result = BitVector.of(U, X, ZERO, ONE, ZERO).or(BitVector.of(ZERO, ZERO, ZERO, ONE, ONE)); assertEquals(BitVector.of(U, X, ZERO, ONE, ONE), result); } @@ -182,7 +182,7 @@ class BitVectorTest assertEquals(SINGLE_U, SINGLE_0.xor(SINGLE_U)); assertEquals(SINGLE_X, SINGLE_X.xor(SINGLE_Z)); - // higher length + // higher width var result = BitVector.of(U, X, ZERO, ONE, ONE).xor(BitVector.of(ONE, ZERO, ZERO, ZERO, ONE)); assertEquals(BitVector.of(U, X, ZERO, ONE, ZERO), result); } @@ -199,17 +199,17 @@ class BitVectorTest assertEquals(SINGLE_X, SINGLE_X.not()); assertEquals(SINGLE_X, SINGLE_Z.not()); - // higher length + // higher width var result = BitVector.of(U, X, ZERO, ONE, Z).not(); assertEquals(BitVector.of(U, X, ONE, ZERO, X), result); } @Test - void testLength() + void testWidth() { - assertEquals(0, BitVector.of().length()); - assertEquals(1, SINGLE_0.length()); - assertEquals(3, BitVector.of(X, X, Z).length()); + assertEquals(0, BitVector.of().width()); + assertEquals(1, SINGLE_0.width()); + assertEquals(3, BitVector.of(X, X, Z).width()); } @Test diff --git a/net.mograsim.logic.model.am2900/components/GUIdff4.json b/net.mograsim.logic.model.am2900/components/GUIdff4.json index 4064f93e..72b7273d 100644 --- a/net.mograsim.logic.model.am2900/components/GUIdff4.json +++ b/net.mograsim.logic.model.am2900/components/GUIdff4.json @@ -689,7 +689,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.am2900/components/GUIdff4_invwe.json b/net.mograsim.logic.model.am2900/components/GUIdff4_invwe.json index cb697d23..7665a992 100644 --- a/net.mograsim.logic.model.am2900/components/GUIdff4_invwe.json +++ b/net.mograsim.logic.model.am2900/components/GUIdff4_invwe.json @@ -698,7 +698,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.am2900/components/GUIdlatch4.json b/net.mograsim.logic.model.am2900/components/GUIdlatch4.json index 28021dff..a836450f 100644 --- a/net.mograsim.logic.model.am2900/components/GUIdlatch4.json +++ b/net.mograsim.logic.model.am2900/components/GUIdlatch4.json @@ -368,7 +368,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.am2900/components/GUIram2.json b/net.mograsim.logic.model.am2900/components/GUIram2.json index 31a01fba..c2919803 100644 --- a/net.mograsim.logic.model.am2900/components/GUIram2.json +++ b/net.mograsim.logic.model.am2900/components/GUIram2.json @@ -2998,7 +2998,7 @@ mograsim version: 0.1.3 "c01.q", "c00.q" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 4, 4, 4, diff --git a/net.mograsim.logic.model.am2900/components/GUIram4.json b/net.mograsim.logic.model.am2900/components/GUIram4.json index 05bfe9da..f676b3dd 100644 --- a/net.mograsim.logic.model.am2900/components/GUIram4.json +++ b/net.mograsim.logic.model.am2900/components/GUIram4.json @@ -3490,7 +3490,7 @@ mograsim version: 0.1.3 "c01.q", "c00.q" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 16, 16, 16, diff --git a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestUtil.java b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestUtil.java index 46a4b92c..cd682f28 100644 --- a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestUtil.java +++ b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestUtil.java @@ -92,11 +92,11 @@ public final class TestUtil return sb.reverse().toString(); } - public static BitVector of(int value, int length) + public static BitVector of(int value, int width) { - BitVectorMutator mutator = BitVectorMutator.ofLength(length); + BitVectorMutator mutator = BitVectorMutator.ofWidth(width); int val = value; - for (int i = length - 1; i >= 0; i--) + for (int i = width - 1; i >= 0; i--) { mutator.setMSBit(i, Bit.lastBitOf(val)); val >>>= 1; diff --git a/net.mograsim.logic.model.editor/components/GUIdff4.json b/net.mograsim.logic.model.editor/components/GUIdff4.json index 4064f93e..72b7273d 100644 --- a/net.mograsim.logic.model.editor/components/GUIdff4.json +++ b/net.mograsim.logic.model.editor/components/GUIdff4.json @@ -689,7 +689,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.editor/components/GUIdff4_invwe.json b/net.mograsim.logic.model.editor/components/GUIdff4_invwe.json index cb697d23..7665a992 100644 --- a/net.mograsim.logic.model.editor/components/GUIdff4_invwe.json +++ b/net.mograsim.logic.model.editor/components/GUIdff4_invwe.json @@ -698,7 +698,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.editor/components/GUIdlatch4.json b/net.mograsim.logic.model.editor/components/GUIdlatch4.json index 28021dff..a836450f 100644 --- a/net.mograsim.logic.model.editor/components/GUIdlatch4.json +++ b/net.mograsim.logic.model.editor/components/GUIdlatch4.json @@ -368,7 +368,7 @@ mograsim version: 0.1.3 "q3", "q4" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 1, 1, 1, diff --git a/net.mograsim.logic.model.editor/components/GUIram2.json b/net.mograsim.logic.model.editor/components/GUIram2.json index 31a01fba..c2919803 100644 --- a/net.mograsim.logic.model.editor/components/GUIram2.json +++ b/net.mograsim.logic.model.editor/components/GUIram2.json @@ -2998,7 +2998,7 @@ mograsim version: 0.1.3 "c01.q", "c00.q" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 4, 4, 4, diff --git a/net.mograsim.logic.model.editor/components/GUIram4.json b/net.mograsim.logic.model.editor/components/GUIram4.json index 05bfe9da..f676b3dd 100644 --- a/net.mograsim.logic.model.editor/components/GUIram4.json +++ b/net.mograsim.logic.model.editor/components/GUIram4.json @@ -3490,7 +3490,7 @@ mograsim version: 0.1.3 "c01.q", "c00.q" ], - "vectorPartLengthes": [ + "vectorPartWidths": [ 16, 16, 16, diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java index 0e2328aa..f26c8723 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java @@ -15,8 +15,8 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh { private SubmodelComponent component; private final List vectorPartTargets; - private final List vectorPartLengthes; - private int length; + private final List vectorPartWidths; + private int width; public BitVectorSplittingAtomicHighLevelStateHandler(HighLevelStateHandlerContext context) { @@ -28,38 +28,38 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh { this.component = context.component; this.vectorPartTargets = new ArrayList<>(); - this.vectorPartLengthes = new ArrayList<>(); + this.vectorPartWidths = new ArrayList<>(); if (params != null) - setVectorParts(params.vectorPartTargets, params.vectorPartLengthes); + setVectorParts(params.vectorPartTargets, params.vectorPartWidths); } - public void set(List targets, List lengthes) + public void set(List targets, List widths) { - setVectorParts(targets, lengthes); + setVectorParts(targets, widths); } - public void addVectorPart(String target, int length) + public void addVectorPart(String target, int width) { vectorPartTargets.add(target); - vectorPartLengthes.add(length); - this.length += length; + vectorPartWidths.add(width); + this.width += width; } public void clearVectorParts() { vectorPartTargets.clear(); - vectorPartLengthes.clear(); - length = 0; + vectorPartWidths.clear(); + width = 0; } - private void setVectorParts(List targets, List lengthes) + private void setVectorParts(List targets, List widths) { clearVectorParts(); - if (targets.size() != lengthes.size()) - throw new IllegalArgumentException("Targets list and lenghtes list have different sizes"); + if (targets.size() != widths.size()) + throw new IllegalArgumentException("Targets list and widths list have different sizes"); vectorPartTargets.addAll(targets); - vectorPartLengthes.addAll(lengthes); - length += lengthes.stream().mapToInt(Integer::intValue).sum(); + vectorPartWidths.addAll(widths); + width += widths.stream().mapToInt(Integer::intValue).sum(); } @Override @@ -74,9 +74,9 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh vectorPart = BitVector.of((Bit) subStateUncasted); else vectorPart = (BitVector) subStateUncasted; - if (vectorPart.length() != vectorPartLengthes.get(partIndex)) + if (vectorPart.width() != vectorPartWidths.get(partIndex)) throw new IllegalArgumentException( - "Incorrect vector part length: " + vectorPart.length() + "; expected " + vectorPartLengthes.get(partIndex)); + "Incorrect vector part width: " + vectorPart.width() + "; expected " + vectorPartWidths.get(partIndex)); result = vectorPart.concat(result); } return result; @@ -86,14 +86,14 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh public void setHighLevelState(Object newState) { BitVector newStateCasted = (BitVector) newState; - if (newStateCasted.length() != length) - throw new IllegalArgumentException("Incorrect vector length: " + newStateCasted.length() + "; expected " + length); + if (newStateCasted.width() != width) + throw new IllegalArgumentException("Incorrect vector width: " + newStateCasted.width() + "; expected " + width); for (int partIndex = vectorPartTargets.size() - 1, bitIndex = 0; partIndex >= 0; partIndex--) { - int vectorPartLength = vectorPartLengthes.get(partIndex); - BitVector vectorPart = newStateCasted.subVector(bitIndex, bitIndex + vectorPartLength); + int vectorPartWidth = vectorPartWidths.get(partIndex); + BitVector vectorPart = newStateCasted.subVector(bitIndex, bitIndex + vectorPartWidth); component.setHighLevelState(vectorPartTargets.get(partIndex), vectorPart); - bitIndex += vectorPartLength; + bitIndex += vectorPartWidth; } } @@ -102,14 +102,14 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh { BitVectorSplittingAtomicHighLevelStateHandlerParams params = new BitVectorSplittingAtomicHighLevelStateHandlerParams(); params.vectorPartTargets = new ArrayList<>(vectorPartTargets); - params.vectorPartLengthes = new ArrayList<>(vectorPartLengthes); + params.vectorPartWidths = new ArrayList<>(vectorPartWidths); return params; } public static class BitVectorSplittingAtomicHighLevelStateHandlerParams { public List vectorPartTargets; - public List vectorPartLengthes; + public List vectorPartWidths; } static diff --git a/net.mograsim.machine/src/net/mograsim/machine/isa/AsmFloatOperand.java b/net.mograsim.machine/src/net/mograsim/machine/isa/AsmFloatOperand.java index 7a1a6ebf..a15d9d5a 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/isa/AsmFloatOperand.java +++ b/net.mograsim.machine/src/net/mograsim/machine/isa/AsmFloatOperand.java @@ -90,7 +90,7 @@ public class AsmFloatOperand implements AsmOperand int bitLength = raw.bitLength() - (bi.signum() - 1) / 2; if (bitLength > size) throw new AsmNumberFormatException("Error parsing %s: bit count %d exceeds size %d", bi, bitLength, size); - BitVectorMutator bvm = BitVectorMutator.ofLength(size); + BitVectorMutator bvm = BitVectorMutator.ofWidth(size); for (int i = 0; i < size; i++) bvm.setLSBit(i, Bit.of(raw.testBit(i))); return bvm.toBitVector(); diff --git a/net.mograsim.machine/src/net/mograsim/machine/isa/AsmIntegerOperand.java b/net.mograsim.machine/src/net/mograsim/machine/isa/AsmIntegerOperand.java index d3ac80f9..70f5a435 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/isa/AsmIntegerOperand.java +++ b/net.mograsim.machine/src/net/mograsim/machine/isa/AsmIntegerOperand.java @@ -55,7 +55,7 @@ public class AsmIntegerOperand implements AsmOperand int bitLength = bi.bitLength() - (bi.signum() - 1) / 2; if (bitLength > size) throw new AsmNumberFormatException("Error parsing %s: bit count %d exceeds size %d", bi, bitLength, size); - BitVectorMutator bvm = BitVectorMutator.ofLength(size); + BitVectorMutator bvm = BitVectorMutator.ofWidth(size); for (int i = 0; i < size; i++) bvm.setLSBit(i, Bit.of(bi.testBit(i))); return bvm.toBitVector(); diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java index ee40201b..2e209f1c 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java @@ -112,9 +112,9 @@ public class WordAddressableMemory implements MainMemory public void setCell(int index, BitVector bits) { - if (bits.length() != cellWidth) + if (bits.width() != cellWidth) throw new IllegalArgumentException(String.format( - "BitVector to be saved in memory cell has unexpected length. Expected: %d Actual: %d", cellWidth, bits.length())); + "BitVector to be saved in memory cell has unexpected width. Expected: %d Actual: %d", cellWidth, bits.width())); memory[index] = bits; } diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemoryComponent.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemoryComponent.java index 13bcc64a..4cec2b17 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemoryComponent.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemoryComponent.java @@ -10,7 +10,7 @@ import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; import net.mograsim.machine.MainMemoryDefinition; /** - * A memory component that only allows access to words of a specific length + * A memory component that only allows access to words of a specific width */ public class WordAddressableMemoryComponent extends BasicComponent {