32 lines
677 B
C++
32 lines
677 B
C++
|
#include "NorGate.h"
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
NorGate::NorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3) {
|
||
|
e = eQueue;
|
||
|
delay = d;
|
||
|
in1 = wire1;
|
||
|
in2 = wire2;
|
||
|
out = wire3;
|
||
|
}
|
||
|
|
||
|
void NorGate::evaluate(int evTime) {
|
||
|
if (in1->getValue(evTime) == 1 || in2->getValue(evTime) == 1) {
|
||
|
if (out->getValue(evTime + delay) != 0) {
|
||
|
e->push(event(e->size, 0, evTime + delay, out));
|
||
|
out->setValue(0, evTime + delay);
|
||
|
}
|
||
|
}
|
||
|
else if (in1->getValue(evTime) == 0 && in2->getValue(evTime) == 0) {
|
||
|
if (out->getValue(evTime + delay) != 1) {
|
||
|
e->push(event(e->size, 1, evTime + delay, out));
|
||
|
out->setValue(1, evTime + delay);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int NorGate::getDelay()
|
||
|
{
|
||
|
return delay;
|
||
|
}
|