PREFIX=../../.. YOSYS=${PREFIX}/bin/yosys NEXTPNR=${PREFIX}/bin/nextpnr-ice40 ICEPACK=${PREFIX}/bin/icepack ICETIME=${PREFIX}/bin/icetime FLASH=${PREFIX}/bin/flash BUILDDIR = ./build FPGA_TYPE = hx8k FPGA_PKG = ct256 PCF = ice40-io-video.pcf RMDIR = rmdir # Targets example: $(BUILDDIR)/example.rpt $(BUILDDIR)/example.bin example_0: $(BUILDDIR)/example_0.rpt $(BUILDDIR)/example_0.bin example_1: $(BUILDDIR)/example_1.rpt $(BUILDDIR)/example_1.bin example_2: $(BUILDDIR)/example_2.rpt $(BUILDDIR)/example_2.bin example_3: $(BUILDDIR)/example_3.rpt $(BUILDDIR)/example_3.bin example_4: $(BUILDDIR)/example_4.rpt $(BUILDDIR)/example_4.bin example_5: $(BUILDDIR)/example_5.rpt $(BUILDDIR)/example_5.bin example_6: $(BUILDDIR)/example_6.rpt $(BUILDDIR)/example_6.bin example_7: $(BUILDDIR)/example_7.rpt $(BUILDDIR)/example_7.bin flash: $(BUILDDIR)/example.bin ${FLASH} ${BUILDDIR}/example.bin $(BUILDDIR)/%.json: %.v @mkdir -p $(@D) ${YOSYS} -ql $(subst .json,,$@).log -p 'synth_ice40 -abc9 -device u -top top -json $@' $< %.asc: %.json ${NEXTPNR} --${FPGA_TYPE} --package ${FPGA_PKG} --json $< --pcf ${PCF} --asc $@ %.bin: %.asc ${ICEPACK} $< $@ %.rpt: %.asc ${ICETIME} -d $(FPGA_TYPE) -mtr $@ $< all: example example_0 example_1 example_2 example_3 example_4 example_5 example_6 example_7 clean: rm -f $(BUILDDIR)/*.asc $(BUILDDIR)/*.bin $(BUILDDIR)/*.rpt $(BUILDDIR)/*.log $(BUILDDIR)/*.json $(RMDIR) $(BUILDDIR) # Uncomment this line if you want to keep the intermediate .json and .asc files # .PRECIOUS: $(BUILDDIR)/%.json %.asc .PHONY: all prog clean example example_0 example_1 example_2 example_3 example_4 example_5 example_6 example_7