6a011bee40299fe369b968a00cd351e25055c5d6
[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.WireArrayInput;
11
12 public class NotGate extends BasicComponent
13 {
14         private WireArray in, out;
15         private WireArrayInput outI;
16
17         
18         public NotGate(int processTime, WireArray in, WireArray out)
19         {
20                 super(processTime);
21                 this.in = in;
22                 in.addObserver(this);
23                 this.out = out;
24                 outI = out.createInput();
25         }
26         
27         public void compute()
28         {
29                 outI.feedSignals(Util.not(in.getValues()));
30         }
31
32         public WireArray getIn()
33         {
34                 return in;
35         }
36
37         public WireArray getOut()
38         {
39                 return out;
40         }
41         
42         @Override
43         public List<WireArray> getAllInputs()
44         {
45                 return Collections.unmodifiableList(Arrays.asList(in));
46         }
47
48         @Override
49         public List<WireArray> getAllOutputs()
50         {
51                 return Collections.unmodifiableList(Arrays.asList(out));
52         }
53 }