X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2Fgates%2FXorGate.java;h=2532c9fe32a5c3226ad4be911abff49010bfea9f;hb=74aebd92f41d03f4a44c9a455ef8c05465136412;hp=c7a945500988db65c4a1d1794f0958d57210b2fb;hpb=ebe86d1517aea138ffb6485b7bd2dff31fdb1253;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 c7a94550..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,42 +1,16 @@ package era.mi.logic.components.gates; 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; +/** + * 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() - { - outI.feedSignals(Util.xor(a.getValues(), b.getValues())); - } - - public WireArray getA() - { - return a; - } - - public WireArray getB() - { - return b; - } - - public WireArray getOut() - { - return out; - } }