add undefined logic to all gates

This commit is contained in:
Joel Beckmeyer 2017-04-25 10:10:07 -04:00
parent 93a176884d
commit fb0c023cf4
7 changed files with 25 additions and 5 deletions

View File

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

View File

@ -13,9 +13,12 @@ Event NandGate::evaluate(int evTime)
if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) {
return Event(-1, 1, evTime + delay, out);
}
else {
else if (in1->getValue(evTime) == 1 && in2->getValue(evTime) == 1) {
return Event(-1, 0, evTime + delay, out);
}
else{
return Event(-1, -1, evTime + delay, out);
}
}
int NandGate::getDelay()

View File

@ -16,6 +16,9 @@ Event NorGate::evaluate(int evTime) {
else if (in1->getValue(evTime) == 0 && in2->getValue(evTime) == 0) {
return Event(-1, 1, evTime + delay, out);
}
else{
return Event(-1, -1, evTime + delay, out);
}
}
int NorGate::getDelay()

View File

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

View File

@ -16,6 +16,9 @@ Event OrGate::evaluate(int evTime) {
else if (in1->getValue(evTime) == 0 && in2->getValue(evTime) == 0) {
return Event(-1, 0, evTime + delay, out);
}
else{
return Event(-1, -1, evTime + delay, out);
}
}
int OrGate::getDelay()

View File

@ -18,6 +18,9 @@ Event XnorGate::evaluate(int evTime) {
return Event(-1, 0, evTime + delay, out);
}
}
else {
return Event(-1, -1, evTime + delay, out);
}
}
int XnorGate::getDelay()

View File

@ -18,6 +18,9 @@ Event XorGate::evaluate(int evTime) {
return Event(-1, 0, evTime + delay, out);
}
}
else {
return Event(-1, -1, evTime + delay, out);
}
}
int XorGate::getDelay()