20 lines
459 B
C++
20 lines
459 B
C++
#include <string>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
|
|
class Gate {
|
|
public:
|
|
std::string name;
|
|
enum { AND, NAND, OR, NOR, XOR, XNOR, NOT, BUF, INPUT, OUTPUT } type;
|
|
enum { VAL_ZERO, VAL_ONE, VAL_X } value;
|
|
std::vector<Gate*> outputs;
|
|
std::vector<Gate*> inputs;
|
|
};
|
|
|
|
class Circuit {
|
|
public:
|
|
std::vector<Gate*> PIs;
|
|
std::vector<Gate*> POs;
|
|
std::unordered_map<std::string, Gate*> name2gate;
|
|
void parse_from_file(const char *filename);
|
|
}; |