Remove old code from evaluate functions for and and not gates.

This commit is contained in:
daniel 2017-04-24 22:25:29 -04:00
parent fe794c6725
commit 1958336d29
3 changed files with 5 additions and 16 deletions

View File

@ -10,14 +10,11 @@ AndGate::AndGate(int d, Wire* wire1, Wire* wire2, Wire* wire3) {
}
Event AndGate::evaluate(int evTime) {
if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) {
if (out->getValue(evTime + delay) != 0) {
return Event(-1, 0, evTime + delay, out);
}
return Event(-1, 0, evTime + delay, out);
}
else if(in1->getValue(evTime) == 1 && in2->getValue(evTime) == 1){
if (out->getValue(evTime + delay) != 1) {
return Event(-1, 1, evTime + delay, out);
}
return Event(-1, 1, evTime + delay, out);
}
}

View File

@ -11,14 +11,10 @@ NandGate::NandGate(int d, Wire * wire1, Wire * wire2, Wire * wire3)
Event NandGate::evaluate(int evTime)
{
if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) {
if (out->getValue(evTime + delay) != 1) {
return Event(-1, 1, evTime + delay, out);
}
return Event(-1, 1, evTime + delay, out);
}
else {
if (out->getValue(evTime + delay) != 0) {
return Event(-1, 0, evTime + delay, out);
}
return Event(-1, 0, evTime + delay, out);
}
}

View File

@ -10,14 +10,10 @@ NotGate::NotGate(int d, Wire* wire1, Wire* wire2) {
Event NotGate::evaluate(int evTime) {
if (in1->getValue(evTime) == 0) {
if (out->getValue(evTime + delay) != 0) {
return Event(-1, 0, evTime + delay, out);
}
}
else{
if (out->getValue(evTime + delay) != 1) {
return Event(-1, 1, evTime + delay, out);
}
}
}