mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 16:01:19 -04:00
refactored the xor-xnor dependency
This commit is contained in:
parent
31cd0d1b4b
commit
b87c5869c6
@ -1,6 +1,5 @@
|
||||
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.ElementTypeDescription;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -31,7 +30,7 @@ public class XNOr extends XOr {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readInputs() throws NodeException {
|
||||
value = ~(a.getValue() ^ b.getValue());
|
||||
protected long calc(long a, long b) {
|
||||
return ~super.calc(a, b);
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ public class XOr extends Node implements Element {
|
||||
|
||||
private final int bits;
|
||||
private final ObservableValue out;
|
||||
protected ObservableValue a;
|
||||
protected ObservableValue b;
|
||||
protected long value;
|
||||
private ObservableValue a;
|
||||
private ObservableValue b;
|
||||
private long value;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
@ -39,7 +39,18 @@ public class XOr extends Node implements Element {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user