X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model.verilog%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fverilog%2Fmodel%2Fsignals%2FSignal.java;h=7ccf9cd93025746bb6d7b758a1937c05c67a7caa;hb=4e5e599fd52dccecc907c3f11196d33056041323;hp=e825cede9fe63b6a72656f99ff98836621e73f8a;hpb=c6087221c312e76ad07cf75da61c735278ab8634;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model.verilog/src/net/mograsim/logic/model/verilog/model/signals/Signal.java b/plugins/net.mograsim.logic.model.verilog/src/net/mograsim/logic/model/verilog/model/signals/Signal.java index e825cede..7ccf9cd9 100644 --- a/plugins/net.mograsim.logic.model.verilog/src/net/mograsim/logic/model/verilog/model/signals/Signal.java +++ b/plugins/net.mograsim.logic.model.verilog/src/net/mograsim/logic/model/verilog/model/signals/Signal.java @@ -5,11 +5,13 @@ import java.util.Objects; public abstract class Signal { private final Type type; + private final String name; private final int width; - public Signal(Type type, int width) + public Signal(Type type, String name, int width) { this.type = Objects.requireNonNull(type); + this.name = Objects.requireNonNull(name); this.width = width; check(); @@ -26,18 +28,33 @@ public abstract class Signal return type; } + public String getName() + { + return name; + } + public int getWidth() { return width; } - public abstract String toReferenceVerilogCode(); + public String toReferenceVerilogCode() + { + return name; + } + + @Override + public String toString() + { + return name + "[" + getWidth() + "]"; + } @Override public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + width; return result; @@ -53,6 +70,12 @@ public abstract class Signal if (getClass() != obj.getClass()) return false; Signal other = (Signal) obj; + if (name == null) + { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; if (type != other.type) return false; if (width != other.width) @@ -62,6 +85,6 @@ public abstract class Signal public static enum Type { - WIRE, IO_INPUT, IO_OUTPUT, CONSTANT; + WIRE, IO_INPUT, IO_OUTPUT; } }