Removed unused argument to TriStateBufferConverter's constructor
[Mograsim.git] / plugins / net.mograsim.logic.model.verilog / src / net / mograsim / logic / model / verilog / converter / PinBit.java
1 package net.mograsim.logic.model.verilog.converter;
2
3 import java.util.Objects;
4
5 import net.mograsim.logic.model.model.wires.Pin;
6
7 public class PinBit
8 {
9         private final Pin pin;
10         private final int bit;
11
12         public PinBit(Pin pin, int bit)
13         {
14                 this.pin = Objects.requireNonNull(pin);
15                 this.bit = bit;
16
17                 check();
18         }
19
20         private void check()
21         {
22                 if (bit < 0 || bit >= pin.logicWidth)
23                         throw new IllegalArgumentException("Bit out of range for pin " + pin + ": " + bit);
24         }
25
26         public Pin getPin()
27         {
28                 return pin;
29         }
30
31         public int getBit()
32         {
33                 return bit;
34         }
35
36         public PinNameBit toPinNameBit()
37         {
38                 return new PinNameBit(pin.name, bit);
39         }
40
41         @Override
42         public String toString()
43         {
44                 return pin + "[" + bit + "]";
45         }
46
47         @Override
48         public int hashCode()
49         {
50                 final int prime = 31;
51                 int result = 1;
52                 result = prime * result + bit;
53                 result = prime * result + ((pin == null) ? 0 : pin.hashCode());
54                 return result;
55         }
56
57         @Override
58         public boolean equals(Object obj)
59         {
60                 if (this == obj)
61                         return true;
62                 if (obj == null)
63                         return false;
64                 if (getClass() != obj.getClass())
65                         return false;
66                 PinBit other = (PinBit) obj;
67                 if (bit != other.bit)
68                         return false;
69                 if (pin == null)
70                 {
71                         if (other.pin != null)
72                                 return false;
73                 } else if (!pin.equals(other.pin))
74                         return false;
75                 return true;
76         }
77 }