finish the program and fix when a wire goes undefined
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user