v1.3: 修复了权重BUG,但求可行解的能力大幅下降
This commit is contained in:
parent
7a3e157bb7
commit
c112a34dd6
@ -60,15 +60,16 @@ int LUTCircuit::check() {
|
||||
}
|
||||
}
|
||||
|
||||
printf("=====================================\n");
|
||||
printf("unsat_lut: %d\n", unsatisfied_lut);
|
||||
printf("score_value_unsatisfied_cost: %d\n", score_value_unsatisfied_cost);
|
||||
// printf("score_fault_detected_weight: %d\n", score_fault_detected_weight);
|
||||
// printf("score_fault_propagated_weight: %d\n", score_fault_propagated_weight);
|
||||
// printf("score_fault_update_cost: %d\n", score_fault_update_cost);
|
||||
printf("score_fault_detected_weight: %d\n", score_fault_detected_weight);
|
||||
printf("score_fault_propagated_weight: %d\n", score_fault_propagated_weight);
|
||||
printf("score_fault_update_cost: %d\n", score_fault_update_cost);
|
||||
|
||||
int score = - score_value_unsatisfied_cost + score_fault_detected_weight + score_fault_propagated_weight - score_fault_update_cost;
|
||||
|
||||
// printf("score: %d\n", score);
|
||||
printf("score: %d\n", score);
|
||||
|
||||
return score;
|
||||
}
|
@ -145,17 +145,48 @@ LUTCircuit* Circuit::build_lut_circuit() {
|
||||
|
||||
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];
|
||||
int *now_dist = new int[gates.size() + 1] { 0 };
|
||||
int *total_dist = new int[gates.size() + 1] { 0 };
|
||||
int *total_cnt = new int[gates.size() + 1] { 0 };
|
||||
// int *topo_cnt = new int[gates.size() + 1] { 0 };
|
||||
|
||||
for(Gate* po : POs) {
|
||||
// memset(topo_cnt, 0, sizeof(int) * (gates.size() + 1));
|
||||
// memset(now_dist, 0x3f, sizeof(int) * (gates.size() + 1));
|
||||
for(Gate* g : gates) {
|
||||
if(g->isPO) {
|
||||
now_dist[g->id] = 0;
|
||||
} else {
|
||||
now_dist[g->id] = 0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
|
||||
total_dist[po->id] = 0;
|
||||
|
||||
// printf(">> po: %s\n", po->name.c_str());
|
||||
|
||||
std::queue<Gate*> q;
|
||||
q.push(po);
|
||||
|
||||
while(!q.empty()) {
|
||||
Gate* u = q.front(); q.pop();
|
||||
|
||||
total_dist[u->id] += now_dist[u->id];
|
||||
total_cnt[u->id] ++;
|
||||
|
||||
// printf("now: %s\n", u->name.c_str());
|
||||
|
||||
for(Gate* in : u->fanins) {
|
||||
if(now_dist[u->id] + 1 < now_dist[in->id]) {
|
||||
now_dist[in->id] = now_dist[u->id] + 1;
|
||||
q.push(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Gate* g : gates) {
|
||||
// printf("gate: %s total: %d cnt: %d\n", g->name.c_str(), total_dist[g->id], total_cnt[g->id]);
|
||||
g->avg_dist = total_dist[g->id] / total_cnt[g->id];
|
||||
if(!g->isPO) assert(g->avg_dist > 0);
|
||||
}
|
||||
|
||||
delete [] now_dist;
|
||||
|
44
src/ls.cpp
44
src/ls.cpp
@ -62,30 +62,35 @@ void LUTCircuit::ls_flip(LUT *lut) {
|
||||
|
||||
void LUTCircuit::ls_update(std::vector<LUT*> &unsat) {
|
||||
|
||||
// printf("?????????????????ls_update\n");
|
||||
|
||||
// if(rand() % 10000 <= OPT(sp)) {
|
||||
|
||||
// } else {
|
||||
|
||||
|
||||
for(LUT* lut : luts) {
|
||||
if(!lut->vsat) {
|
||||
if(lut->vunat_cost += OPT(vsat_inc) > OPT(vsat_max)) {
|
||||
|
||||
// printf("ocost: %d add: %d\n", lut->vunat_cost);
|
||||
if(lut->vunat_cost + OPT(vsat_inc) > OPT(vsat_max)) {
|
||||
lut->vunat_cost = OPT(vsat_max);
|
||||
} else {
|
||||
lut->vunat_cost += OPT(vsat_inc);
|
||||
}
|
||||
// printf("cost: %d add: %d\n", lut->vunat_cost, OPT(vsat_inc));
|
||||
|
||||
for(LUT* out : lut->fanouts) {
|
||||
if(out->vunat_cost -= OPT(vsat_inc) > 1) {
|
||||
out->vunat_cost -= OPT(vsat_inc);
|
||||
} else {
|
||||
out->vunat_cost = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// for(LUT* out : lut->fanouts) {
|
||||
// if(out->vunat_cost -= OPT(vsat_inc) > 1) {
|
||||
// out->vunat_cost -= OPT(vsat_inc);
|
||||
// } else {
|
||||
// out->vunat_cost = 1;
|
||||
// }
|
||||
// }
|
||||
unsat.push_back(lut);
|
||||
}
|
||||
if(lut->uptag) {
|
||||
if(lut->up_cost += OPT(up_inc) > OPT(up_max)) {
|
||||
if(lut->up_cost + OPT(up_inc) > OPT(up_max)) {
|
||||
lut->up_cost = OPT(up_max);
|
||||
} else {
|
||||
lut->up_cost += OPT(up_inc);
|
||||
@ -147,6 +152,8 @@ void LUTCircuit::ls_main() {
|
||||
|
||||
ls_gen_sol();
|
||||
|
||||
// exit(0);
|
||||
|
||||
int res = simulator->verify(this, fault_detected);
|
||||
assert(res == 1);
|
||||
|
||||
@ -186,7 +193,7 @@ void LUTCircuit::ls_gen_sol() {
|
||||
|
||||
for(int step=0; ; step++) {
|
||||
// printf("step: %d\n", step);
|
||||
// int t1 = check();
|
||||
|
||||
|
||||
LUT* pick = ls_pick();
|
||||
|
||||
@ -194,17 +201,26 @@ void LUTCircuit::ls_gen_sol() {
|
||||
break;
|
||||
}
|
||||
|
||||
// pick->cal_score();
|
||||
pick->cal_score();
|
||||
|
||||
// int t1 = check();
|
||||
|
||||
// printf(">>>>>>>>>>>>>\n");
|
||||
// printf("dert_score: %d\n", pick->score);
|
||||
// printf("dert_fault_detected_weight: %d\n", pick->score_fault_detected_weight);
|
||||
// printf("dert_fault_propagated_weight: %d\n", pick->score_fault_propagated_weight);
|
||||
// printf("dert_up_cost: %d\n", pick->score_fault_update_cost);
|
||||
// printf("dert_unsat_cost: %d\n", pick->score_value_unsatisfied_cost);
|
||||
|
||||
ls_flip(pick);
|
||||
|
||||
// int t2 = check();
|
||||
// assert(t2 - t1 == pick->score);
|
||||
// assert((t2 - t1) == pick->score);
|
||||
|
||||
if(pick->isPI) {
|
||||
int score;
|
||||
simulator->simulate(PIs, score, fault_detected);
|
||||
printf("step: %d fd: %d\n", step, score);
|
||||
// printf("step: %d fd: %d\n", step, score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
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 , 10000 , 0 , 1000 , "max input numbers of LUT")
|
||||
PARA( up_max , int , '\0' , false , 1000 , 0 , 1000 , "max input numbers of LUT")
|
||||
// name, short-name, must-need, default, comments
|
||||
#define STR_PARAS \
|
||||
STR_PARA( instance , 'i' , true , "" , ".bench format instance")
|
||||
|
@ -131,5 +131,7 @@ void LUT::cal_score() {
|
||||
out->vsat = ( out->cal_value() == out->value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
score = - score_value_unsatisfied_cost + score_fault_detected_weight + score_fault_propagated_weight - score_fault_update_cost;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user