summaryrefslogtreecommitdiff
path: root/simulator.c
blob: c6462ea88be93234a5096b46b5c663a2de1c880e (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
#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;

	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;
}