added demux; added getAllInputs() and getAllOutputs() for all components
[Mograsim.git] / era.mi / src / era / mi / logic / components / gates / NotGate.java
index 55d0cb0..6a011be 100644 (file)
@@ -1,12 +1,19 @@
 package era.mi.logic.components.gates;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import era.mi.logic.Util;
-import era.mi.logic.WireArray;
 import era.mi.logic.components.BasicComponent;
+import era.mi.logic.wires.WireArray;
+import era.mi.logic.wires.WireArray.WireArrayInput;
 
 public class NotGate extends BasicComponent
 {
        private WireArray in, out;
+       private WireArrayInput outI;
+
        
        public NotGate(int processTime, WireArray in, WireArray out)
        {
@@ -14,11 +21,12 @@ public class NotGate extends BasicComponent
                this.in = in;
                in.addObserver(this);
                this.out = out;
+               outI = out.createInput();
        }
        
        public void compute()
        {
-               out.feedSignals(Util.not(in.getValues()));
+               outI.feedSignals(Util.not(in.getValues()));
        }
 
        public WireArray getIn()
@@ -30,4 +38,16 @@ public class NotGate extends BasicComponent
        {
                return out;
        }
+       
+       @Override
+       public List<WireArray> getAllInputs()
+       {
+               return Collections.unmodifiableList(Arrays.asList(in));
+       }
+
+       @Override
+       public List<WireArray> getAllOutputs()
+       {
+               return Collections.unmodifiableList(Arrays.asList(out));
+       }
 }