-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.components.BasicComponent;
-import era.mi.logic.wires.WireArray;
-import era.mi.logic.wires.WireArray.WireArrayInput;
-
-public class XorGate extends BasicComponent
-{
- private WireArray a, b, out;
- private WireArrayInput outI;
-
- public XorGate(int processTime, WireArray a, WireArray b, WireArray out)
- {
- super(processTime);
- this.a = a;
- a.addObserver(this);
- this.b = b;
- b.addObserver(this);
- this.out = out;
- }
-
- protected void compute()
- {
- outI.feedSignals(Util.xor(a.getValues(), b.getValues()));
- }
-
- public WireArray getA()
- {
- return a;
- }
-
- public WireArray getB()
- {
- return b;
- }
-
- public WireArray getOut()
- {
- return out;
- }
-
- @Override
- public List<WireArray> getAllInputs()
- {
- return Collections.unmodifiableList(Arrays.asList(a, b));
- }
-
- @Override
- public List<WireArray> getAllOutputs()
- {
- return Collections.unmodifiableList(Arrays.asList(out));
- }
-}
+package era.mi.logic.components.gates;\r
+\r
+import era.mi.logic.Util;\r
+import era.mi.logic.wires.WireArray;\r
+\r
+/**\r
+ * Outputs 1 when the number of 1 inputs is odd.\r
+ * \r
+ * @author Fabian Stemmler\r
+ */\r
+public class XorGate extends MultiInputGate {\r
+ public XorGate(int processTime, WireArray out, WireArray... in) {\r
+ super(processTime, Util::xor, out, in);\r
+ }\r
+\r
+}\r