X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2Fgates%2FXorGate.java;h=ad2f829671380457d796746718ae6a0f1ecdfdd8;hb=4712d3e6ee08461b7754dbfba1c9e82372bb474d;hp=c7a945500988db65c4a1d1794f0958d57210b2fb;hpb=fa95c348b3b8fb9681e4bf5c8284c5ac8eeed518;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..ad2f8296 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,18 @@ 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 +/** + * Outputs 1 when the number of 1 inputs is odd. + * + * @author Fabian Stemmler + */ +public class XorGate extends MultiInputGate { - private WireArray a, b, out; - private WireArrayInput outI; - - public XorGate(int processTime, WireArray a, WireArray b, WireArray out) + public XorGate(int processTime, WireArray out, WireArray... in) { - super(processTime); - this.a = a; - a.addObserver(this); - this.b = b; - b.addObserver(this); - this.out = out; + 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; - } }