From 77a4984f3a3a5f0cedae96cef479a2654271043e Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Thu, 9 Mar 2023 02:51:10 +0000 Subject: [PATCH] =?UTF-8?q?gate=20=E5=A2=9E=E5=8A=A0=E4=BA=86=20level=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atpg | Bin 73472 -> 77680 bytes circuit.cpp | 33 ++++++++++++++++++++++++++++++++- circuit.h | 8 +++++++- ls.cpp | 4 +++- main.cpp | 2 ++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/atpg b/atpg index 3bce51b37f36c4e43eb00877f4944f7ea4357232..2978293d3c049955aafe470d34a749e9047abf1f 100755 GIT binary patch delta 20216 zcmb7s3wTUd_xCv`2|;8Mx7_S$Q&z4rCY zO#WWan#-QWfsKk|I3*;h5oc}tZoA9&GmF)%9&>(bo=4#?z1 z9gxHuD&0N)!Ap}vOdQAN@s0d%s!)7w%s%5!w5&Oz!tQZ%LB*T1_k|4q|EPxjBg|@Y zvByyV?9S5$Uh)~ye8La8W9@YVKPy|{k?v)$Rtx8=5%(F|*pdt6)@yRi8a^BCCp=Ko zNyq=u@S_@kzQ%tAcq`bzZ>0*<)$pzwzo^w)Hl$u!J-b%eTVu-Zs3tPp@R3@N4ROP* z8vjT){O*2LPL><~yM||LxLvRKp+?AaEAX#|=eyzeGKSzWv27>M&geMsAWt!s<9&5mL$0WS70Uvo= z&5#3sdc1+|~!mKg|o zKNDVR!0Qp9h4lu!z78VZY`_~B@Er!+$AFjLR_o_Tn}!C$Q9}V=1Afwgn+*6l1Fp@Q z3boRJ`y2RW9jE#m8wfQz0az0Q{=k4YHQ=1)jMRW;2He|#2N-Za10D!mYd^;Y8VEs# z0%ijqY``N7xHkVQRI34RZs3nM;4Plub}q?42z^4}L<1gXz%vZE*?3q6dKGiMX-7O#ImT&Kt4|mJkTetyD-SQ3H@?LKF zN5`L5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;%WRT_TD9%c&@hhw9!?sBQwG)4ROB5TJ*VQ-hvT@thc;k1(G$52{O_8w5 zwCl!6Ax+DKt2#bT$7y|})Q;RQ{Knr7Xoz<00G#w((Be|VlIM~ecIP52vglN1F+YYbW% zC_My|36Ifnn)Q?>0sn6e%+TfYduVbrktuzpSKJX{$!*A#6y= z!mDW-O*wZs7S+x5Un(J-H^3Gb=tr8_&NI32(GkVX&Zn+rim)$!CvHT;^E36C4{uWNvD ziz=X2#P$682XC<@hQwd$Ab2+DRrRbLaI$3LEDfM#l2RYwZSdP#D+H_NDgI|*K(RxCo zZ|itJ;3R*zQo{?hOeiLK$v;3a?npW=EG7myKJiUmWsz=zv8CLt<5wqZb!b~k>7r3H zI0)NmYBYPj#`(9FA>bzc6*y@ImS^I|XKAnzj$_dP$LHUR#|LU%%bum-Sgm-<0#5R- zf3}g!Lw`P9gOBKSQy?H%7d))-+|(Eetn6qncE>rHXmN6Nzyiu(pT6JkcR9eji!eq zNo6gv7~B}*lLnY!W3|+#qdlGe^zht3mwm1 zt>Lu4rIg3LH<2BI=3>ldvPyVBqCuek*A=Pcn?pm>_D!L2%JwqDiS3fJp~vt73W zGn2vf!)+(DL5KA$12~PS@&6h{I{p%HYB6=R2GA2HrAOH4+krS+!!>wEnAW17KIM*R zB0@X14Kh*uI)q$F_1E+qL%NlL8J(G#fz~G|D|IU4k zB{&1Kp6jaVjDJI`OFMf?OM#P5jsGSI=P16es>_#`Y5+ZbQ2Lp0^s^m%%X#L5x5UcU z6*I!bZXYi67Jmu(@agX2k8aY3j*2lcVw{(;S{1%qu{cKT?^mO#FzzVT6-Q#kUjD`n z-pIWx{A0ylZFcO?q>cQTPsNy6G0uO2=Rl93rwoBZYoutputs.size() >= 2) { gate->stem = true; } - //gate->stem = true; + // gate->stem = true; if(gate->stem) { stems.push_back(gate); } @@ -86,6 +86,37 @@ void Circuit::init_topo_index() { } } +void Circuit::init_gate_level() { + MAX_GATE_LEVEL = 0; + std::queue q; + + for(Gate* gate : gates) { + gate->level = -1; + } + + for(auto pi: PIs) { + pi->level = 0; + q.push(pi); + } + + while(!q.empty()) { + Gate* g = q.front(); q.pop(); + + MAX_GATE_LEVEL = std::max(MAX_GATE_LEVEL, g->level); + + for(Gate* out : g->outputs) { + if(out->level == -1) { + out->level = g->level + 1; + q.push(out); + } + } + } + + for(Gate* g : gates) { + assert(g->level != -1); + } +} + void Circuit::print_gates() { static const char* type2name[9] = {"AND", "NAND", "OR", "NOR", "XOR", "XNOR", "NOT", "BUF", "IN"}; for(Gate* gate : gates) { diff --git a/circuit.h b/circuit.h index eea1a62..72f505d 100644 --- a/circuit.h +++ b/circuit.h @@ -11,6 +11,7 @@ using ll = long long; class Gate { public: int id; + int level; std::string name; enum Type { AND, NAND, OR, NOR, XOR, XNOR, NOT, BUF, INPUT } type; int value; @@ -59,6 +60,10 @@ void print_gates(); bool is_valid_circuit(); void init_topo_index(); + + +int MAX_GATE_LEVEL; +void init_gate_level(); void init_stems(); // local search @@ -81,7 +86,7 @@ int* flip_need_update; std::vector flip_update_queue; // incremental stem struct -const int STEM_INC = 100; +const int STEM_INC = 2; const int STEM_WEIGHT_MAX = 1e9; ll stem_total_weight; int stem_total_cnt; @@ -89,6 +94,7 @@ int* stem_weight; int* stem_satisfied; int fault_propagate_tatal_len; +int fault_propagate_score; const int FAULT_INC = 1; const int FAULT_WEIGHT_MAX = 20; diff --git a/ls.cpp b/ls.cpp index f1f8bec..0cfbe73 100644 --- a/ls.cpp +++ b/ls.cpp @@ -217,7 +217,7 @@ ll Circuit::ls_pick_score(Gate* stem) { ll Circuit::ls_score() { //ll score = - flip_total_weight - stem_total_weight + fault_total_weight + fault_propagate_tatal_len; - ll score = - flip_total_weight - stem_total_weight + fault_propagate_tatal_len; + ll score = - flip_total_weight - stem_total_weight + 10 * fault_propagate_tatal_len; return score; } @@ -282,6 +282,8 @@ void Circuit::ls_init_data_structs() { } } + fault_propagate_score = 0; + fault_propagate_tatal_len = 0; flip_total_weight = 0; diff --git a/main.cpp b/main.cpp index ad17589..e842258 100644 --- a/main.cpp +++ b/main.cpp @@ -19,6 +19,7 @@ int main(int args, char* argv[]) { circuit->parse_from_file(argv[1]); circuit->init_stems(); circuit->init_topo_index(); + circuit->init_gate_level(); printf(" Done.\n"); printf("====== Circuit Statistics ====== \n"); @@ -26,6 +27,7 @@ int main(int args, char* argv[]) { printf("PO:\t%ld\n", circuit->POs.size()); printf("Gate:\t%ld\n", circuit->name2gate.size()); printf("Stem:\t%ld\n", circuit->stems.size()); + printf("Level:\t%d\n", circuit->MAX_GATE_LEVEL); printf("================================ \n"); std::unordered_set faults;