c4821159b386bd022e9ad4266a471df2e31c809d
[Mograsim.git] / era.mi / src / era / mi / logic / components / gates / NotGate.java
1 package era.mi.logic.components.gates;
2
3 import java.util.Arrays;
4 import java.util.Collections;
5 import java.util.List;
6
7 import era.mi.logic.Util;
8 import era.mi.logic.components.BasicComponent;
9 import era.mi.logic.wires.WireArray;
10 import era.mi.logic.wires.WireArray.WireArrayEnd;
11
12 public class NotGate extends BasicComponent
13 {
14         private WireArray in, out;
15         private WireArrayEnd outI;
16
17         public NotGate(int processTime, WireArray in, WireArray out)
18         {
19                 super(processTime);
20                 this.in = in;
21                 in.addObserver(this);
22                 this.out = out;
23                 outI = out.createInput();
24         }
25
26         public void compute()
27         {
28                 outI.feedSignals(Util.not(in.getValues()));
29         }
30
31         public WireArray getIn()
32         {
33                 return in;
34         }
35
36         public WireArray getOut()
37         {
38                 return out;
39         }
40
41         @Override
42         public List<WireArray> getAllInputs()
43         {
44                 return Collections.unmodifiableList(Arrays.asList(in));
45         }
46
47         @Override
48         public List<WireArray> getAllOutputs()
49         {
50                 return Collections.unmodifiableList(Arrays.asList(out));
51         }
52 }