toString now returns '-' for BitVectors consisting only of Z
authorFabian Stemmler <stemmler@in.tum.de>
Sat, 12 Oct 2019 11:17:05 +0000 (13:17 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Sat, 12 Oct 2019 11:17:05 +0000 (13:17 +0200)
plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java

index 1346694..ec6d12d 100644 (file)
@@ -111,6 +111,16 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
                return true;
        }
 
+       public boolean isHighImpedance()
+       {
+               for (int i = 0; i < bits.length; i++)
+               {
+                       if (!bits[i].equals(Bit.Z))
+                               return false;
+               }
+               return true;
+       }
+
        @Override
        public BitVector join(BitVector t)
        {
@@ -404,6 +414,8 @@ public final class BitVector implements StrictLogicType<BitVector>, Iterable<Bit
        @Override
        public String toString()
        {
+               if (isHighImpedance())
+                       return "-";
                StringBuilder sb = new StringBuilder(bits.length);
                for (Bit bit : bits)
                        sb.append(bit);