This commit is contained in:
daniel 2017-04-24 21:06:00 -04:00
commit a005f92560

View File

@ -109,12 +109,36 @@ bool Simulation::parseVector(string fileName) {
} }
} }
void Simulation::simulate() void Simulation::simulate() {
{ // loop through event queue
while(!e.empty()) {
bool doesChange;
Wire * output;
Event tmpEvent = e.top();
e.pop();
output = tmpEvent.getOutput();
doesChange = output->setValue(tmpEvent.getValue(), tmpEvent.getTime());
// if the wire value changes, evaluate gates
if(doesChange) {
Gate * tmpGate;
int index = 0;
do{
tmpGate = output->getGate(index++);
e.push(tmpGate->evaluate(tmpEvent.evTime));
}while(tmpGate != nullptr);
}
}
} }
void Simulation::print() void Simulation::print()
{ {
// iterate through wires, printing each of them
for(auto i = wires.begin(); i != wires.end(); ++i) {
cout << *i;
}
} }
Wire * Simulation::findWire(int n) Wire * Simulation::findWire(int n)