blob: 84fb1ec7185f90dfdf9e44026fe6672212ca6978 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "GateXor.h"
GateXor GateXor::instance(GateXor::type);
SignalLevel GateXor::level() {
int highCount = 0;
for (int i = 0; i < this->inputs.size(); i++) {
SignalLevel l = this->inputs[i]->getLevel();
if (l == UNDEFINED) return UNDEFINED;
if (l == HIGH) highCount++;
}
return (highCount % 2 == 1) ? HIGH : LOW;
}
GateXor::GateXor(const GateXor *prototype) : Node() {}
GateXor *GateXor::clone() const {
return new GateXor(this);
}
|