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.v embeds the program for synthesis hdl/prog_rom.v: $(BUILD)/program.hex $(PODMAN) python3 hdl/rom.py $< > $@ # Regenerate ROM from an arbitrary hex file: make rom HEX=foo.hex rom: $(PODMAN) python3 hdl/rom.py --module prog_ram $(HEX) > hdl/prog_rom.v # -- Container targets ---------------------------------------------------------------------------- all: hdl/prog_rom.v $(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.v .PHONY: all sim clean flash show-top show-uart rom