Reformatted everything. Eclipse built-in Linewrapping/Comments 140 chars
[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         private WireArray in, out;
14         private WireArrayInput outI;
15
16         public NotGate(int processTime, WireArray in, WireArray out) {
17                 super(processTime);
18                 this.in = in;
19                 in.addObserver(this);
20                 this.out = out;
21                 outI = out.createInput();
22         }
23
24         public void compute() {
25                 outI.feedSignals(Util.not(in.getValues()));
26         }
27
28         public WireArray getIn() {
29                 return in;
30         }
31
32         public WireArray getOut() {
33                 return out;
34         }
35
36         @Override
37         public List<WireArray> getAllInputs() {
38                 return Collections.unmodifiableList(Arrays.asList(in));
39         }
40
41         @Override
42         public List<WireArray> getAllOutputs() {
43                 return Collections.unmodifiableList(Arrays.asList(out));
44         }
45 }