From 1a93b8a8a302cf22c18a278bed53839d475d2362 Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Thu, 2 Mar 2023 08:17:53 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=89=80=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atpg | Bin 65200 -> 64728 bytes circuit.h | 3 +-- gate.cpp | 26 ++++++++++++++++++++++++++ ls.cpp | 37 ++++++++++++++++++++++--------------- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/atpg b/atpg index b11a2014dfce35f131308e5dc3c2c2cc1c0ff96d..f104823b812707a637454faa6ec99e60ea85092c 100755 GIT binary patch delta 16339 zcma)j4SWpO*Z<5U%X-ViYhEN0EJ7j@gsiu2NSI}5yf#X`G)lB-rDQ8Ax*@yRPL^=f zHd?LF7u36`R;wECTC}R#`l(9#qGr7m)v7A?|2;FaN$`7~=RcoM_TGEWx#ymH&bjBF zduOusZouh(0*XVMBqVU^W6=t(^v`9T&eeC#(VDI~tO*}q&k~|FE#+3e3*S2TU9I_G zd5YKIr`QUive}$Nw!|)z$GrB^+~^O)@r&Kw(L<(|7X@rI2vtkVd)0fP9v{rMH3Q$i8eJ z?Z}bj9i{>fq#f@`E?=%e$-e9JN%C$}836$qBgs*FLeWr05XN13$*U~BToC}jo^dn_Qfxvwg1K%jhDi|V?@K&eO6veQ(`IY`>wregF+yeWB_9Ylpw zo(7l13O|A*ECpC{J5B5KvW!YO)nt*(hjZ&mdw&a1K0qg%ywP+5sG+Vaxv4ZlD0D2z zD^0fmw0R~OZRTHQHI?MvdpH4z!u=DC%1h{XNg?9XMC86IdAe(2OaVs1JjRpQ^1Nb6 zwwG0_X%HdhPjjGMzzeG3UDQsMN(Y+!lWby4s8H_?n-df9_@#eULtOGoa#|_zt2N_C zfm1;z!K_qrk6wqrGMo8teR5lXR|cy?KG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0yvFShX3(N4`t-^G+`~i4dhMq4xVaIHC3#QcuJw*xbGF3|0wSl z%DXum_-$bPm=-F}mqYp@4gPXSAJGy4Q1PmnsHy%{R8{+rr`F8WN|mD|MiW4jbuht| z{@;6Q@sBjx=y577C8hMdV$@{QJZ6Ck<|12bGBis>jWpu-5=9UejUr`yENZ07pp$B6 zgT`Y#;N(#ic`ATXEP5n@L%znPlfRo?kM+IKuEC&ABhBN+rKJrTWggU-HM<|drxYw}3pxA1W0i-w(oj)U6P_=l!U>uZJ?f z3r*R&2Axa0yJqQyTDk1YCsB1hq3_sx?EaJ9*lbOIc5L`x|8bqo1T^|nRbEe7%=Q3U sQK~{c<(1Mu|LiH?e{Y$dcd1+Wor>JnhQ0H=bKNcv)uxGOPaib@A0CT!1poj5 diff --git a/circuit.h b/circuit.h index e8c48ed..019e7e0 100644 --- a/circuit.h +++ b/circuit.h @@ -19,8 +19,6 @@ public: bool isPI; bool isPO; - std::unordered_map> sa_by_out; - std::vector pre_stems; std::vector suc_stems; @@ -29,6 +27,7 @@ public: bool is_propagated(); int cal_value(); + bool cal_sa(bool x); }; class Fault { diff --git a/gate.cpp b/gate.cpp index f5be4bd..c12ffe1 100644 --- a/gate.cpp +++ b/gate.cpp @@ -6,6 +6,32 @@ bool Gate::is_propagated() { return sa[0] || sa[1]; } +bool Gate::cal_sa(bool x) { + if(isPO) { + if(x == 0) return value; + else return !value; + } + + bool sa0 = 0; + bool sa1 = 0; + + for(Gate* out : outputs) { + if(!out->is_propagated()) continue; + + if(out->cal_value() != out->value) continue; + + this->value = !this->value; + bool detect = out->cal_value() != out->value; + this->value = !this->value; + if(!detect) continue; + + sa0 |= this->value; + sa1 |= !this->value; + } + if(x == 0) return sa0; + else return sa1; +} + int Gate::cal_value() { int res; diff --git a/ls.cpp b/ls.cpp index b34a949..938d250 100644 --- a/ls.cpp +++ b/ls.cpp @@ -402,12 +402,32 @@ void Circuit::ls_block_recal(Gate* stem) { stem_satisfied[stem->id] = true; stem_total_weight -= stem_weight[stem->id]; stem_total_cnt += 1; + + for(Gate* pre : stem->pre_stems) { + if(flip_need_update[pre->id]) continue; + + flip_need_update[pre->id] = true; + flip_update_queue.push_back(pre); + + flip_total_weight += flip_weight[pre->id]; + flip_total_cnt += 1; + } } if(stem->cal_value() != stem->value && stem_satisfied[stem->id]) { stem_satisfied[stem->id] = false; stem_total_weight += stem_weight[stem->id]; stem_total_cnt -= 1; + + for(Gate* pre : stem->pre_stems) { + if(flip_need_update[pre->id]) continue; + + flip_need_update[pre->id] = true; + flip_update_queue.push_back(pre); + + flip_total_weight += flip_weight[pre->id]; + flip_total_cnt += 1; + } } } @@ -417,27 +437,14 @@ void Circuit::ls_block_recal(Gate* stem) { used[g] = false; - bool right_value = (g->cal_value() == g->value); for(Gate* in : g->inputs) { - in->value = !in->value; - bool input_detected = (g->cal_value() != g->value); - in->value = !in->value; - - bool sa0 = right_value && input_detected && g->sa[!g->value] && in->value; - bool sa1 = right_value && input_detected && g->sa[!g->value] && !in->value; - - in->sa_by_out[g] = std::make_pair(sa0, sa1); bool old_sa[2]; old_sa[0] = in->sa[0]; old_sa[1] = in->sa[1]; - in->sa[0] = in->sa[1] = 0; - for(Gate* out : in->outputs) { - auto &p = in->sa_by_out[out]; - in->sa[0] |= p.first; - in->sa[1] |= p.second; - } + in->sa[0] = in->cal_sa(0); + in->sa[1] = in->cal_sa(1); if(in->stem && !in->isPI && (in->sa[0] != old_sa[0] || in->sa[1] != old_sa[1])) {