sockit/fpga/syn/Makefile

89 lines
2.9 KiB
Makefile
Raw Normal View History

# #############################################
# (2014) Benjamin Krill <benjamin@krll.de>
# #############################################
PWD = $(shell pwd)
ifndef TOP
TOP = $(shell while ! test -d syn; do cd .. ; done; pwd)
export TOP
endif
PROJECT := sockit
BUILD_DIR := $(PWD)/build_$(PROJECT)
BUILD_QUARTUS_DIR := $(BUILD_DIR)/quartus
##### SOURCE FILES ############################
SOURCE_QIP = $(TOP)/top/$(PROJECT).qip
##### DEFAULT #################################
.PHONY: default
default: help
##### QSYS ####################################
.PHONY: qsys-generate qsys-edit
QSYS_FILE := $(TOP)/soc/soc_system.qsys
QSYS_BASE := $(basename $(notdir $(QSYS_FILE)))
QSYS_OUTDIR := $(BUILD_DIR)/$(QSYS_BASE)
QSYS_QIP := $(QSYS_OUTDIR)/$(QSYS_BASE).qip
QSYS_SOPCINFO := $(QSYS_OUTDIR)/$(QSYS_BASE).sopcinfo
SOURCE_QIP += $(QSYS_QIP)
$(QSYS_QIP) qsys-generate: config $(QSYS_FILE)
ip-generate \
--component-file=$(QSYS_FILE) \
--file-set=QUARTUS_SYNTH \
--output-name=$(QSYS_BASE) \
--output-directory=$(QSYS_OUTDIR) \
--reportfile=sopcinfo:$(QSYS_SOPCINFO) \
--reportfile=qip:$(QSYS_QIP) \
--language=vhdl
touch $(QSYS_QIP)
qsys-edit: $(QSYS_FILE)
qsys-edit $^ &
HELP_TARGETS += qsys-generate qsys-edit
qsys-generate.HELP := Generate current QSYS implementation
qsys-edit.HELP := Edit QSYS implementation
##### QUARTUS ###################################
QUARTUS_QPF := $(PROJECT).qpf
QUARTUS_QSF := $(PROJECT).qsf
tcl: $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf $(BUILD_QUARTUS_DIR)/$(PROJECT).qpf
@cd $(BUILD_QUARTUS_DIR) && for pin_assign_tcl_file in $$(find $(BUILD_DIR) -name '*_pin_assignments.tcl'); do \
quartus_map $(QUARTUS_QPF); \
echo "Applying $${pin_assign_tcl_file} to $(QUARTUS_QPF)..."; \
quartus_sta -t $${pin_assign_tcl_file} $(QUARTUS_QPF); \
done
$(BUILD_QUARTUS_DIR)/output_files/sockit.sof quartus: tcl
cd $(BUILD_QUARTUS_DIR) && quartus_sh --flow compile $(QUARTUS_QPF)
##### CONFIGURE BUILD ###########################
.PHONY: config
config $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf:
mkdir -p $(BUILD_QUARTUS_DIR)
cp $(PROJECT).qpf_tmpl $(BUILD_QUARTUS_DIR)/$(PROJECT).qpf
cp $(PROJECT).qsf_tmpl $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf
for I in $(SOURCE_QIP); do \
echo "set_global_assignment -name QIP_FILE $$I" >> $(BUILD_QUARTUS_DIR)/$(PROJECT).qsf; \
done
HELP_TARGETS += config
config.HELP := create build sandbox
##### HELP ######################################
.PHONY: $(HELP_TARGETS_X) help
HELP_TARGETS += help
help.HELP := Displays this info (i.e. the available targets)
help: help-header help-targets
HELP_TARGETS_X := $(patsubst %,help-%,$(sort $(HELP_TARGETS)))
help-targets: $(HELP_TARGETS_X)
$(HELP_TARGETS_X): help-%:
@printf "\t%20s\t - %s\n" $* "$($*.HELP)"
help-header:
@printf "\t%20s\t - %s\n" target description\n
@printf "\t------------------------------------------------------------------------------\n"