From b2df76e1de02129ce8d1d7e5eb04cd4cf1bbaa52 Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Sat, 4 Mar 2023 10:28:39 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=BF=E7=9C=9F=E7=9A=84?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atpg | Bin 70064 -> 74832 bytes circuit.h | 10 +++- ls.cpp | 13 +++++ simulator.cpp | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 simulator.cpp diff --git a/atpg b/atpg index 2ad58e5239ed3f04fa58db76209547b536028956..dd5ffcb532519ce9fa234e3bc72f42eda8245c8a 100755 GIT binary patch delta 21225 zcmai630zcF+rM*RWM@D@5Jd+al}!W{1rq}WyCRS+=04Xe*kgxxrgzcS2LkSIzIO`Toyc#)+@@_Z@z7&w2jObIy6rbDp!#9jf1Q zZ#d~*9@@G(o|8kW5^(_?)^2;;NL5jaegIzM7Gu~GQ2m+qPEKFRK1ZCzzydJOT?!i zJMGp_H=eC@4`JEvq3onbC`)n=)ituG+(UGQ>`1E+-Rt1?)TOic@YLZMq6?FsH7rm+ zRQD0()lHX62+)V>F3G$jGHQ{ZV`SttIlYZaWbv&+bv;-F@;xD=4q0N2oQ{>#kI6MR z$kMkVeOH!#U490$2#=l{0LIE0wz8ETLv;h>^s^8MB_S5z8LBhN*;73Q{Wi3{GkcG3 zW2tuIxCkzktGtBPBNWL`j@t=OAbh*psYVrF3Cj^4s&<@)KUDFPs(g_u-w3=jJSG2S z1@KVu{))UCCtRxO>}BWOX6Mdg&)(=<6YcwN-hE=;qFm z-f>CHVHh3i0wi)nGtGklOza)khs_KaWO3u@PmkVJQXWXVfzsp8lk?)dWtuP_e0(`S znf8~Z4V;G@>k(5*2gO^-f0Wh%p?u08QRGKD?mUc1L&%6vw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bd+Jj{OLdY-wG!CdmgXPDilAvj*P*8qMzzoX+WZUA#t5 z&@FVslu~<>(1lA9roKg!FrGbtb2J;Prh)e}YCiEeN^DE>0~#+^x8*R`#5l+4<7`B3 zE7yd4#w<<#qAvdcc4gKRw^GCTV9Cj5_&Mw+UBY>sci`ni?M2v0Ej8{f|cT8zHA!8h?>jd_2S4x@se3)vYzw$sWM9SRdS0deA6^&EXPku}s%A@~al7 z^@haQ-%;YWo%blOZd%PNdJm83HVpvI^3Ho#y9k7(x<+@SH!cN=gVbjQKZAb-kFBVS z(^|iwWx`!mW*)^~4jfy9qan*Q?0Dg(#^djTvcZd3ISGv2@ zCtdH}j+8sMsKeFp`lx^Ux>n_i;$QT)d+5ijB=JL^j|=_9FWb?t9??~&{6*iYHGZP| z$Lm7G4@7E^+I^hSNz4+(l&WoEVjsUaePJ;2f~uTVw z-J=k)oT94U=`0TPH(m*h{EAD}wa(%Kv94-%IHa2q4V;>*-U$~6`nBk!k=ImRg_OT> z>^Ji5g;jkmVs8&)e@a|eHOqqPHL9+*Ex*>S>H~=R83!yQcdfc=f!4ZOP29+%ysP?l zf%x(58gAr0t7dl*`*;}dPdSIHHg^#Rco;{+!oyYPnKs@*iVs)CbOmi3-!hL>%>wOb z9NUb%x@ucjG0t5N3V7grS8<@RqZ>2XS{2_-Oca}|W_1&Xbrr_|MTDBDs%zcE0aBc~DkegV{6D(ocq0G+ diff --git a/circuit.h b/circuit.h index 6861c88..011261b 100644 --- a/circuit.h +++ b/circuit.h @@ -80,18 +80,18 @@ void init_stems(); // local search // shared info -static const int STEM_INC = 10; +static const int STEM_INC = 2; static const int STEM_COST_MAX = 1e9; static ll stem_total_cost; static int stem_falsified_cnt; -static const int PROPAGATE_INC = 10; +static const int PROPAGATE_INC = 2; static const int PROPAGATE_COST_MAX = 1e9; static ll propagate_total_cost; static int propagate_falsified_cnt; static const int FAULT_INC = 1; -static const int FAULT_COST_MAX = 20; +static const int FAULT_COST_MAX = 1e9; static ll fault_total_cost; static int fault_falsified_cnt; @@ -116,4 +116,8 @@ void ls_update(Gate* stem); ll ls_pick_score(Gate* stem, bool value, bool propagate); ll ls_score(); + + +// simulator +int** simulate(); }; \ No newline at end of file diff --git a/ls.cpp b/ls.cpp index 05df9ef..94e733a 100644 --- a/ls.cpp +++ b/ls.cpp @@ -28,6 +28,19 @@ bool Circuit::local_search(std::unordered_set &faults) { ls_update_weight(); picked_stem = ls_pick_falsified_var(value, propagate); printf("[UP] propagate: %lld, stem: %lld, fault:%lld. propagate_cnt: %d, stem_cnt: %d, fault_cnt:%d\n", propagate_total_cost, stem_total_cost, fault_total_cost, propagate_falsified_cnt, stem_falsified_cnt, fault_falsified_cnt); + + int** sa = simulate(); + int cnt = 0; + static int max_cnt = 0; + + for(Fault* f : faults) { + if(sa[f->gate->id][f->type]) { + cnt++; + } + } + max_cnt = std::max(max_cnt, cnt); + + printf("[SOL] detect-faults: %d max-faults: %d\n", cnt, max_cnt); } else { // printf("pick: %s value: %d propagate: %d\n", picked_stem->name.c_str(), value, propagate); // printf("[LS] propagate: %lld, stem: %lld, fault:%lld. propagate_cnt: %d, stem_cnt: %d, fault_cnt:%d\n", propagate_total_cost, stem_total_cost, fault_total_cost, propagate_falsified_cnt, stem_falsified_cnt, fault_falsified_cnt); diff --git a/simulator.cpp b/simulator.cpp new file mode 100644 index 0000000..5fd4cad --- /dev/null +++ b/simulator.cpp @@ -0,0 +1,150 @@ +#include "circuit.h" + +#include +#include + +int cal_value(Gate *g, int *value) { + int res; + + switch(g->type) { + case Gate::NOT: + res = !value[g->inputs[0]->id]; + break; + case Gate::BUF: + res = value[g->inputs[0]->id]; + break; + case Gate::AND: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res &= value[g->inputs[i]->id]; + } + break; + case Gate::NAND: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res &= value[g->inputs[i]->id]; + } + res = !res; + break; + case Gate::OR: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res |= value[g->inputs[i]->id]; + } + break; + case Gate::NOR: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res |= value[g->inputs[i]->id]; + } + res = !res; + break; + case Gate::XOR: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res ^= value[g->inputs[i]->id]; + } + break; + case Gate::XNOR: + res = value[g->inputs[0]->id]; + for(int i=1; iinputs.size(); i++) { + res ^= value[g->inputs[i]->id]; + } + res = !res; + break; + case Gate::INPUT: + res = value[g->id]; + break; + default: + assert(false); + break; + } + return res; +} + +bool cal_sa(Gate* g, bool x, int** sa, int *value) { + if(g->po) { + if(x == 0) return value[g->id]; + else return !value[g->id]; + } + + bool sa0 = 0; + bool sa1 = 0; + + for(Gate* out : g->outputs) { + if(!sa[out->id][0] && !sa[out->id][1]) continue; + + if(cal_value(out, value) != value[out->id]) continue; + + value[g->id] = !value[g->id]; + bool detect = cal_value(out, value) != value[out->id]; + value[g->id] = !value[g->id]; + if(!detect) continue; + + sa0 |= value[g->id]; + sa1 |= !value[g->id]; + } + if(x == 0) return sa0; + else return sa1; +} + + +int** Circuit::simulate() { + + static bool init = false; + static int** sa = nullptr; + static int* value = nullptr; + + if(!init) { + const int MAXN = gates.size() + 1; + init = true; + sa = new int*[MAXN]; + for(int i=0; iid] = pi->value; + } + + for(Gate *g : gates) { + if(g->pi) continue; + value[g->id] = cal_value(g, value); + } + + for(Gate *g : gates) { + assert(value[g->id] == cal_value(g, value)); + } + + std::queue q; + std::unordered_map topo; + + // init PO + for(Gate* po : POs) { + sa[po->id][!value[po->id]] = 1; + sa[po->id][value[po->id]] = 0; + q.push(po); + } + + while(!q.empty()) { + Gate* g = q.front(); + q.pop(); + for(Gate* in : g->inputs) { + if(++topo[in] == in->outputs.size()) { + sa[in->id][0] = cal_sa(in, 0, sa, value); + sa[in->id][1] = cal_sa(in, 1, sa, value); + q.push(in); + } + } + } + + for(Gate* g : gates) { + assert(sa[g->id][0] == cal_sa(g, 0, sa, value)); + assert(sa[g->id][1] == cal_sa(g, 1, sa, value)); + } + + return sa; +} \ No newline at end of file