1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

124 lines
4.0 KiB
Makefile
Raw Normal View History

2019-03-28 19:38:55 -07:00
###################################################################
#
# Xilinx Vivado FPGA Makefile
#
# Copyright (c) 2016 Alex Forencich
#
###################################################################
#
# Parameters:
# FPGA_TOP - Top module name
# FPGA_FAMILY - FPGA family (e.g. VirtexUltrascale)
# FPGA_DEVICE - FPGA device (e.g. xcvu095-ffva2104-2-e)
# SYN_FILES - space-separated list of source files
# INC_FILES - space-separated list of include files
# XDC_FILES - space-separated list of timing constraint files
# XCI_FILES - space-separated list of IP XCI files
#
# Example:
#
# FPGA_TOP = fpga
# FPGA_FAMILY = VirtexUltrascale
# FPGA_DEVICE = xcvu095-ffva2104-2-e
# SYN_FILES = rtl/fpga.v
# XDC_FILES = fpga.xdc
# XCI_FILES = ip/pcspma.xci
# include ../common/vivado.mk
#
###################################################################
# phony targets
.PHONY: clean fpga
# prevent make from deleting intermediate files and reports
2019-06-27 00:59:36 -07:00
.PRECIOUS: %.xpr %.bit %.mcs %.prm
2019-03-28 19:38:55 -07:00
.SECONDARY:
CONFIG ?= config.mk
-include ../$(CONFIG)
SYN_FILES_REL = $(patsubst %, ../%, $(SYN_FILES))
INC_FILES_REL = $(patsubst %, ../%, $(INC_FILES))
XCI_FILES_REL = $(patsubst %, ../%, $(XCI_FILES))
2020-07-01 19:43:26 -07:00
IP_TCL_FILES_REL = $(patsubst %, ../%, $(IP_TCL_FILES))
2019-03-28 19:38:55 -07:00
ifdef XDC_FILES
XDC_FILES_REL = $(patsubst %, ../%, $(XDC_FILES))
else
XDC_FILES_REL = $(FPGA_TOP).xdc
endif
###################################################################
# Main Targets
#
# all: build everything
# clean: remove output files and project files
###################################################################
all: fpga
fpga: $(FPGA_TOP).bit
2020-08-06 17:19:11 -07:00
vivado: $(FPGA_TOP).xpr
vivado $(FPGA_TOP).xpr
2019-03-28 19:38:55 -07:00
tmpclean:
2020-07-01 19:43:26 -07:00
-rm -rf *.log *.jou *.cache *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
2019-03-28 19:38:55 -07:00
-rm -rf create_project.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
clean: tmpclean
2019-06-27 00:59:36 -07:00
-rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
2019-03-28 19:38:55 -07:00
distclean: clean
-rm -rf rev
###################################################################
# Target implementations
###################################################################
# Vivado project file
2020-08-06 17:19:11 -07:00
%.xpr: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
2019-03-28 19:38:55 -07:00
rm -rf defines.v
touch defines.v
for x in $(DEFS); do echo '`define' $$x >> defines.v; done
echo "create_project -force -part $(FPGA_PART) $*" > create_project.tcl
echo "add_files -fileset sources_1 defines.v" >> create_project.tcl
for x in $(SYN_FILES_REL); do echo "add_files -fileset sources_1 $$x" >> create_project.tcl; done
for x in $(XDC_FILES_REL); do echo "add_files -fileset constrs_1 $$x" >> create_project.tcl; done
for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> create_project.tcl; done
2020-07-01 19:43:26 -07:00
for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> create_project.tcl; done
2019-03-28 19:38:55 -07:00
echo "exit" >> create_project.tcl
2019-06-27 00:59:36 -07:00
vivado -nojournal -nolog -mode batch -source create_project.tcl
2019-03-28 19:38:55 -07:00
# synthesis run
%.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL)
echo "open_project $*.xpr" > run_synth.tcl
echo "reset_run synth_1" >> run_synth.tcl
echo "launch_runs synth_1" >> run_synth.tcl
echo "wait_on_run synth_1" >> run_synth.tcl
echo "exit" >> run_synth.tcl
2019-06-27 00:59:36 -07:00
vivado -nojournal -nolog -mode batch -source run_synth.tcl
2019-03-28 19:38:55 -07:00
# implementation run
%.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
echo "open_project $*.xpr" > run_impl.tcl
echo "reset_run impl_1" >> run_impl.tcl
echo "launch_runs impl_1" >> run_impl.tcl
echo "wait_on_run impl_1" >> run_impl.tcl
echo "exit" >> run_impl.tcl
2019-06-27 00:59:36 -07:00
vivado -nojournal -nolog -mode batch -source run_impl.tcl
2019-03-28 19:38:55 -07:00
# bit file
%.bit: %.runs/impl_1/%_routed.dcp
echo "open_project $*.xpr" > generate_bit.tcl
echo "open_run impl_1" >> generate_bit.tcl
echo "write_bitstream -force $*.bit" >> generate_bit.tcl
echo "exit" >> generate_bit.tcl
2019-06-27 00:59:36 -07:00
vivado -nojournal -nolog -mode batch -source generate_bit.tcl
2019-03-28 19:38:55 -07:00
mkdir -p rev
EXT=bit; COUNT=100; \
while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
2019-06-27 00:59:36 -07:00
do COUNT=$$((COUNT+1)); done; \
2019-03-28 19:38:55 -07:00
cp $@ rev/$*_rev$$COUNT.$$EXT; \
echo "Output: rev/$*_rev$$COUNT.$$EXT";