Improvements in the ModelComponentToVerilogConverter:
[Mograsim.git] / plugins / net.mograsim.logic.model.verilog / src / net / mograsim / logic / model / verilog / model / statements / WireDeclaration.java
1 package net.mograsim.logic.model.verilog.model.statements;
2
3 import java.util.Objects;
4 import java.util.Set;
5
6 import net.mograsim.logic.model.verilog.model.signals.Signal;
7 import net.mograsim.logic.model.verilog.model.signals.Wire;
8
9 public class WireDeclaration extends Statement
10 {
11         private final Wire wire;
12
13         public WireDeclaration(Wire wire)
14         {
15                 this.wire = Objects.requireNonNull(wire);
16         }
17
18         public Wire getWire()
19         {
20                 return wire;
21         }
22
23         @Override
24         public String toVerilogCode()
25         {
26                 return wire.toDeclarationVerilogCode();
27         }
28
29         @Override
30         public Set<String> getDefinedNames()
31         {
32                 return Set.of(wire.getName());
33         }
34
35         @Override
36         public Set<Signal> getDefinedSignals()
37         {
38                 return Set.of(wire);
39         }
40
41         @Override
42         public Set<Signal> getReferencedSignals()
43         {
44                 return Set.of();
45         }
46
47         @Override
48         public String toString()
49         {
50                 return "decl[" + wire.toString() + "]";
51         }
52
53         @Override
54         public int hashCode()
55         {
56                 final int prime = 31;
57                 int result = 1;
58                 result = prime * result + ((wire == null) ? 0 : wire.hashCode());
59                 return result;
60         }
61
62         @Override
63         public boolean equals(Object obj)
64         {
65                 if (this == obj)
66                         return true;
67                 if (obj == null)
68                         return false;
69                 if (getClass() != obj.getClass())
70                         return false;
71                 WireDeclaration other = (WireDeclaration) obj;
72                 if (wire == null)
73                 {
74                         if (other.wire != null)
75                                 return false;
76                 } else if (!wire.equals(other.wire))
77                         return false;
78                 return true;
79         }
80 }