atpg-ls/circuit.h

27 lines
551 B
C
Raw Normal View History

2023-02-12 18:14:12 +08:00
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
class Gate {
public:
2023-02-12 16:22:32 +08:00
int topo;
std::string name;
2023-02-12 18:14:12 +08:00
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;
2023-02-12 16:22:32 +08:00
std::vector<Gate*> gates;
std::unordered_map<std::string, Gate*> name2gate;
void parse_from_file(const char *filename);
2023-02-12 18:14:12 +08:00
int cal_gate_value(const Gate* &gate);
2023-02-12 16:22:32 +08:00
void cal_topo_index();
2023-02-12 18:14:12 +08:00
};