atpg-ls/circuit.h
2023-02-16 18:51:31 +08:00

44 lines
899 B
C++

#pragma once
#include <string>
#include <vector>
#include <unordered_map>
class Gate {
public:
int topo;
std::string name;
enum Type { AND, NAND, OR, NOR, XOR, XNOR, NOT, BUF, INPUT, OUTPUT } type;
int value;
std::vector<Gate*> outputs;
std::vector<Gate*> 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<Gate*> PIs;
std::vector<Gate*> POs;
std::vector<Gate*> gates;
std::vector<Gate*> stems;// PI + stems
std::unordered_map<std::string, Gate*> name2gate;
void parse_from_file(const char *filename);
int cal_gate_value(const Gate* &gate);
void init_topo_index();
void init_stems();
// local search
std::vector<int> local_search(const std::vector<Fault*> &faults);
void ls_init_circuit();
void ls_init_vector(std::vector<Gate*> *vec);
};