summaryrefslogtreecommitdiff
path: root/gate.h
blob: bd5dc650e3c71db8435c41fd6e8918720a97b5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef GATE_H
#define GATE_H

#include <stddef.h>

#include "logic.h"

enum NODE_TYPE {
	NODE_INPUT,
	NODE_OUTPUT
};

struct gate {
	char *name;
	enum BINARY (*operation)(enum BINARY, enum BINARY);
	enum BINARY output;
	struct gate *in1;
	struct gate *in2;
};

void gate_update_output(struct gate *);
int gate_input_add(char *name);
struct gate* gate_get_input_by_name(char *name);
int gate_add(char *name, enum BINARY (*operation)(enum BINARY, enum BINARY), struct gate *in1, struct gate *in2);
int tick(void);
void gate_init(void);
void gate_dump(void);
int gate_set_input(char *name, enum BINARY value);
void gate_update(void);

#endif