From d613341d1c74f945dd7f198ef41a88684a975a98 Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Sun, 12 Feb 2023 18:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E9=83=A8=E5=88=86?= =?UTF-8?q?=20ls=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atpg | Bin 44304 -> 44760 bytes circuit.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ circuit.h | 9 ++++++--- ls.cpp | 35 ++++++++++++++++++++++++++++++++++ ls.h | 9 +++++++++ main.cpp | 13 ++++++++++++- parser.cpp | 4 +--- 7 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 ls.cpp create mode 100644 ls.h diff --git a/atpg b/atpg index 6c332445df2307481c278bf576049e8677487e2a..fcca67dcdf06e0bf8d3df4a56c8f29850d24dc07 100755 GIT binary patch delta 12957 zcmZ`<4_s7L_J41f!Qt-=e{=>!8Ff&=KY)sYhB1oqMn}cOLf1`L#MG!TA=$)6;!jS) z7C@7MxURxoyuC8o4A1t%;RsEBOP|dP zn)z3yR$gEW|0#>;*Uf*$c>QAjeO9E8=XbMey(y+eQI7?aQdtj)hHz#smF>}+(mECF zItj;d=YSnbnw}{G`YCX`GODoo2mPi%-KvL*9$4~xgMlv&kD8|tr!KkR?h>GX5>|5hN{yP>F5kL0^HlEC&==z^E9Jq!; zKI$KT2aDL zq4exz8zW7uGBPwQ#ShxU(g1CW3{6P$gBly<4q4l9KX?nf6lp3_H<`3M!4F&LmOBK` z@PqI6gOBrrrz&TN=+ph+m27U5DQ4XU8AQs#=Jb~JtUAiXmPLhz(O#?NX|@N@rvat2 ztd=JBC7?$DRdq+0eJmo{#I6GxtP-L=!fb#hMu&!l`awI`N^VT!M~B9c zwW#H~pTrUDpV6kUNEL-z&-nf(CW2G6AJoj!05$gy4IAJGO=LxY3V@pZpc!lH{2i*_SY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&?4bqdhZV5E}s2< zT9lR-v>LxSed_(;QCasZ(`a>PFy97Py9Q|WuLA%1{o#D!Ml;XaXz!sVwLSdNjiY*K zQN5LKK~GC4PJVIYs7Ngtype) { + case Gate::NOT: + res = !gate->inputs[0]->value; + break; + case Gate::BUF: + res = gate->inputs[0]->value; + break; + case Gate::AND: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res &= gate->inputs[i]->value; + } + break; + case Gate::NAND: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res &= gate->inputs[i]->value; + } + res = !res; + break; + case Gate::OR: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res |= gate->inputs[i]->value; + } + break; + case Gate::NOR: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res |= gate->inputs[i]->value; + } + res = !res; + break; + case Gate::XOR: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res ^= gate->inputs[i]->value; + } + break; + case Gate::XNOR: + res = gate->inputs[0]->value; + for(int i=1; iinputs.size(); i++) { + res ^= gate->inputs[i]->value; + } + res = !res; + break; + } + return res; } \ No newline at end of file diff --git a/circuit.h b/circuit.h index a893714..64d4ff7 100644 --- a/circuit.h +++ b/circuit.h @@ -1,3 +1,5 @@ +#pragma once + #include #include #include @@ -6,8 +8,8 @@ class Gate { public: int topo; std::string name; - enum { AND, NAND, OR, NOR, XOR, XNOR, NOT, BUF, INPUT, OUTPUT } type; - enum { VAL_ZERO, VAL_ONE, VAL_X } value; + enum Type { AND, NAND, OR, NOR, XOR, XNOR, NOT, BUF, INPUT, OUTPUT } type; + int value; std::vector outputs; std::vector inputs; }; @@ -19,6 +21,7 @@ std::vector POs; std::vector gates; std::unordered_map name2gate; void parse_from_file(const char *filename); +int cal_gate_value(const Gate* &gate); void cal_topo_index(); -void cal_headlines(); + }; \ No newline at end of file diff --git a/ls.cpp b/ls.cpp new file mode 100644 index 0000000..0471d53 --- /dev/null +++ b/ls.cpp @@ -0,0 +1,35 @@ +#include "ls.h" + + +std::vector local_search(Circuit* circuit) { + + // local search vector + std::vector vec; + + init_vector(circuit, &vec); + + init_circuit(circuit); + + printf("local search!\n"); + + return std::vector(); +} + + +void init_circuit(Circuit* circuit) { + for(auto pi : circuit->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 new file mode 100644 index 0000000..270c45c --- /dev/null +++ b/ls.h @@ -0,0 +1,9 @@ +#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 e1c8ad7..9954451 100644 --- a/main.cpp +++ b/main.cpp @@ -2,8 +2,8 @@ #include #include - #include "circuit.h" +#include "ls.h" int main(int args, char* argv[]) { @@ -21,11 +21,22 @@ int main(int args, char* argv[]) { printf("PO:\t%ld\n", circuit.POs.size()); printf("Gates:\t%ld\n", circuit.name2gate.size()); + int cnt = 0; + for(auto& gate: circuit.gates) { + if(gate->outputs.size() > 2) { + cnt++; + } + } + printf("Stem:\t%d\n", cnt); + printf("cal topo index ...\n"); circuit.cal_topo_index(); for(Gate* gate : circuit.gates) { assert(gate->topo > 0); } + srand(19260817); + local_search(&circuit); + return 0; } \ No newline at end of file diff --git a/parser.cpp b/parser.cpp index fe276e7..83f8f89 100644 --- a/parser.cpp +++ b/parser.cpp @@ -73,7 +73,6 @@ void Circuit::parse_from_file(const char *filename) { Gate* gate = new Gate(); gate->name = tokens[0]; - gate->value = Gate::VAL_X; for(auto &in : ins) { if(!name2gate.count(in)) { @@ -109,10 +108,9 @@ void Circuit::parse_from_file(const char *filename) { Gate* gate = new Gate(); gate->name = tokens[2]; gate->type = Gate::INPUT; - gate->value = Gate::VAL_X; name2gate.insert(std::make_pair(gate->name, gate)); - gates.push_back(gate); + // gates.push_back(gate); PIs.push_back(gate); } // gate