X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2Fgates%2FXorGate.java;fp=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2Fgates%2FXorGate.java;h=9287f3fd3e9999f2501a7a76bf64f032b3b3d9ca;hb=a4c5cfb856026771dfcf31eb22434b8b6ff20ad4;hp=0000000000000000000000000000000000000000;hpb=7199371e42ba04d2daab9f8512fdf25bd5f5ff92;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 new file mode 100644 index 00000000..9287f3fd --- /dev/null +++ b/era.mi/src/era/mi/logic/components/gates/XorGate.java @@ -0,0 +1,40 @@ +package era.mi.logic.components.gates; + +import era.mi.logic.Util; +import era.mi.logic.WireArray; +import era.mi.logic.components.BasicComponent; + +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; + } + + 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; + } +}