Wires now can have a name
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 3 Jun 2019 12:12:35 +0000 (14:12 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 3 Jun 2019 12:12:35 +0000 (14:12 +0200)
net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java

index 89fcb80..6e4e50a 100644 (file)
@@ -21,6 +21,7 @@ import net.mograsim.logic.core.types.BitVector.BitVectorMutator;
  */\r
 public class Wire\r
 {\r
+       public final String name;\r
        private BitVector values;\r
        public final int travelTime;\r
        private List<ReadEnd> attached = new ArrayList<>();\r
@@ -29,10 +30,16 @@ public class Wire
        Timeline timeline;\r
 \r
        public Wire(Timeline timeline, int length, int travelTime)\r
+       {\r
+               this(timeline, length, travelTime, null);\r
+       }\r
+\r
+       public Wire(Timeline timeline, int length, int travelTime, String name)\r
        {\r
                if (length < 1)\r
                        throw new IllegalArgumentException(\r
                                        String.format("Tried to create an array of wires with length %d, but a length of less than 1 makes no sense.", length));\r
+               this.name = name;\r
                this.timeline = timeline;\r
                this.length = length;\r
                this.travelTime = travelTime;\r
@@ -491,7 +498,8 @@ public class Wire
        @Override\r
        public String toString()\r
        {\r
-               return String.format("wire 0x%08x value: %s inputs: %s", hashCode(), values, inputs);\r
+               String name = this.name == null ? String.format("0x%08x", hashCode()) : this.name;\r
+               return String.format("wire %s value: %s inputs: %s", name, values, inputs);\r
        }\r
 \r
        public static ReadEnd[] extractEnds(Wire[] w)\r