projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made ManualSwitch non-final to make GUIManualSwitch possible
[Mograsim.git]
/
era.mi
/
src
/
era
/
mi
/
logic
/
components
/
gates
/
XorGate.java
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
9287f3f
..
c20af6f
100644
(file)
--- 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,17
@@
package era.mi.logic.components.gates;
import era.mi.logic.Util;
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)
+/**
+ * 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);
- this.a = a;
- a.addObserver(this);
- this.b = b;
- b.addObserver(this);
- this.out = out;
+ 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;
- }
}
}