aboutsummaryrefslogtreecommitdiff
path: root/GateXor.cpp
blob: 44154bd8bfae371f3bfe5763d3a90fe5bc8e5987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "GateXor.h"

GateXor GateXor::instance(GateXor::type);

SignalLevel GateXor::level() {
	bool on = false;
	for (int i = 0; i < this->inputs.size(); i++) {
		SignalLevel l = this->inputs[i]->getLevel();

		if (l == UNDEFINED) return UNDEFINED;
		if (l == HIGH) on = !on;
	}
	return on ? HIGH : LOW;
}

GateXor::GateXor(const GateXor * prototype) : Node() {}

GateXor * GateXor::clone() const {
	return new GateXor(this);
}