summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorVaino Kauppila <vaino@vke.fi>2026-04-19 12:32:58 +0300
committerVaino Kauppila <vaino@vke.fi>2026-04-19 12:32:58 +0300
commiteb8643ddbef43547eb7bfe58789a3908926c7258 (patch)
treefadfba88a1c71b266b8c67df166a3a6ead6b30d1 /Makefile
parent129a1c975dbd0c042576010b1f6eb40d19fc5733 (diff)
downloadvhdl_pic-eb8643ddbef43547eb7bfe58789a3908926c7258.tar.gz
vhdl_pic-eb8643ddbef43547eb7bfe58789a3908926c7258.zip
refactor dir structure, add fib.c
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile41
1 files changed, 21 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index dbc5712..ca56c27 100644
--- a/Makefile
+++ b/Makefile
@@ -1,54 +1,55 @@
IMAGE = fpga-tools
PODMAN = podman run --rm -v $(CURDIR):/workspace $(IMAGE)
+BUILD = build
+
# Which C program to build. Override: make PROG=test_uart
PROG ?= blink
-# ── Host-side C compilation (sdcc on host) ──────────────────────────────────
+$(BUILD):
+ mkdir -p $@
-blink.hex: PIC/blink.c
- sdcc --use-non-free -mpic14 -p16f84a $<
+# -- Host-side C compilation (sdcc on host) --------------------------------------------
-test_uart.hex: PIC/test_uart.c
- sdcc --use-non-free -mpic14 -p16f84a $<
+$(BUILD)/%.hex: fw/%.c | $(BUILD)
+ cd $(BUILD) && sdcc --use-non-free -mpic14 -p16f84a $(CURDIR)/fw/$*.c
# program.hex is what the testbench loads at runtime
-program.hex: $(PROG).hex
+$(BUILD)/program.hex: $(BUILD)/$(PROG).hex
cp $< $@
# prog_rom.vhd embeds the program for synthesis
-PIC/prog_rom.vhd: program.hex
+hdl/prog_rom.vhd: $(BUILD)/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
+ python3 hex2rom.py $(HEX) > hdl/prog_rom.vhd
-# ── Container targets ────────────────────────────────────────────────────────
+# -- Container targets ----------------------------------------------------------------------------
-all: PIC/prog_rom.vhd
+all: hdl/prog_rom.vhd
$(PODMAN) make -f Makefile.inner
-sim: program.hex
+sim: $(BUILD)/program.hex
$(PODMAN) make -f Makefile.inner sim
-flash: pic_top.fs
+flash: $(BUILD)/pic_top.fs
openFPGALoader -b tangprimer25k $<
show-top:
- $(PODMAN) make -f Makefile.inner pic_top.dot
- xdot pic_top.dot
+ $(PODMAN) make -f Makefile.inner $(BUILD)/pic_top.dot
+ xdot $(BUILD)/pic_top.dot
show-uart:
- $(PODMAN) make -f Makefile.inner uart.dot
- xdot uart.dot
+ $(PODMAN) make -f Makefile.inner $(BUILD)/uart.dot
+ xdot $(BUILD)/uart.dot
-# ── Clean ────────────────────────────────────────────────────────────────────
+# -- 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
+ rm -rf $(BUILD)
+ rm -f hdl/prog_rom.vhd
.PHONY: all sim clean flash show-top show-uart rom