This commit is contained in:
daniel
2017-04-24 22:14:00 -04:00
parent b326f08971
commit 681b4c91ad
20 changed files with 187 additions and 8 deletions

View File

@@ -90,7 +90,7 @@ bool Simulation::parseVector(string fileName) {
string tmpString;
int timeInt, valInt;
Wire *tmpWire;
Wire *tmpWire = nullptr;
// get rid of first line
getline(in, tmpString);
@@ -127,10 +127,15 @@ void Simulation::simulate() {
if(doesChange) {
Gate * tmpGate;
int index = 0;
do{
while(true){
tmpGate = output->getGate(index++);
e.push(tmpGate->evaluate(tmpEvent.getTime()));
}while(tmpGate != nullptr);
if (tmpGate != nullptr) {
e.push(tmpGate->evaluate(tmpEvent.getTime()));
}
else {
break;
}
}
}
}
}
@@ -149,14 +154,13 @@ void Simulation::print()
// now iterate through wires, printing each of them
for(auto i = wires.begin(); i != wires.end(); ++i) {
(**i).setLast(lastTime);
cout << *i;
cout << **i;
}
int t = 0;
cout << setw(10) << "TIME";
cout << setw(5);
while(t <= 60 && t <= lastTime) {
cout << t;
cout << setw(5) << t;
t += 5;
}
}

View File

@@ -57,7 +57,7 @@ void Wire::convertToIO(string newName)
Gate * Wire::getGate(int index)
{
if (index >= gates.size()) {
if (index < gates.size()) {
return gates[index];
}
return nullptr;