#Auto generated by Edalize

TARGET   := {{ name }}

all: $(TARGET).fasm

ifndef INTERCHANGE_SCHEMA_PATH
$(error Environment variable INTERCHANGE_SCHEMA_PATH was not found. It should be set to <fpga-interchange-schema path>/interchange)
endif

{% for xdc in constr %}
XDCS += --xdc {{ xdc }}
{% endfor %}

{{ name }}.json: {{ name }}.mk
	$(EDALIZE_LAUNCHER) $(MAKE) -f $<

{{ name }}.netlist: {{ name }}.json
	$(EDALIZE_LAUNCHER) python -m fpga_interchange.yosys_json --schema_dir $(INTERCHANGE_SCHEMA_PATH) --device {{ device }} --top {{ toplevel }} {{ name }}.json {{ name }}.netlist

{{ name }}.phys: {{ name }}.netlist
	$(EDALIZE_LAUNCHER) nextpnr-{{ arch }} --chipdb {{ chipdb }} --package {{ package }} $(XDCS) --netlist {{ name }}.netlist --write {{ name }}.routed.json --phys {{ name }}.phys {{ additional_options }}

{{ name }}.fasm: {{ name }}.phys
	$(EDALIZE_LAUNCHER) python -m fpga_interchange.fasm_generator --schema_dir $(INTERCHANGE_SCHEMA_PATH) --family {{ family }} {{ device }} {{ name }}.netlist {{ name }}.phys {{ name }}.fasm

clean:
	$(EDALIZE_LAUNCHER) rm -f $(TARGET).json $(TARGET).routed.json $(TARGET).netlist $(TARGET).phys $(TARGET).fasm
