add undefined logic to all gates
This commit is contained in:
parent
93a176884d
commit
fb0c023cf4
@ -16,6 +16,9 @@ Event AndGate::evaluate(int evTime) {
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -9,11 +9,13 @@ 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 if (in1->getValue(evTime) == 0) {
|
||||
return Event(-1, 1, evTime + delay, out);
|
||||
}
|
||||
else {
|
||||
return Event(-1, 1, evTime + delay, out);
|
||||
return Event(-1, -1, evTime + delay, out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user