atpg-ls/circuit.h

27 lines
551 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 Circuit {
public:
std::vector<Gate*> PIs;
std::vector<Gate*> POs;
std::vector<Gate*> gates;
std::unordered_map<std::string, Gate*> name2gate;
void parse_from_file(const char *filename);
int cal_gate_value(const Gate* &gate);
void cal_topo_index();
};