From 9f4b106057a7b291aa880620dc80faa9cb7fc8f3 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Sat, 12 Oct 2019 14:57:30 +0200 Subject: [PATCH] Some work on improving BitVector<->String conversions --- .../mograsim/logic/core/types/BitVector.java | 15 +++-- .../logic/core/types/BitVectorFormatter.java | 50 +++++++++++++++- .../mograsim/logic/model/LogicUICanvas.java | 17 +++++- .../components/atomic/ModelBitDisplay.java | 11 +--- .../standard/memory/MainMemoryParser.java | 4 +- .../plugin/launch/MachineRegister.java | 47 ++------------- .../logic/core/types/BitVectorTest.java | 44 +++++++------- .../am2900/am2901/TestableAm2901Impl.java | 28 ++++----- .../am2900/am2904/TestableAm2904Impl.java | 58 +++++++++---------- .../logic/model/am2900/am2910/Am2910Test.java | 4 +- .../am2900/am2910/TestableAm2910Impl.java | 26 ++++----- 11 files changed, 160 insertions(+), 144 deletions(-) diff --git a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java index 4b102928..3ca16a10 100644 --- a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java +++ b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java @@ -406,13 +406,18 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable 0 && userInput.matches("0x[0-9a-fA-F]+")) + // TODO should we check for overflows? + bitvector = BitVector.from(new BigInteger(userInput.substring(2), 16), width); + else if (width <= 0 || userInput.length() == width) + // TODO do this without exceptions + try + { + bitvector = BitVector.parseBitstring(userInput); + } + catch (@SuppressWarnings("unused") NullPointerException x) + { + // ignore + } + if (bitvector == null && width > 0) + try + { + // TODO should we check for overflows? + bitvector = BitVector.from(new BigInteger(userInput), width); + } + catch (@SuppressWarnings("unused") NumberFormatException x) + { + // ignore + } + return bitvector; } // TODO doesn't this belong to logic.model? diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java index 5fd58c13..9675167c 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java @@ -25,6 +25,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas; import net.mograsim.logic.core.types.Bit; import net.mograsim.logic.core.types.BitVector; +import net.mograsim.logic.core.types.BitVectorFormatter; import net.mograsim.logic.model.model.LogicModel; import net.mograsim.logic.model.model.components.ModelComponent; import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; @@ -141,14 +142,24 @@ public class LogicUICanvas extends ZoomableCanvas throw new RuntimeException("No component selected"); ModelComponent target = componentsByItemIndex.get(componentIndex); String valueString = valueText.getText(); + String stateID = stateIDText.getText(); Object value; if (radioBit.getSelection()) value = Bit.parse(valueString); else if (radioBitVector.getSelection()) - value = BitVector.parse(valueString); - else + { + Object hls = target.getHighLevelState(stateID); + int width; + if (hls instanceof Bit) + width = 1; + else if (hls instanceof BitVector) + width = ((BitVector) hls).length(); + else + width = -1; + value = BitVectorFormatter.parseUserBitVector(valueString, width); + } else throw new RuntimeException("No value type selected"); - target.setHighLevelState(stateIDText.getText(), value); + target.setHighLevelState(stateID, value); output.setText("Success!"); } catch (Exception x) diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java index 5be3e22d..ac332665 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java @@ -8,7 +8,6 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; import net.mograsim.logic.core.components.CoreBitDisplay; -import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.core.types.BitVectorFormatter; import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.components.ModelComponent; @@ -56,15 +55,7 @@ public class ModelBitDisplay extends ModelComponent if (foreground != null) gc.setForeground(foreground); gc.drawRectangle(getBounds()); - String label; - if (bitDisplay == null) - label = BitVectorFormatter.formatAsString(null); - else - { - BitVector toDisplay = bitDisplay.getDisplayedValue(); - label = toDisplay != null && toDisplay.isHighImpedance() ? "-" - : BitVectorFormatter.formatAsString(bitDisplay.getDisplayedValue()); - } + String label = BitVectorFormatter.formatAsString(bitDisplay == null ? null : bitDisplay.getDisplayedValue()); Font oldFont = gc.getFont(); Font labelFont = new Font(oldFont.getName(), fontHeight, oldFont.getStyle()); gc.setFont(labelFont); diff --git a/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java b/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java index ea872961..d52efdcf 100644 --- a/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java +++ b/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java @@ -63,7 +63,7 @@ public class MainMemoryParser { for (; i <= maxAddr && reader.ready() && !"".equals((line = reader.readLine())); i++) { - memory.setCell(i, BitVector.parse(line)); + memory.setCell(i, BitVector.parseBitstring(line)); } } catch (IOException e) @@ -86,7 +86,7 @@ public class MainMemoryParser int val = instStream.read(); if (val == -1 && instIndex <= maxAddress) { - instStream = new ByteArrayInputStream((memory.getCell(instIndex++).toString() + lineSeparator).getBytes()); + instStream = new ByteArrayInputStream((memory.getCell(instIndex++).toBitstring() + lineSeparator).getBytes()); val = instStream.read(); } return val; diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineRegister.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineRegister.java index 59e22f83..e4704204 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineRegister.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineRegister.java @@ -1,6 +1,5 @@ package net.mograsim.plugin.launch; -import java.math.BigInteger; import java.util.Arrays; import java.util.function.Consumer; @@ -19,6 +18,7 @@ import org.eclipse.debug.core.model.IValue; import org.eclipse.swt.SWT; import net.mograsim.logic.core.types.BitVector; +import net.mograsim.logic.core.types.BitVectorFormatter; import net.mograsim.machine.Machine; import net.mograsim.machine.registers.Register; import net.mograsim.plugin.MograsimActivator; @@ -97,58 +97,19 @@ public class MachineRegister extends PlatformObject implements IRegister public String getValueString() { - BitVector bitvector = getMachine().getRegister(machineRegister); - if (bitvector.isBinary()) - { - String hexdigits = bitvector.getUnsignedValue().toString(16); - StringBuilder sb = new StringBuilder(); - sb.append("0x"); - sb.append("0".repeat((machineRegister.getWidth() + 3) / 4 - hexdigits.length())); - sb.append(hexdigits); - return sb.toString(); - } - return bitvector.toString(); + return BitVectorFormatter.formatAsString(getMachine().getRegister(machineRegister)); } @Override public void setValue(String expression) throws DebugException { - BitVector bitvector = parseValue(expression); + BitVector bitvector = BitVectorFormatter.parseUserBitVector(expression, machineRegister.getWidth()); if (bitvector == null) throw new DebugException( new Status(IStatus.ERROR, MograsimActivator.PLUGIN_ID, "Couldn't parse value string: " + expression, null)); getMachine().setRegister(machineRegister, bitvector); } - private BitVector parseValue(String expression) - { - BitVector bitvector = null; - if (expression.matches("0x[0-9a-fA-F]+")) - // TODO should we check for overflows? - bitvector = BitVector.from(new BigInteger(expression.substring(2), 16), machineRegister.getWidth()); - else if (expression.length() == machineRegister.getWidth()) - // TODO do this without exceptions - try - { - bitvector = BitVector.parse(expression); - } - catch (@SuppressWarnings("unused") NullPointerException x) - { - // ignore - } - if (bitvector == null) - try - { - // TODO should we check for overflows? - bitvector = BitVector.from(new BigInteger(expression), machineRegister.getWidth()); - } - catch (@SuppressWarnings("unused") NumberFormatException x) - { - // ignore - } - return bitvector; - } - @Override public void setValue(IValue value) throws DebugException { @@ -166,7 +127,7 @@ public class MachineRegister extends PlatformObject implements IRegister @Override public boolean verifyValue(String expression) throws DebugException { - return parseValue(expression) != null; + return BitVectorFormatter.parseUserBitVector(expression, machineRegister.getWidth()) != null; } @Override diff --git a/tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java b/tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java index 317e8ab1..d9b90688 100644 --- a/tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java +++ b/tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java @@ -42,31 +42,31 @@ class BitVectorTest @Test void testGetUnsignedValue() { - assertEquals(BigInteger.valueOf(0b101), BitVector.parse("101").getUnsignedValue()); - assertEquals(BigInteger.valueOf(0b01010), BitVector.parse("01010").getUnsignedValue()); - assertEquals(BigInteger.valueOf(0), BitVector.parse("0000").getUnsignedValue()); - assertEquals(BigInteger.valueOf(0b0000000101), BitVector.parse("0000000101").getUnsignedValue()); - assertEquals(BigInteger.valueOf(0b1010000000), BitVector.parse("1010000000").getUnsignedValue()); + assertEquals(BigInteger.valueOf(0b101), BitVector.parseBitstring("101").getUnsignedValue()); + assertEquals(BigInteger.valueOf(0b01010), BitVector.parseBitstring("01010").getUnsignedValue()); + assertEquals(BigInteger.valueOf(0), BitVector.parseBitstring("0000").getUnsignedValue()); + assertEquals(BigInteger.valueOf(0b0000000101), BitVector.parseBitstring("0000000101").getUnsignedValue()); + assertEquals(BigInteger.valueOf(0b1010000000), BitVector.parseBitstring("1010000000").getUnsignedValue()); - assertThrows(NumberFormatException.class, () -> BitVector.parse("00X1").getUnsignedValue()); + assertThrows(NumberFormatException.class, () -> BitVector.parseBitstring("00X1").getUnsignedValue()); } @Test void testOfLongInt() { - assertEquals(BitVector.parse("101"), BitVector.from(0b101L, 3)); - assertEquals(BitVector.parse("01010"), BitVector.from(0b01010L, 5)); - assertEquals(BitVector.parse("10101"), BitVector.from(-11L, 5)); - assertEquals(BitVector.parse("0000"), BitVector.from(0L, 4)); + assertEquals(BitVector.parseBitstring("101"), BitVector.from(0b101L, 3)); + assertEquals(BitVector.parseBitstring("01010"), BitVector.from(0b01010L, 5)); + assertEquals(BitVector.parseBitstring("10101"), BitVector.from(-11L, 5)); + assertEquals(BitVector.parseBitstring("0000"), BitVector.from(0L, 4)); } @Test void testOfBigIntegerInt() { - assertEquals(BitVector.parse("101"), BitVector.from(BigInteger.valueOf(0b101), 3)); - assertEquals(BitVector.parse("01010"), BitVector.from(BigInteger.valueOf(0b01010), 5)); - assertEquals(BitVector.parse("10101"), BitVector.from(BigInteger.valueOf(-11), 5)); - assertEquals(BitVector.parse("0000"), BitVector.from(BigInteger.valueOf(0), 4)); + assertEquals(BitVector.parseBitstring("101"), BitVector.from(BigInteger.valueOf(0b101), 3)); + assertEquals(BitVector.parseBitstring("01010"), BitVector.from(BigInteger.valueOf(0b01010), 5)); + assertEquals(BitVector.parseBitstring("10101"), BitVector.from(BigInteger.valueOf(-11), 5)); + assertEquals(BitVector.parseBitstring("0000"), BitVector.from(BigInteger.valueOf(0), 4)); } @Test @@ -100,7 +100,7 @@ class BitVectorTest void testGetBits() { assertArrayEquals(new Bit[] { X, ONE, Z }, BitVector.of(X, ONE, Z).getBits()); - assertArrayEquals(new Bit[] { X, ONE, Z }, BitVector.parse("X1Z").getBits()); + assertArrayEquals(new Bit[] { X, ONE, Z }, BitVector.parseBitstring("X1Z").getBits()); } @Test @@ -263,15 +263,15 @@ class BitVectorTest @Test void testParse() { - assertEquals(SINGLE_U, BitVector.parse("U")); - assertEquals(SINGLE_X, BitVector.parse("X")); - assertEquals(SINGLE_0, BitVector.parse("0")); - assertEquals(SINGLE_1, BitVector.parse("1")); - assertEquals(SINGLE_Z, BitVector.parse("Z")); + assertEquals(SINGLE_U, BitVector.parseBitstring("U")); + assertEquals(SINGLE_X, BitVector.parseBitstring("X")); + assertEquals(SINGLE_0, BitVector.parseBitstring("0")); + assertEquals(SINGLE_1, BitVector.parseBitstring("1")); + assertEquals(SINGLE_Z, BitVector.parseBitstring("Z")); - assertEquals(BitVector.of(X, U, Z, ONE, ZERO), BitVector.parse("XUZ10")); + assertEquals(BitVector.of(X, U, Z, ONE, ZERO), BitVector.parseBitstring("XUZ10")); - assertThrows(RuntimeException.class, () -> BitVector.parse("01BX")); + assertThrows(RuntimeException.class, () -> BitVector.parseBitstring("01BX")); } @Test diff --git a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2901/TestableAm2901Impl.java b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2901/TestableAm2901Impl.java index bddddea5..ed057e19 100644 --- a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2901/TestableAm2901Impl.java +++ b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2901/TestableAm2901Impl.java @@ -61,13 +61,13 @@ public class TestableAm2901Impl implements TestableAm2901 @Override public void setReg_A(String val_4_bit) { - A.setState(BitVector.parse(val_4_bit)); + A.setState(BitVector.parseBitstring(val_4_bit)); } @Override public void setReg_B(String val_4_bit) { - B.setState(BitVector.parse(val_4_bit)); + B.setState(BitVector.parseBitstring(val_4_bit)); } @Override @@ -85,7 +85,7 @@ public class TestableAm2901Impl implements TestableAm2901 @Override public void setD(String val_4_bit) { - D.setState(BitVector.parse(val_4_bit)); + D.setState(BitVector.parseBitstring(val_4_bit)); } @Override @@ -121,25 +121,25 @@ public class TestableAm2901Impl implements TestableAm2901 @Override public String getQ_0() { - return Qn.getDisplayedValue().toString(); + return Qn.getDisplayedValue().toBitstring(); } @Override public String getQ_3() { - return Qn_3.getDisplayedValue().toString(); + return Qn_3.getDisplayedValue().toBitstring(); } @Override public String getRAM_0() { - return RAMn.getDisplayedValue().toString(); + return RAMn.getDisplayedValue().toBitstring(); } @Override public String getRAM_3() { - return RAMn_3.getDisplayedValue().toString(); + return RAMn_3.getDisplayedValue().toBitstring(); } @Override @@ -157,43 +157,43 @@ public class TestableAm2901Impl implements TestableAm2901 @Override public String getCarryOut() { - return Cn_4.getDisplayedValue().toString(); + return Cn_4.getDisplayedValue().toBitstring(); } @Override public String getSign() { - return F3.getDisplayedValue().toString(); + return F3.getDisplayedValue().toBitstring(); } @Override public String getZero() { - return F_0.getDisplayedValue().toString(); + return F_0.getDisplayedValue().toBitstring(); } @Override public String getOverflow() { - return OVR.getDisplayedValue().toString(); + return OVR.getDisplayedValue().toBitstring(); } @Override public String getY() { - return Y.getDisplayedValue().toString(); + return Y.getDisplayedValue().toBitstring(); } @Override public void setDirectly(Register r, String val_4_bit) { - am2901.setHighLevelState(regToStateID(r), BitVector.parse(val_4_bit)); + am2901.setHighLevelState(regToStateID(r), BitVector.parseBitstring(val_4_bit)); } @Override public String getDirectly(Register r) { - return ((BitVector) am2901.getHighLevelState(regToStateID(r))).toString(); + return ((BitVector) am2901.getHighLevelState(regToStateID(r))).toBitstring(); } private static String regToStateID(Register r) diff --git a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java index b43f130e..99ea5a29 100644 --- a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java +++ b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java @@ -62,7 +62,7 @@ public class TestableAm2904Impl implements TestableAm2904 @Override public void setShiftCode(String val_4_bit) { - I_6_9.setState(BitVector.parse(val_4_bit)); + I_6_9.setState(BitVector.parseBitstring(val_4_bit)); } @Override @@ -80,13 +80,13 @@ public class TestableAm2904Impl implements TestableAm2904 @Override public void setCX(String val_1_bit) { - Cx.setState(BitVector.parse(val_1_bit)); + Cx.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setY(String z_c_n_ovr) { - var bv = BitVector.parse(z_c_n_ovr); + var bv = BitVector.parseBitstring(z_c_n_ovr); // correct order apparently unknown, most likely Z-C-N-OVR YZ.setState(bv.getLSBit(3).toVector()); YC.setState(bv.getLSBit(2).toVector()); @@ -97,103 +97,103 @@ public class TestableAm2904Impl implements TestableAm2904 @Override public void setIZ(String val_1_bit) { - IZ.setState(BitVector.parse(val_1_bit)); + IZ.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setIC(String val_1_bit) { - IC.setState(BitVector.parse(val_1_bit)); + IC.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setIOVR(String val_1_bit) { - IOVR.setState(BitVector.parse(val_1_bit)); + IOVR.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setIN(String val_1_bit) { - IN.setState(BitVector.parse(val_1_bit)); + IN.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_CEM(String val_1_bit) { - _CEM.setState(BitVector.parse(val_1_bit)); + _CEM.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_CEµ(String val_1_bit) { - _CEmu.setState(BitVector.parse(val_1_bit)); + _CEmu.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_OEY(String val_1_bit) { - _OEY.setState(BitVector.parse(val_1_bit)); + _OEY.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_OECT(String val_1_bit) { - _OECT.setState(BitVector.parse(val_1_bit)); + _OECT.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_SE(String val_1_bit) { - _SE.setState(BitVector.parse(val_1_bit)); + _SE.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_EZ(String val_1_bit) { - _EZ.setState(BitVector.parse(val_1_bit)); + _EZ.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_EC(String val_1_bit) { - _EC.setState(BitVector.parse(val_1_bit)); + _EC.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_EOVR(String val_1_bit) { - _EOVR.setState(BitVector.parse(val_1_bit)); + _EOVR.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_EN(String val_1_bit) { - _EN.setState(BitVector.parse(val_1_bit)); + _EN.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setSIO0(String val_1_bit) { - SIO0.setState(BitVector.parse(val_1_bit)); + SIO0.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setSIO3(String val_1_bit) { - SIOn.setState(BitVector.parse(val_1_bit)); + SIOn.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setQIO0(String val_1_bit) { - QIO0.setState(BitVector.parse(val_1_bit)); + QIO0.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setQIO3(String val_1_bit) { - QIOn.setState(BitVector.parse(val_1_bit)); + QIOn.setState(BitVector.parseBitstring(val_1_bit)); } @Override @@ -207,19 +207,19 @@ public class TestableAm2904Impl implements TestableAm2904 @Override public void setDirectly(CompleteStatus r, String z_c_n_ovr) { - am2904.setHighLevelState(regToStateID(r), BitVector.parse(z_c_n_ovr)); + am2904.setHighLevelState(regToStateID(r), BitVector.parseBitstring(z_c_n_ovr)); } @Override public String getC0() { - return C0.getDisplayedValue().toString(); + return C0.getDisplayedValue().toBitstring(); } @Override public String getCT() { - return CT.getDisplayedValue().toString(); + return CT.getDisplayedValue().toBitstring(); } @Override @@ -230,31 +230,31 @@ public class TestableAm2904Impl implements TestableAm2904 var y2 = YC.getDisplayedValue(); var y1 = YN.getDisplayedValue(); var y0 = YOVR.getDisplayedValue(); - return y3.concat(y2).concat(y1).concat(y0).toString(); + return y3.concat(y2).concat(y1).concat(y0).toBitstring(); } @Override public String getSIO0() { - return SIO0.getDisplayedValue().toString(); + return SIO0.getDisplayedValue().toBitstring(); } @Override public String getSIO3() { - return SIOn.getDisplayedValue().toString(); + return SIOn.getDisplayedValue().toBitstring(); } @Override public String getQIO0() { - return QIO0.getDisplayedValue().toString(); + return QIO0.getDisplayedValue().toBitstring(); } @Override public String getQIO3() { - return QIOn.getDisplayedValue().toString(); + return QIOn.getDisplayedValue().toBitstring(); } @Override @@ -268,7 +268,7 @@ public class TestableAm2904Impl implements TestableAm2904 public String getDirectly(CompleteStatus r) { var bv = (BitVector) am2904.getHighLevelState(regToStateID(r)); - return bv.toString(); + return bv.toBitstring(); } private static String regToStateID(Register r) diff --git a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/Am2910Test.java b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/Am2910Test.java index 18b2578d..25966477 100644 --- a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/Am2910Test.java +++ b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/Am2910Test.java @@ -57,8 +57,8 @@ public class Am2910Test @EnumSource(Register.class) void testDirectAccess(Register r) { - String us = U.toVector(r.size()).toString(); - String three = BitVector.from(3, r.size()).toString(); + String us = U.toVector(r.size()).toBitstring(); + String three = BitVector.from(3, r.size()).toBitstring(); assertEquals(us, am2910.getDirectly(r)); diff --git a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/TestableAm2910Impl.java b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/TestableAm2910Impl.java index ef763df2..a4eb5ed4 100644 --- a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/TestableAm2910Impl.java +++ b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/TestableAm2910Impl.java @@ -55,79 +55,79 @@ public class TestableAm2910Impl implements TestableAm2910 @Override public void set_CCEN(String val_1_bit) { - _CCEN.setState(BitVector.parse(val_1_bit)); + _CCEN.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setD(String val_12_bit) { - D.setState(BitVector.parse(val_12_bit)); + D.setState(BitVector.parseBitstring(val_12_bit)); } @Override public void set_CC(String val_1_bit) { - _CC.setState(BitVector.parse(val_1_bit)); + _CC.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setCI(String val_1_bit) { - CI.setState(BitVector.parse(val_1_bit)); + CI.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_RLD(String val_1_bit) { - _RLD.setState(BitVector.parse(val_1_bit)); + _RLD.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void set_OE(String val_1_bit) { - _OE.setState(BitVector.parse(val_1_bit)); + _OE.setState(BitVector.parseBitstring(val_1_bit)); } @Override public void setDirectly(Register r, String val_X_bit) { - am2901.setHighLevelState(regToStateID(r), BitVector.parse(val_X_bit)); + am2901.setHighLevelState(regToStateID(r), BitVector.parseBitstring(val_X_bit)); } @Override public String getY() { - return Y.getDisplayedValue().toString(); + return Y.getDisplayedValue().toBitstring(); } @Override public String get_FULL() { - return _FULL.getDisplayedValue().toString(); + return _FULL.getDisplayedValue().toBitstring(); } @Override public String get_PL() { - return _PL.getDisplayedValue().toString(); + return _PL.getDisplayedValue().toBitstring(); } @Override public String get_MAP() { - return _MAP.getDisplayedValue().toString(); + return _MAP.getDisplayedValue().toBitstring(); } @Override public String get_VECT() { - return _VECT.getDisplayedValue().toString(); + return _VECT.getDisplayedValue().toBitstring(); } @Override public String getDirectly(Register r) { - return am2901.getHighLevelState(regToStateID(r)).toString(); + return ((BitVector) am2901.getHighLevelState(regToStateID(r))).toBitstring(); } private static String regToStateID(Register r) -- 2.17.1