Reformatted everything. Eclipse built-in Linewrapping/Comments 140 chars
[Mograsim.git] / era.mi / src / era / mi / logic / components / TriStateBuffer.java
index 4000ae6..a0e7a8b 100644 (file)
@@ -1,18 +1,23 @@
 package era.mi.logic.components;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import era.mi.logic.Bit;
 import era.mi.logic.wires.WireArray;
 import era.mi.logic.wires.WireArray.WireArrayInput;
 
-public class TriStateBuffer extends BasicComponent{
+public class TriStateBuffer extends BasicComponent {
        WireArray in, enable;
        WireArrayInput outI;
-       
+
        public TriStateBuffer(int processTime, WireArray in, WireArray out, WireArray enable) {
                super(processTime);
-               if(in.length != out.length)
-                       throw new IllegalArgumentException("Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length);
-               if(enable.length != 1)
+               if (in.length != out.length)
+                       throw new IllegalArgumentException(
+                                       "Tri-state output must have the same amount of bits as the input. Input: " + in.length + " Output: " + out.length);
+               if (enable.length != 1)
                        throw new IllegalArgumentException("Tri-state enable must have exactly one bit, not " + enable.length + ".");
                this.in = in;
                in.addObserver(this);
@@ -20,14 +25,23 @@ public class TriStateBuffer extends BasicComponent{
                enable.addObserver(this);
                outI = out.createInput();
        }
-       
+
        @Override
-       protected void compute()
-       {
-               if(enable.getValue() == Bit.ONE)
+       protected void compute() {
+               if (enable.getValue() == Bit.ONE)
                        outI.feedSignals(in.getValues());
                else
                        outI.clearSignals();
        }
 
+       @Override
+       public List<WireArray> getAllInputs() {
+               return Collections.unmodifiableList(Arrays.asList(in, enable));
+       }
+
+       @Override
+       public List<WireArray> getAllOutputs() {
+               return Collections.unmodifiableList(Arrays.asList(outI.owner));
+       }
+
 }