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;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user