SOURCES := $(shell find hdl sim -name \*.sv -o -name \*.cpp) HEADERS := $(shell find hdl -name \*.svh) MEMORIES := $(shell find mem -name \*.hex) $(addprefix build/, $(addsuffix .hex, $(basename $(shell find mem -name \*.bin -o -name \*.pal)))) QUARTUS := $(shell find altera tcl -name \*.cdf -o -name \*.sdc -o -name \*.tcl) OPTS ?= sim: build/Vtop $(MEMORIES) $< .PHONY: sim build/p8bin2hex: tool/p8bin2hex.c @mkdir -p build gcc -Wall -Werror -o $@ $< build/%.hex: build/%.bin build/p8bin2hex build/p8bin2hex $< > $@ build/%.hex: %.bin build/p8bin2hex build/p8bin2hex $< > $@ build/%.bin: %.pal @mkdir -p $(dir $@) palbart $< mv -f $*.bin $*.lst $(dir $@) build/Vtop: $(SOURCES) $(HEADERS) @rm -rf verilator @mkdir -p build verilator verilator +1800-2017ext+sv -Wall -Wno-BLKSEQ -Wno-UNUSED -O3 -Ihdl $(OPTS) --Mdir verilator --trace --cc --build -j --exe --top-module top $(SOURCES) @ln -t build -f verilator/Vtop @rm -rf verilator noncpu.sof: $(SOURCES) $(HEADERS) $(MEMORIES) $(QUARTUS) [ ! -e noncpu.qpf ] || quartus_sh -t tcl/clean.tcl quartus_sh -t tcl/init.tcl quartus_sh --flow compile noncpu.qpf fpga: noncpu.sof quartus_pgm -c 1 -m JTAG -o "P;$<@1" nios2-terminal .PHONY: fpga clean: git clean -dfX .PHONY: clean .SECONDARY: