Merge branch 'master' of https://daniel12997@gitlab.com/AluminumTank/radec.git
This commit is contained in:
commit
a005f92560
@ -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()
|
||||
{
|
||||
// iterate through wires, printing each of them
|
||||
for(auto i = wires.begin(); i != wires.end(); ++i) {
|
||||
cout << *i;
|
||||
}
|
||||
}
|
||||
|
||||
Wire * Simulation::findWire(int n)
|
||||
|
Loading…
Reference in New Issue
Block a user