Wire concept was changed to accommodate multiple inputs. Not all
[Mograsim.git] / era.mi / src / era / mi / logic / components / gates / AndGate.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 AndGate extends BasicComponent
9 {
10         private WireArray a, b, out;
11         private WireArrayInput outI;
12         
13         public AndGate(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                 outI = out.createInput();
22         }
23
24         protected void compute()
25         {
26                 outI.feedSignals(Util.and(a.getValues(), b.getValues()));
27         }
28
29         public WireArray getA()
30         {
31                 return a;
32         }
33
34         public WireArray getB()
35         {
36                 return b;
37         }
38
39         public WireArray getOut()
40         {
41                 return out;
42         }
43 }