radec/src/NotGate.cpp

27 lines
495 B
C++
Raw Normal View History

2017-04-23 19:13:23 -04:00
#include "NotGate.h"
using namespace std;
NotGate::NotGate(int d, Wire* wire1, Wire* wire2) {
delay = d;
in1 = wire1;
out = wire2;
}
2017-04-26 11:20:20 -04:00
// generate an event based on changes in the Gate's inputs
Event NotGate::evaluate(int evTime) {
2017-04-25 10:10:07 -04:00
if (in1->getValue(evTime) == 1) {
return Event(0, evTime + delay, out);
2017-04-25 10:10:07 -04:00
}else if (in1->getValue(evTime) == 0) {
return Event(1, evTime + delay, out);
2017-04-23 19:13:23 -04:00
}
2017-04-25 10:10:07 -04:00
else {
return Event(-1, evTime + delay, out);
2017-04-25 10:10:07 -04:00
}
2017-04-23 19:13:23 -04:00
}
int NotGate::getDelay()
{
return delay;
}