Some work on improving BitVector<->String conversions
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 12 Oct 2019 12:57:30 +0000 (14:57 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 12 Oct 2019 12:57:30 +0000 (14:57 +0200)
plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java
plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVectorFormatter.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelBitDisplay.java
plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/MainMemoryParser.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MachineRegister.java
tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2901/TestableAm2901Impl.java
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/Am2910Test.java
tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/am2910/TestableAm2910Impl.java

index 4b10292..3ca16a1 100644 (file)
@@ -406,13 +406,18 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
                return Arrays.equals(bits, offset, offset + other.length(), other.bits, 0, other.length());
        }
 
+       @Override
+       public String toString()
+       {
+               return toBitstring();
+       }
+
        /**
         * All {@link Bit}s symbols concatenated together (MSB first)
         * 
-        * @see #parse(String)
+        * @see #parseBitstring(String)
         */
-       @Override
-       public String toString()
+       public String toBitstring()
        {
                StringBuilder sb = new StringBuilder(bits.length);
                for (Bit bit : bits)
@@ -475,9 +480,9 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
        /**
         * Parses a String containing solely {@link Bit} symbols (MSB first)
         * 
-        * @see #toString()
+        * @see #toBitString()
         */
-       public static BitVector parse(String s)
+       public static BitVector parseBitstring(String s)
        {
                Bit[] values = new Bit[s.length()];
                for (int i = 0; i < s.length(); i++)
index 5f645a2..b24e342 100644 (file)
@@ -1,5 +1,7 @@
 package net.mograsim.logic.core.types;
 
+import java.math.BigInteger;
+
 import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
 import net.mograsim.preferences.ColorDefinition;
 import net.mograsim.preferences.ColorDefinition.BuiltInColor;
@@ -12,11 +14,57 @@ public class BitVectorFormatter
                return formatAsString(end == null ? null : end.getValues());
        }
 
+       public static String toBitstring(BitVector bitVector)
+       {
+               return bitVector.toBitstring();
+       }
+
        public static String formatAsString(BitVector bitVector)
        {
                if (bitVector == null)
                        return "null";
-               return bitVector.toString();
+               if (bitVector.isBinary())
+               {
+                       String hexdigits = bitVector.getUnsignedValue().toString(16);
+                       StringBuilder sb = new StringBuilder();
+                       sb.append("0x");
+                       sb.append("0".repeat((bitVector.length() + 3) / 4 - hexdigits.length()));
+                       sb.append(hexdigits);
+                       return sb.toString();
+               }
+               if (bitVector.isHighImpedance())
+                       return "-";
+               return bitVector.toBitstring();
+       }
+
+       // TODO this method overlaps in functionality with AsmNumberUtil (in plugin.core)
+       public static BitVector parseUserBitVector(String userInput, int width)
+       {
+               BitVector bitvector = null;
+               if (width > 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?
index 5fd58c1..9675167 100644 (file)
@@ -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)
index 5be3e22..ac33266 100644 (file)
@@ -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);
index ea87296..d52efdc 100644 (file)
@@ -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;
index 59e22f8..e470420 100644 (file)
@@ -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
index 317e8ab..d9b9068 100644 (file)
@@ -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
index bddddea..ed057e1 100644 (file)
@@ -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)
index b43f130..99ea5a2 100644 (file)
@@ -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)
index 18b2578..2596647 100644 (file)
@@ -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));
 
index ef763df..a4eb5ed 100644 (file)
@@ -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)