v1.2: 过程中仿真采样输出

This commit is contained in:
YuhangQ 2023-08-10 02:15:06 +00:00
parent 0431ca531a
commit 7a3e157bb7
10 changed files with 49 additions and 5658 deletions

BIN
atpg

Binary file not shown.

View File

@ -142,6 +142,27 @@ LUTCircuit* Circuit::build_lut_circuit() {
return C; return C;
} }
void Circuit::init_avg_dist() {
int *now_dist = new int[gates.size() + 1];
int *total_dist = new int[gates.size() + 1];
int *total_cnt = new int[gates.size() + 1];
for(Gate* po : POs) {
total_dist[po->id] = 0;
std::queue<Gate*> q;
}
delete [] now_dist;
delete [] total_dist;
delete [] total_cnt;
}
void Circuit::init_topo_index() { void Circuit::init_topo_index() {
int topo = 1; int topo = 1;
std::queue<Gate*> q; std::queue<Gate*> q;

View File

@ -15,6 +15,8 @@ std::vector<LUT*> POs;
std::vector<LUT*> luts; std::vector<LUT*> luts;
std::vector<LUT*> rtopo_luts; std::vector<LUT*> rtopo_luts;
int** fault_detected;
void print(); void print();
// local search // local search
@ -23,7 +25,7 @@ LUT* ls_pick();
void ls_flip(LUT *lut); void ls_flip(LUT *lut);
void ls_main(); void ls_main();
void ls_init(); void ls_init();
void ls_random_sol(int **fault_detected); void ls_random_sol();
void ls_gen_sol(); void ls_gen_sol();
// checker // checker
@ -49,5 +51,6 @@ void parse_from_file(const char *filename);
LUTCircuit* build_lut_circuit(); LUTCircuit* build_lut_circuit();
void init_topo_index(); void init_topo_index();
void init_avg_dist();
}; };

View File

@ -26,6 +26,8 @@ public:
std::vector<Gate*> fanouts; std::vector<Gate*> fanouts;
std::vector<Gate*> fanins; std::vector<Gate*> fanins;
std::vector<Gate*> reigon; std::vector<Gate*> reigon;
int avg_dist;
int fault_propagated_len[2]; int fault_propagated_len[2];
int fault_propagated_weight[2]; int fault_propagated_weight[2];
@ -46,6 +48,7 @@ public:
LUT* parent_lut; LUT* parent_lut;
int id_in_lut; int id_in_lut;
// ( partical ) score // ( partical ) score
// score(x) = for y in neibor(x) { ~V_x,V_y make - ~V_x,V_y break } // score(x) = for y in neibor(x) { ~V_x,V_y make - ~V_x,V_y break }

View File

