27 lines
608 B
C++
27 lines
608 B
C++
#include "simulator.h"
|
|
|
|
void Simulator::simulate(std::vector<LUT*> &inputs, int &score) {
|
|
|
|
assert(inputs.size() == this->PIs.size());
|
|
|
|
for(int i=0; i<inputs.size(); i++) {
|
|
PIs[i]->value = inputs[i]->value;
|
|
}
|
|
|
|
for(auto gate : gates) {
|
|
gate->cal_value();
|
|
}
|
|
|
|
for(auto gate : rtopo_gates) {
|
|
gate->fault_detected[0] = gate->cal_fault_detected(0);
|
|
gate->fault_detected[1] = gate->cal_fault_detected(1);
|
|
}
|
|
|
|
score = 0;
|
|
|
|
for(auto gate : gates) {
|
|
if(gate->fault_detected[0] || gate->fault_detected[1]) {
|
|
score++;
|
|
}
|
|
}
|
|
} |