radec/src/XnorGate.cpp

27 lines
488 B
C++
Raw Normal View History

2017-04-23 19:18:11 -04:00
#include "XnorGate.h"
using namespace std;
XnorGate::XnorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3) {
delay = d;
in1 = wire1;
in2 = wire2;
out = wire3;
}
Event XnorGate::evaluate(int evTime) {
2017-04-23 19:18:11 -04:00
if (in1->getValue(evTime) != -1 && in2->getValue(evTime) != -1) {
if (in1->getValue(evTime) == in2->getValue(evTime)) {
2017-04-24 22:25:51 -04:00
return Event(-1, 1, evTime + delay, out);
2017-04-23 19:18:11 -04:00
}
else {
2017-04-24 22:25:51 -04:00
return Event(-1, 0, evTime + delay, out);
2017-04-23 19:18:11 -04:00
}
}
}
int XnorGate::getDelay()
{
return delay;
}