X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2Fgates%2FXorGate.java;h=2532c9fe32a5c3226ad4be911abff49010bfea9f;hb=74aebd92f41d03f4a44c9a455ef8c05465136412;hp=9287f3fd3e9999f2501a7a76bf64f032b3b3d9ca;hpb=a4c5cfb856026771dfcf31eb22434b8b6ff20ad4;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/components/gates/XorGate.java b/era.mi/src/era/mi/logic/components/gates/XorGate.java index 9287f3fd..2532c9fe 100644 --- a/era.mi/src/era/mi/logic/components/gates/XorGate.java +++ b/era.mi/src/era/mi/logic/components/gates/XorGate.java @@ -1,40 +1,16 @@ package era.mi.logic.components.gates; import era.mi.logic.Util; -import era.mi.logic.WireArray; -import era.mi.logic.components.BasicComponent; +import era.mi.logic.wires.WireArray; -public class XorGate extends BasicComponent -{ - private WireArray a, b, out; - - 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; +/** + * Outputs 1 when the number of 1 inputs is odd. + * + * @author Fabian Stemmler + */ +public class XorGate extends MultiInputGate { + public XorGate(int processTime, WireArray out, WireArray... in) { + super(processTime, Util::xor, out, in); } - protected void compute() - { - out.feedSignals(Util.xor(a.getValues(), b.getValues())); - } - - public WireArray getA() - { - return a; - } - - public WireArray getB() - { - return b; - } - - public WireArray getOut() - { - return out; - } }