summaryrefslogtreecommitdiff
path: root/simulator.c
blob: 657355f2b96ba56920136b6396e04632ac907d0f (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
#include <stdio.h>
#include <string.h>

#include "gate.h"
#include "logic.h"
#include "parser.h"

int main(int argc, char **argv) {
	char buf[4096];
	FILE *fd = stdin;

	(void)argc;
	(void)argv;

	logic_test();
	gate_init();

	while (NULL != fgets(buf, sizeof(buf), fd)) {
		buf[strcspn(buf, "\r\n")] = '\0';
		if (parse_line(buf)) {
			return 1;
		}
	}

	gate_set_input("a", LOGIC_LOW);
	gate_set_input("b", LOGIC_LOW);
	gate_update();
	gate_dump();

	return 0;
}