summaryrefslogtreecommitdiff
path: root/Makefile
blob: 9f7967449e06cc3b7e2201cff07e48fee744a5a4 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
SOURCES := $(wildcard hdl/**.sv)
HEADERS := $(wildcard hdl/**.svh)
MEMORIES := $(addprefix build/, $(addsuffix .hex, $(basename $(wildcard mem/**.pal))))
QUARTUS := $(shell find altera tcl -name \*.cdf -o -name \*.sdc -o -name \*.tcl)

fpga: pdp8.sof
	quartus_pgm -c 1 -m JTAG -o "P;$<@1"
.PHONY: fpga

download-%.bin: mem/%.bin
	p8bin2uart 1 $< | tool/download.tcl  0 1
	p8bin2uart 1 $< | tool/download.tcl  1 1
	p8bin2uart 1 $< | tool/download.tcl  2 1
	p8bin2uart 1 $< | tool/download.tcl  3 1
	p8bin2uart 1 $< | tool/download.tcl  4 1
	p8bin2uart 1 $< | tool/download.tcl  5 1
	p8bin2uart 1 $< | tool/download.tcl  6 1
	p8bin2uart 1 $< | tool/download.tcl  7 1
	p8bin2uart 1 $< | tool/download.tcl  8 1
	p8bin2uart 1 $< | tool/download.tcl  9 1
	p8bin2uart 1 $< | tool/download.tcl 10 1
	p8bin2uart 1 $< | tool/download.tcl 11 1
	p8bin2uart 1 $< | tool/download.tcl 12 1
	p8bin2uart 1 $< | tool/download.tcl 13 1
	p8bin2uart 1 $< | tool/download.tcl 14 1
	p8bin2uart 1 $< | tool/download.tcl 15 1

download-%.pal: build/mem/%.bin
	p8bin2uart 1 $< | tool/download.tcl  0 1
	p8bin2uart 1 $< | tool/download.tcl  1 1
	p8bin2uart 1 $< | tool/download.tcl  2 1
	p8bin2uart 1 $< | tool/download.tcl  3 1
	p8bin2uart 1 $< | tool/download.tcl  4 1
	p8bin2uart 1 $< | tool/download.tcl  5 1
	p8bin2uart 1 $< | tool/download.tcl  6 1
	p8bin2uart 1 $< | tool/download.tcl  7 1
	p8bin2uart 1 $< | tool/download.tcl  8 1
	p8bin2uart 1 $< | tool/download.tcl  9 1
	p8bin2uart 1 $< | tool/download.tcl 10 1
	p8bin2uart 1 $< | tool/download.tcl 11 1
	p8bin2uart 1 $< | tool/download.tcl 12 1
	p8bin2uart 1 $< | tool/download.tcl 13 1
	p8bin2uart 1 $< | tool/download.tcl 14 1
	p8bin2uart 1 $< | tool/download.tcl 15 1


download-%.uart: mem/%.uart
	tool/download.tcl  0 1 < $<
	tool/download.tcl  1 1 < $<
	tool/download.tcl  2 1 < $<
	tool/download.tcl  3 1 < $<
	tool/download.tcl  4 1 < $<
	tool/download.tcl  5 1 < $<
	tool/download.tcl  6 1 < $<
	tool/download.tcl  7 1 < $<
	tool/download.tcl  8 1 < $<
	tool/download.tcl  9 1 < $<
	tool/download.tcl 10 1 < $<
	tool/download.tcl 11 1 < $<
	tool/download.tcl 12 1 < $<
	tool/download.tcl 13 1 < $<
	tool/download.tcl 14 1 < $<
	tool/download.tcl 15 1 < $<

term-mem:
	nios2-terminal --instance 0
.PHONY: term-mem

term-pdp8:
	nios2-terminal --instance 1
.PHONY: term-pdp8

build/%.bin: %.pal
	@mkdir -p $(dir $@)
	palbart $<
	mv -f $*.bin $*.lst $(dir $@)

pdp8.sof: $(SOURCES) $(HEADERS) $(MEMORIES) $(QUARTUS)
	[ ! -e pdp8.qpf ] || quartus_sh -t tcl/clean.tcl
	quartus_sh -t tcl/init.tcl
	quartus_sh --flow compile pdp8.qpf

clean:
	git clean -dfX
.PHONY: clean

.SECONDARY: