IMAGE = fpga-tools PODMAN = podman run --rm --cpus=$(shell nproc) -v $(CURDIR):/workspace $(IMAGE) BUILD = build # Which C program to build. Override: make PROG=test_uart PROG ?= blink override PROG := $(basename $(PROG)) $(BUILD): mkdir -p $@ # -- Host-side C compilation (sdcc on host) -------------------------------------------- $(BUILD)/%.hex: fw/%.c | $(BUILD) cd $(BUILD) && sdcc --use-non-free -mpic14 -p16f84a \ -Wl-s -Wl$(CURDIR)/fw/fpga_pic.lkr \ $(CURDIR)/fw/$*.c # program.hex is what the testbench loads at runtime $(BUILD)/program.hex: $(BUILD)/$(PROG).hex cp $< $@ # prog_rom.vhd embeds the program for synthesis 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) > hdl/prog_rom.vhd # -- Container targets ---------------------------------------------------------------------------- all: hdl/prog_rom.vhd $(PODMAN) make -f Makefile.inner sim: $(BUILD)/program.hex $(PODMAN) make -f Makefile.inner sim flash: $(BUILD)/pic_top.fs openFPGALoader -b tangprimer25k $< show-top: $(PODMAN) make -f Makefile.inner $(BUILD)/pic_top.dot xdot $(BUILD)/pic_top.dot show-uart: $(PODMAN) make -f Makefile.inner $(BUILD)/uart.dot xdot $(BUILD)/uart.dot # -- Clean ---------------------------------------------------------------------------- clean: $(PODMAN) make -f Makefile.inner clean rm -rf $(BUILD) rm -f hdl/prog_rom.vhd .PHONY: all sim clean flash show-top show-uart rom