1 package net.mograsim.logic.model.verilog.converter;
3 import java.util.Objects;
5 import net.mograsim.logic.model.verilog.model.IOPort;
6 import net.mograsim.logic.model.verilog.model.Signal;
8 public class VerilogEmulatedModelPin
10 private final IOPort verilogPort;
11 private final int portIndex;
12 private final PinNameBit pinbit;
13 private final Type type;
15 public VerilogEmulatedModelPin(IOPort verilogPort, int portIndex, PinNameBit pinbit, Type type)
17 this.verilogPort = Objects.requireNonNull(verilogPort);
18 this.portIndex = portIndex;
19 this.pinbit = Objects.requireNonNull(pinbit);
20 this.type = Objects.requireNonNull(type);
27 if (verilogPort.getWidth() != 2)
28 throw new IllegalArgumentException("Every Verilog port has to have width 2");
30 throw new IllegalArgumentException("Negative port index can't be negative");
34 if (verilogPort.getType() != Signal.Type.IO_INPUT)
35 throw new IllegalArgumentException("A PRE pin has to be an input");
38 if (verilogPort.getType() != Signal.Type.IO_OUTPUT)
39 throw new IllegalArgumentException("A OUT pin has to be an output");
42 if (verilogPort.getType() != Signal.Type.IO_INPUT)
43 throw new IllegalArgumentException("A RES pin has to be an input");
46 throw new IllegalStateException("Unknown enum constant: " + type);
50 public IOPort getVerilogPort()
55 public int getPortIndex()
60 public PinNameBit getPinbit()
75 result = prime * result + ((pinbit == null) ? 0 : pinbit.hashCode());
76 result = prime * result + portIndex;
77 result = prime * result + ((type == null) ? 0 : type.hashCode());
78 result = prime * result + ((verilogPort == null) ? 0 : verilogPort.hashCode());
83 public boolean equals(Object obj)
89 if (getClass() != obj.getClass())
91 VerilogEmulatedModelPin other = (VerilogEmulatedModelPin) obj;
94 if (other.pinbit != null)
96 } else if (!pinbit.equals(other.pinbit))
98 if (portIndex != other.portIndex)
100 if (type != other.type)
102 if (verilogPort == null)
104 if (other.verilogPort != null)
106 } else if (!verilogPort.equals(other.verilogPort))
111 public static enum Type