1 package net.mograsim.logic.model.verilog.model.expressions;
5 import net.mograsim.logic.core.types.BitVector;
6 import net.mograsim.logic.model.verilog.model.signals.Signal;
8 public class Constant extends Expression
10 private final BitVector constant;
12 public Constant(BitVector constant)
14 super(constant.length());
15 this.constant = constant;
22 if (!constant.isBinary())
23 throw new IllegalArgumentException("Constant is not binary: " + constant);
26 public BitVector getConstant()
32 public String toVerilogCode()
34 return getWidth() + "'b" + constant.toBitstring();
38 public Set<Signal> getReferencedSignals()
47 int result = super.hashCode();
48 result = prime * result + ((constant == null) ? 0 : constant.hashCode());
53 public boolean equals(Object obj)
57 if (!super.equals(obj))
59 if (getClass() != obj.getClass())
61 Constant other = (Constant) obj;
64 if (other.constant != null)
66 } else if (!constant.equals(other.constant))