Wire concept was changed to accommodate multiple inputs. Not all
[Mograsim.git] / era.mi / src / era / mi / logic / components / gates / XorGate.java
1 package era.mi.logic.components.gates;
2
3 import era.mi.logic.Util;
4 import era.mi.logic.components.BasicComponent;
5 import era.mi.logic.wires.WireArray;
6 import era.mi.logic.wires.WireArray.WireArrayInput;
7
8 public class XorGate extends BasicComponent
9 {
10         private WireArray a, b, out;
11         private WireArrayInput outI;
12         
13         public XorGate(int processTime, WireArray a, WireArray b, WireArray out)
14         {
15                 super(processTime);
16                 this.a = a;
17                 a.addObserver(this);
18                 this.b = b;
19                 b.addObserver(this);
20                 this.out = out;
21         }
22
23         protected void compute()
24         {
25                 outI.feedSignals(Util.xor(a.getValues(), b.getValues()));
26         }
27
28         public WireArray getA()
29         {
30                 return a;
31         }
32
33         public WireArray getB()
34         {
35                 return b;
36         }
37
38         public WireArray getOut()
39         {
40                 return out;
41         }
42 }