radec/src/NorGate.cpp

29 lines
577 B
C++
Raw Normal View History

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