From 67443cbde9c961b81403806ed2b16758f1c819d5 Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Thu, 16 Feb 2023 18:51:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atpg | Bin 44760 -> 44792 bytes circuit.cpp | 18 ++++++++++++++++-- circuit.h | 19 ++++++++++++++++++- ls.cpp | 28 +++++----------------------- ls.h | 9 --------- main.cpp | 32 ++++++++++++++++---------------- 6 files changed, 55 insertions(+), 51 deletions(-) delete mode 100644 ls.h diff --git a/atpg b/atpg index fcca67dcdf06e0bf8d3df4a56c8f29850d24dc07..cb4983cc4077065bf9c4e405863776a538632d11 100755 GIT binary patch delta 10054 zcmai44O~=J+COudK|sD02NVT$L=c5RMMXdX5idF_iW-?I_<@>VY=V+Y0wHbVIEFq} z+h&EWZ>d>nRI6nxEE?MD2WFa?CYt3PQBhk*G__)THpIN;onuyeIUBx?_o+@+JJrb)Y=}$W@27V4ngyzT z11eAa?OLVwcdh+>y}+dQi>T6I4$3Q2dwJ`$nzkE`2Nlm&d+jyZg;_oSo5mbXV-9(H z%<4Q~$@W<_140gd`_CmGo{5`&Xb4;BL1iA%-4mcwH;&bA$q!@`8OH|UFR`w{W2C{b ziwveQhV4{fiYL)zrFzpg!&dY{snT=5;V7kdXfvFm1g}{eO-9<}6>iu=yS>a|hqNh1 zLK82~VVIsQlntYcUgiWzqgE(1#(n^`7ra$JUIjX6c(x|Bpf1My9Z$L(aFb34K4G{* z=|K^b+Tc>|;DWm^35@x$-?aY8_ZDIH9he`qaQYtGcoeDnCsO?nBptef`cnuk!J@=}XRFbJzeCP@a+-HI6}|Aj@r?>isrS1+n_^;#)VZJ)k|5IWRnde>FI z%CdCuH(BNyMEgPM9@?V4O)8+2s0~6yUpgMuHO2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#+r9M>z}aBa{&i5L8hr#fv$>p|6_D6DlBHxysx@2Y zVo#F?)EouX#>*3o%l}1wzAHaZ%g-O#(~`kP6Kv+kDO$%>n?>{uw5n+np0Bc}<%TM0 zRQF`PqQKpkxij%joY`qthqHX@g2Y;itTXchRpS{eKOOW=o!OF$#hUiV ztSDTRGfKT5#TPCsnNM$R+})I0-yzUEYOwrIS^AlpnvTBc66m2`v1Hv8WXV(hpOd$s zptvL>Birf7%*q=UKP*0(?z}wDoHVR>X>n;@p>h*@P-T`I_@yNr~(E75d&pkhIzjr8iSgkbIHq0zDtbZ%F?pSFVG z=o7qqB40yub|?61d*o``w0o4Pp-{1>Q3IXbonYFrSV1*vAf59EIduH(LH`e!vO8-4 diff --git a/circuit.cpp b/circuit.cpp index 8dea274..6ad6907 100644 --- a/circuit.cpp +++ b/circuit.cpp @@ -3,7 +3,19 @@ #include #include -void Circuit::cal_topo_index() { + +void Circuit::init_stems() { + for(auto& gate: gates) { + if(gate->outputs.size() >= 2) { + stems.push_back(gate); + } + } + for(auto &gate : PIs) { + stems.push_back(gate); + } +} + +void Circuit::init_topo_index() { int topo = 1; std::queue q; @@ -80,4 +92,6 @@ int Circuit::cal_gate_value(const Gate* &gate) { break; } return res; -} \ No newline at end of file +} + + diff --git a/circuit.h b/circuit.h index 64d4ff7..7748f0b 100644 --- a/circuit.h +++ b/circuit.h @@ -14,14 +14,31 @@ public: std::vector inputs; }; +class Fault { +public: + Gate* gate; + enum Type { SA0, SA1 } type; + Fault(Gate* gate, Type type):gate(gate),type(type) {} +}; + class Circuit { public: std::vector PIs; std::vector POs; std::vector gates; +std::vector stems;// PI + stems + std::unordered_map name2gate; void parse_from_file(const char *filename); int cal_gate_value(const Gate* &gate); -void cal_topo_index(); +void init_topo_index(); +void init_stems(); + +// local search +std::vector local_search(const std::vector &faults); + +void ls_init_circuit(); +void ls_init_vector(std::vector *vec); + }; \ No newline at end of file diff --git a/ls.cpp b/ls.cpp index 0471d53..8b09a4f 100644 --- a/ls.cpp +++ b/ls.cpp @@ -1,35 +1,17 @@ -#include "ls.h" +#include "circuit.h" - -std::vector local_search(Circuit* circuit) { +std::vector Circuit::local_search(const std::vector &faults) { // local search vector - std::vector vec; - - init_vector(circuit, &vec); - - init_circuit(circuit); + ls_init_circuit(); printf("local search!\n"); return std::vector(); } - -void init_circuit(Circuit* circuit) { - for(auto pi : circuit->PIs) { +void Circuit::ls_init_circuit() { + for(auto pi : PIs) { pi->value = rand() % 2; } -} - -void init_vector(Circuit* circuit, std::vector *vec) { - for(auto pi : circuit->PIs) { - vec->push_back(pi); - } - for(auto gate : circuit->gates) { - // fanout stem - if(gate->outputs.size() >= 2) { - vec->push_back(gate); - } - } } \ No newline at end of file diff --git a/ls.h b/ls.h deleted file mode 100644 index 270c45c..0000000 --- a/ls.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "circuit.h" - -std::vector local_search(Circuit* circuit); - -// private -void init_circuit(Circuit* circuit); -void init_vector(Circuit* circuit, std::vector *vec); \ No newline at end of file diff --git a/main.cpp b/main.cpp index 9954451..ba86ac3 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,6 @@ #include #include "circuit.h" -#include "ls.h" int main(int args, char* argv[]) { @@ -12,31 +11,32 @@ int main(int args, char* argv[]) { exit(1); } + srand(19260817); + Circuit circuit; - printf("parsing file %s...\n", argv[1]); + printf("parsing file %s ...", argv[1]); circuit.parse_from_file(argv[1]); + circuit.init_stems(); + circuit.init_topo_index(); + printf(" Done.\n"); + printf("====== Circuit Statistics ====== \n"); printf("PI:\t%ld\n", circuit.PIs.size()); printf("PO:\t%ld\n", circuit.POs.size()); - printf("Gates:\t%ld\n", circuit.name2gate.size()); + printf("Gate:\t%ld\n", circuit.name2gate.size()); + printf("Stem:\t%ld\n", circuit.stems.size()); + printf("================================ \n"); - int cnt = 0; - for(auto& gate: circuit.gates) { - if(gate->outputs.size() > 2) { - cnt++; - } - } - printf("Stem:\t%d\n", cnt); + std::vector faults; - printf("cal topo index ...\n"); - circuit.cal_topo_index(); - for(Gate* gate : circuit.gates) { - assert(gate->topo > 0); + // init faults + for(auto stem : circuit.stems) { + faults.push_back(new Fault(stem, Fault::SA0)); + faults.push_back(new Fault(stem, Fault::SA1)); } - srand(19260817); - local_search(&circuit); + auto pattern = circuit.local_search(faults); return 0; } \ No newline at end of file