@ -130,7 +130,7 @@ void LUTCircuit::ls_main() {
num_gates += lut->inner_gates.size(); num_gates += lut->inner_gates.size();
} }
assert(num_gates == C->gates.size()); assert(num_gates == C->gates.size());
int** fault_detected = new int*[num_gates]; fault_detected = new int*[num_gates];
for(int i=0; i<num_gates; i++) { for(int i=0; i<num_gates; i++) {
fault_detected[i] = new int[2]; fault_detected[i] = new int[2];
fault_detected[i][0] = fault_detected[i][1] = 0; fault_detected[i][0] = fault_detected[i][1] = 0;
@ -143,11 +143,11 @@ void LUTCircuit::ls_main() {
while(num_undetected_fault != 0) { while(num_undetected_fault != 0) {
ls_random_sol(fault_detected); ls_random_sol();
ls_gen_sol(); ls_gen_sol();
int res = simulator->verify(this); int res = simulator->verify(this, fault_detected);
assert(res == 1); assert(res == 1);
int num_fault = 0; int num_fault = 0;
@ -201,11 +201,11 @@ void LUTCircuit::ls_gen_sol() {
// int t2 = check(); // int t2 = check();
// assert(t2 - t1 == pick->score); // assert(t2 - t1 == pick->score);
// if(pick->isPI) { if(pick->isPI) {
// int score; int score;
// simulator->simulate(PIs, score); simulator->simulate(PIs, score, fault_detected);
// printf("step: %d fd: %d\n", step, score); printf("step: %d fd: %d\n", step, score);
// } }
} }
} }
@ -260,7 +260,7 @@ void LUTCircuit::ls_init() {
} }
} }
void LUTCircuit::ls_random_sol(int **fault_detected) { void LUTCircuit::ls_random_sol() {
step = 0; step = 0;

View File

@ -17,6 +17,7 @@ int main(int argc, char *argv[]) {
simulator->parse_from_file(OPT(instance).c_str()); simulator->parse_from_file(OPT(instance).c_str());
circuit->init_topo_index(); circuit->init_topo_index();
simulator->init_topo_index(); simulator->init_topo_index();
circuit->init_avg_dist();
// circuit-> // circuit->
printf("building lut circuit ...\n"); printf("building lut circuit ...\n");

View File

@ -12,11 +12,11 @@
PARA( sp , double , '\0' , false , 0.01 , 0 , 1 , "max input numbers of LUT") \ PARA( sp , double , '\0' , false , 0.01 , 0 , 1 , "max input numbers of LUT") \
PARA( brk_sp , double , '\0' , false , 0.05 , 0 , 1 , "max input numbers of LUT") \ PARA( brk_sp , double , '\0' , false , 0.05 , 0 , 1 , "max input numbers of LUT") \
PARA( t , int , '\0' , false , 20 , 0 , 1000 , "max input numbers of LUT") \ PARA( t , int , '\0' , false , 20 , 0 , 1000 , "max input numbers of LUT") \
PARA( vsat_inc , int , '\0' , false , 2 , 0 , 100000 , "max input numbers of LUT") \ PARA( vsat_inc , int , '\0' , false , 10 , 0 , 100000 , "max input numbers of LUT") \
PARA( vsat_max , int , '\0' , false , 10000 , 0 , 100000 , "max input numbers of LUT") \ PARA( vsat_max , int , '\0' , false , 10000 , 0 , 100000 , "max input numbers of LUT") \
PARA( fw_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \ PARA( fw_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( fw_max , int , '\0' , false , 500 , 0 , 1000 , "max input numbers of LUT") \ PARA( fw_max , int , '\0' , false , 500 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_inc , int , '\0' , false , 10 , 0 , 1000 , "max input numbers of LUT") \ PARA( up_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_max , int , '\0' , false , 10000 , 0 , 1000 , "max input numbers of LUT") PARA( up_max , int , '\0' , false , 10000 , 0 , 1000 , "max input numbers of LUT")
// name, short-name, must-need, default, comments // name, short-name, must-need, default, comments
#define STR_PARAS \ #define STR_PARAS \

View File

@ -1,6 +1,6 @@
#include "simulator.h" #include "simulator.h"
int Simulator::verify(LUTCircuit *lut_circuit) { int Simulator::verify(LUTCircuit *lut_circuit, int** fault_detected) {
// lut_circuit->check(); // lut_circuit->check();
@ -9,7 +9,7 @@ int Simulator::verify(LUTCircuit *lut_circuit) {
// } // }
int score; int score;
simulate(lut_circuit->PIs, score); simulate(lut_circuit->PIs, score, fault_detected);
for(LUT* lut : lut_circuit->luts) { for(LUT* lut : lut_circuit->luts) {
assert(lut->value == lut->cal_value()); assert(lut->value == lut->cal_value());
@ -77,7 +77,7 @@ int Simulator::verify(LUTCircuit *lut_circuit) {
return 1; return 1;
} }
void Simulator::simulate(std::vector<LUT*> &inputs, int &score) { void Simulator::simulate(std::vector<LUT*> &inputs, int &score, int** fault_detected) {
assert(inputs.size() == this->PIs.size()); assert(inputs.size() == this->PIs.size());
@ -99,7 +99,10 @@ void Simulator::simulate(std::vector<LUT*> &inputs, int &score) {
score = 0; score = 0;
for(auto gate : gates) { for(auto gate : gates) {
if(gate->fault_detected[0] || gate->fault_detected[1]) { if(gate->fault_detected[0] && !fault_detected[gate->id-1][0]) {
score++;
}
if(gate->fault_detected[1] && !fault_detected[gate->id-1][1]) {
score++; score++;
} }
} }

View File

@ -4,6 +4,6 @@
class Simulator : public Circuit { class Simulator : public Circuit {
public: public:
void simulate(std::vector<LUT*> &inputs, int &score); void simulate(std::vector<LUT*> &inputs, int &score, int** fault_detected);
int verify(LUTCircuit *lut_circuit); int verify(LUTCircuit *lut_circuit, int** fault_detected);
}; };

5640
test.txt

File diff suppressed because it is too large Load Diff