#Auto generated by Edalize

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

all: $(TARGET).{{ default_target }}
timing: $(TARGET).tim
stats: $(TARGET).stat

.PRECIOUS: %_next.asc %_arachne.asc

%.blif: %.mk
	$(MAKE) -f $<
%_arachne.asc: $(PCF_FILE) %.blif
	$(EDALIZE_LAUNCHER) arachne-pnr $(ARACHNE_PNR_OPTIONS) -q -p $? -o $@
%.json: %.mk
	$(MAKE) -f $<
%_next.asc: %.json
	$(EDALIZE_LAUNCHER) nextpnr-ice40 -l next.log $(NEXTPNR_OPTIONS) --pcf $(PCF_FILE) --json $? --asc $@
%.bin: %_$(PNR).asc
	$(EDALIZE_LAUNCHER) icepack $< $@
%.tim: %_$(PNR).asc
	$(EDALIZE_LAUNCHER) icetime -tmd $(DEVICE) $< > $@
%.stat: %_$(PNR).asc
	$(EDALIZE_LAUNCHER) icebox_stat $< > $@

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

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