refactored the xor-xnor dependency

This commit is contained in:
hneemann 2016-08-20 20:29:03 +02:00
parent 31cd0d1b4b
commit b87c5869c6
2 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package de.neemann.digital.core.basic; package de.neemann.digital.core.basic;
import de.neemann.digital.core.NodeException;
import de.neemann.digital.core.element.ElementAttributes; import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription; import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys; import de.neemann.digital.core.element.Keys;
@ -31,7 +30,7 @@ public class XNOr extends XOr {
} }
@Override @Override
public void readInputs() throws NodeException { protected long calc(long a, long b) {
value = ~(a.getValue() ^ b.getValue()); return ~super.calc(a, b);
} }
} }

View File

@ -23,9 +23,9 @@ public class XOr extends Node implements Element {
private final int bits; private final int bits;
private final ObservableValue out; private final ObservableValue out;
protected ObservableValue a; private ObservableValue a;
protected ObservableValue b; private ObservableValue b;
protected long value; private long value;
/** /**
* Creates a new instance * Creates a new instance
@ -39,7 +39,18 @@ public class XOr extends Node implements Element {
@Override @Override
public void readInputs() throws NodeException { public void readInputs() throws NodeException {
value = a.getValue() ^ b.getValue(); value = calc(a.getValue(), b.getValue());
}
/**
* Performs the operation
*
* @param a a
* @param b b
* @return result
*/
protected long calc(long a, long b) {
return a ^ b;
} }
@Override @Override