diff --git a/src/ls.cpp b/src/ls.cpp index ceed5c5..07343b7 100644 --- a/src/ls.cpp +++ b/src/ls.cpp @@ -38,7 +38,16 @@ LUT* LUTCircuit::ls_pick() { if(unsat.size() == 0) return nullptr; - return unsat[rand() % unsat.size()]; + pick = unsat[rand() % unsat.size()]; + + if(pick->fanins.size() == 0) { + return pick; + } + + if(rand() % 10000 < 5000) { + return pick->fanins[rand() % pick->fanins.size()]; + } + return pick; } void LUTCircuit::ls_flip(LUT *lut) { @@ -68,11 +77,41 @@ void LUTCircuit::ls_flip(LUT *lut) { void LUTCircuit::ls_update(std::vector &unsat) { - // printf("?????????????????ls_update\n"); + if(rand() % 10000 <= OPT(sp) * 10000) { - // if(rand() % 10000 <= OPT(sp)) { - - // } else { + for(LUT* lut : luts) { + if(lut->vsat) { + if(lut->vunat_cost - OPT(vsat_inc) >= 1) { + lut->vunat_cost -= OPT(vsat_inc); + } + } + if(!lut->vsat) { + unsat.push_back(lut); + } + if(!lut->uptag) { + if(lut->up_cost - OPT(up_inc) >= 1) { + lut->up_cost -= OPT(up_inc); + } + } + for(int i=lut->fanins.size(); ifanins.size()+lut->inner_gates.size(); i++) { + Gate* g = lut->inner_gates[i-lut->fanins.size()]; + LUT::FaultInfo &fi = lut->fault_table[i][lut->input_var]; + if(fi.fd[0] && g->fault_detected_weight[0] - OPT(fw_inc) >= 1) { + g->fault_detected_weight[0] -= OPT(fw_inc); + } + if(fi.fd[1] && g->fault_detected_weight[1] - OPT(fw_inc) >= 1) { + g->fault_detected_weight[1] -= OPT(fw_inc); + } + if(fi.fd[0] && g->fault_propagated_weight[0] - OPT(fw_inc) >= 1) { + g->fault_propagated_weight[0] -= OPT(fw_inc); + } + if(fi.fd[1] && g->fault_propagated_weight[1] + OPT(fw_inc) >= 1) { + g->fault_propagated_weight[1] -= OPT(fw_inc); + } + } + } + + } else { for(LUT* lut : luts) { if(!lut->vsat) { @@ -119,7 +158,7 @@ void LUTCircuit::ls_update(std::vector &unsat) { } } } - // } + } } void LUTCircuit::ls_main() { @@ -360,13 +399,13 @@ void LUTCircuit::ls_gen_sol(const TMP_FAULT &target) { best_sol.push_back(lut->value); } - for(int step=0; ; step++) { + for(int step=0; stepcal_score(); diff --git a/src/paras.h b/src/paras.h index 26cccbb..1f1aae8 100644 --- a/src/paras.h +++ b/src/paras.h @@ -7,17 +7,18 @@ // name, type, short-name,must-need, default ,low, high, comments #define PARAS \ - PARA( seed , int , '\0' , false , 17 , 0 , 100000000 , "max input numbers of LUT") \ - PARA( lut , int , '\0' , false , 8 , 0 , 30 , "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( t , int , '\0' , false , 30 , 0 , 1000 , "max input numbers of LUT") \ - PARA( vsat_inc , int , '\0' , false , 1 , 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_max , int , '\0' , false , 500 , 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 , 1000 , 0 , 1000 , "max input numbers of LUT") + PARA( seed , int , '\0' , false , 17 , 0 , 100000000 , "max input numbers of LUT") \ + PARA( lut , int , '\0' , false , 8 , 0 , 30 , "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( t , int , '\0' , false , 30 , 0 , 1000 , "max input numbers of LUT") \ + PARA( vsat_inc , int , '\0' , false , 1 , 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_max , int , '\0' , false , 500 , 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 , 1000 , 0 , 1000 , "max input numbers of LUT") \ + PARA( max_step_coeff , double , '\0' , false , 10.0 , 1 , 1000 , "max input numbers of LUT") // name, short-name, must-need, default, comments #define STR_PARAS \ STR_PARA( instance , 'i' , true , "" , ".bench format instance")