#Auto generated by Edalize

TARGET   := {{ name }}
PCF_FILE := {{ pcf_file }}
PNR      ?= {{ pnr }}
ARACHNE_PNR_OPTIONS := {{ arachne_pnr_options|join(' ') }}
NEXTPNR_OPTIONS     := {{ nextpnr_options|join(' ') }}

all: $(TARGET).bin

%.blif: %.ys
	yosys -q -s $?
%_arachne.asc: $(PCF_FILE) %.blif
	arachne-pnr $(ARACHNE_PNR_OPTIONS) -q -p $? -o $@
%.json: %.ys
	yosys -q -s $?
%_next.asc: %.json
	nextpnr-ice40 -q $(NEXTPNR_OPTIONS) --pcf $(PCF_FILE) --json $? --asc $@
%.bin: %_$(PNR).asc
	icepack $< $@

build-gui: $(TARGET).json
	nextpnr-ice40 -q $(NEXTPNR_OPTIONS) --pcf $(PCF_FILE) --json $? --asc $@ --gui

clean:
	rm -f $(TARGET).blif $(TARGET).json $(TARGET)_arachne.asc $(TARGET)_next.asc $(TARGET).bin

