summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: dbc5712099cd785f6f2a427582cb4eae80a1ec98 (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
IMAGE  = fpga-tools
PODMAN = podman run --rm -v $(CURDIR):/workspace $(IMAGE)

# Which C program to build.  Override: make PROG=test_uart
PROG ?= blink

# ── Host-side C compilation (sdcc on host) ──────────────────────────────────

blink.hex: PIC/blink.c
	sdcc --use-non-free -mpic14 -p16f84a $<

test_uart.hex: PIC/test_uart.c
	sdcc --use-non-free -mpic14 -p16f84a $<

# program.hex is what the testbench loads at runtime
program.hex: $(PROG).hex
	cp $< $@

# prog_rom.vhd embeds the program for synthesis
PIC/prog_rom.vhd: program.hex
	python3 hex2rom.py $< > $@

# Regenerate ROM from an arbitrary hex file: make rom HEX=foo.hex
rom:
	python3 hex2rom.py $(HEX) > PIC/prog_rom.vhd

# ── Container targets ────────────────────────────────────────────────────────

all: PIC/prog_rom.vhd
	$(PODMAN) make -f Makefile.inner

sim: program.hex
	$(PODMAN) make -f Makefile.inner sim

flash: pic_top.fs
	openFPGALoader -b tangprimer25k $<

show-top:
	$(PODMAN) make -f Makefile.inner pic_top.dot
	xdot pic_top.dot

show-uart:
	$(PODMAN) make -f Makefile.inner uart.dot
	xdot uart.dot

# ── Clean ────────────────────────────────────────────────────────────────────

clean:
	$(PODMAN) make -f Makefile.inner clean
	rm -f program.hex PIC/prog_rom.vhd
	rm -f blink.hex blink.asm blink.cod blink.lst
	rm -f test_uart.hex test_uart.asm test_uart.cod test_uart.lst

.PHONY: all sim clean flash show-top show-uart rom