diff --git a/.vscode/launch.json b/.vscode/launch.json index f331369..37924da 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "program": "${workspaceFolder}/atpg", "args": ["${workspaceFolder}/benchmark/c432.bench"], "stopAtEntry": false, - "cwd": "${fileDirname}", + "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", diff --git a/atpg b/atpg index 23be6d0..8420a80 100755 Binary files a/atpg and b/atpg differ diff --git a/circuit.cpp b/circuit.cpp index ceb9575..fb94fc1 100644 --- a/circuit.cpp +++ b/circuit.cpp @@ -76,8 +76,6 @@ bool Circuit::is_valid_circuit() { ll fault_propagate_score = 0; - //printf("flip: %d, stem: %d, fault:%d\n", flip_total_weight, stem_total_weight, fault_total_weight); - for(Gate* g : gates) { if(g->propagate != (g->fault_detected[0] || g->fault_detected[1])) { diff --git a/crun b/crun index 32099a5..12b724c 100755 --- a/crun +++ b/crun @@ -8,6 +8,6 @@ if [ $? -ne 0 ]; then echo "compile failed." else echo "========================" - time ./atpg $1 2>&1 | tee output.txt + time ./atpg $1 fi diff --git a/ls.cpp b/ls.cpp index 5a25f88..7dfdadb 100644 --- a/ls.cpp +++ b/ls.cpp @@ -12,6 +12,8 @@ bool Circuit::local_search() { + //printf("[start ls]\n"); + ls_reset_data(); ls_init_stems(); @@ -22,15 +24,29 @@ bool Circuit::local_search() { ls_random_circuit(); + //printf("stem-cnt: %d\n", stem_total_cnt); + for(int i=0; istem) { ls_flip_stem(id2gate[var]); } @@ -240,7 +252,7 @@ ll Circuit::ls_pick_score(int var) { ls_flip_var(var); - //assert(old_score == ls_circuit_score()); + assert(old_score == ls_circuit_score()); return new_score - old_score; } @@ -269,7 +281,8 @@ void Circuit::ls_random_circuit() { for(int i=1; i<=ClauseLS::num_vars; i++) { int new_v = CCAnr::module_cur_soln()[i]; if(new_v != ClauseLS::lit_value[i]) { - ls_flip_var(i); + //ls_flip_var(i); + ClauseLS::flip(i); } } @@ -309,10 +322,9 @@ void Circuit::ls_random_circuit() { fault_propagate_score += g->fault_weight[0] * g->fault_propagate_length[0]; fault_propagate_score += g->fault_weight[1] * g->fault_propagate_length[1]; - } - //assert(is_valid_circuit()); + assert(is_valid_circuit()); } void Circuit::ls_reset_data() { diff --git a/makefile b/makefile index f7ff918..7c64677 100644 --- a/makefile +++ b/makefile @@ -7,8 +7,8 @@ OBJECTS := $(addprefix build/,$(SOURCES:%=%.o)) # 声明编译器和编译选项 CC := gcc CXX := g++ -CFLAGS := -Wall -Wextra -MMD -MP -CXXFLAGS := -Wall -Wextra -MMD -MP +CFLAGS := -O0 -g -Wall -Wextra -MMD -MP +CXXFLAGS := -O0 -g -Wall -Wextra -MMD -MP # 默认目标,编译所有目标文件 atpg: $(OBJECTS)