finish the program and fix when a wire goes undefined

This commit is contained in:
daniel
2017-04-25 14:38:15 -04:00
parent e7afee35aa
commit 4f3f006d0d
6 changed files with 29 additions and 6 deletions

View File

@@ -11,7 +11,6 @@ NandGate::NandGate(int d, Wire * wire1, Wire * wire2, Wire * wire3)
Event NandGate::evaluate(int evTime)
{
cout << evTime << " " << in1->getValue(evTime) << " " << in2->getValue(evTime) << endl;
if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) {
return Event(1, evTime + delay, out);
}

View File

@@ -110,8 +110,8 @@ bool Simulation::parseVector(string fileName) {
return false;
}
string tmpString;
int timeInt, valInt;
string tmpString, valInt;
int timeInt;
Wire *tmpWire = nullptr;
// get rid of first line
@@ -129,7 +129,12 @@ bool Simulation::parseVector(string fileName) {
}
}
e.push(Event(valInt, timeInt, tmpWire));
if (valInt == "X") {
e.push(Event(-1, timeInt, tmpWire));
}
else {
e.push(Event(atoi(valInt.c_str()), timeInt, tmpWire));
}
}
}