forked from openXC7/xc7k325t-blinky-nextpnr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (90 loc) · 3.53 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
PROJECT_NAME ?= blinky
PREFIX ?= ${HOME}/opt
DB_DIR = ${PREFIX}/nextpnr/prjxray-db
CHIPDB_DIR = ${PREFIX}/nextpnr/xilinx-chipdb
XRAY_DIR ?= ${PREFIX}/prjxray
XRAY_UTILS_DIR = ${PWD}/prjxray/env/bin
XRAY_TOOLS_DIR = ${XRAY_DIR}/bin
NEXTPNR_DIR ?= ${PREFIX}/nextpnr
SHELL = /bin/bash
PYTHONPATH ?= ${XRAY_DIR}
QMTECH_CABLE ?= tigard
STLV_CABLE ?= tigard
JOBS ?= 4
# This workaround is only required for macOS, because Apple has explicitly disabled OpenMP support in their compilers.
ifeq ($(shell uname -s),Darwin)
HOME_BREW = $(shell brew --prefix llvm)
NEXTPNR_BUILD_ENV = env CC=${HOME_BREW}/bin/clang CXX=${HOME_BREW}/bin/clang++ LDFLAGS="-L${HOME_BREW}/lib -Wl,-rpath,${HOME_BREW}/lib"
NEXTPNR_CMAKE_FLAGS = -DBUILD_GUI=0 -DBUILD_PYTHON=0
PRJXRAY_BUILD_ENV = env CXXFLAGS="-std=c++11"
endif
ifeq (${BOARD}, qmtech)
PART = xc7k325tffg676-1
PROG = openFPGALoader --cable ${QMTECH_CABLE} --board qmtechKintex7 --bitstream ${PROJECT_NAME}-${BOARD}.bit
else ifeq (${BOARD}, genesys2)
PART = xc7k325tffg900-2
CLK = -diffclk
PROG = openFPGALoader --board genesys2 --bitstream ${PROJECT_NAME}-${BOARD}.bit
else ifeq (${BOARD}, stlv7325)
PART = xc7k325tffg676-1
CLK = -diffclk
PROG = openFPGALoader --cable ${STLV_CABLE} --bitstream ${PROJECT_NAME}-${BOARD}.bit
else
.PHONY: check
check:
@echo "BOARD environment variable not set. Available boards:"
@echo " * qmtech"
@echo " * genesys2"
@echo " * stlv7325"
@exit 1
endif
.PHONY: all
all: ${PROJECT_NAME}-${BOARD}.bit
${PROG}
${PROJECT_NAME}.json: ${PROJECT_NAME}${CLK}.v
yosys -p "synth_xilinx -flatten -abc9 -nobram -arch xc7 -top ${PROJECT_NAME}; write_json ${PROJECT_NAME}.json" $<
${PROJECT_NAME}-${BOARD}.fasm: ${PROJECT_NAME}.json
${NEXTPNR_DIR}/bin/nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}-${BOARD}-routed.json --fasm $@ --verbose --debug
${PROJECT_NAME}-${BOARD}.frames: ${PROJECT_NAME}-${BOARD}.fasm
${XRAY_UTILS_DIR}/fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@
${PROJECT_NAME}-${BOARD}.bit: ${PROJECT_NAME}-${BOARD}.frames
${XRAY_TOOLS_DIR}/xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@
.PHONY: setup
setup:
ifeq (${PART},)
make check
endif
cp -rv db-workspace-for-kintex7/* nextpnr-xilinx/xilinx/external/prjxray-db/kintex7
${NEXTPNR_BUILD_ENV} cmake -S nextpnr-xilinx -B nextpnr-xilinx/build ${NEXTPNR_CMAKE_FLAGS} -DARCH=xilinx -DCMAKE_INSTALL_PREFIX=${NEXTPNR_DIR}
make -C nextpnr-xilinx/build -j${JOBS} all
make -C nextpnr-xilinx/build install
if [ ! -f nextpnr-xilinx/xilinx/${PART}.bba ] ; then \
cd nextpnr-xilinx ; \
python3 xilinx/python/bbaexport.py --device ${PART} --bba xilinx/${PART}.bba ; \
fi
if [ ! -f nextpnr-xilinx/xilinx/${PART}.bin ] ; then \
cd nextpnr-xilinx ; \
build/bbasm -l xilinx/${PART}.bba xilinx/${PART}.bin ; \
fi
if [ ! -f ${NEXTPNR_DIR}/xilinx-chipdb/${PART}.bin ] ; then \
mkdir -p ${NEXTPNR_DIR}/xilinx-chipdb ; \
cp nextpnr-xilinx/xilinx/${PART}.bin ${NEXTPNR_DIR}/xilinx-chipdb/ ; \
fi
if [ ! -e ${NEXTPNR_DIR}/prjxray-db ] ; then \
ln -s ${PWD}/nextpnr-xilinx/xilinx/external/prjxray-db ${NEXTPNR_DIR}/ ; \
fi
${PRJXRAY_BUILD_ENV} cmake -S prjxray -B prjxray/build ${PRJXRAY_CMAKE_FLAGS} -DCMAKE_INSTALL_PREFIX=${XRAY_DIR}
make -j${JOBS} -C prjxray/build
make -j${JOBS} -C prjxray/build install
make -j${JOBS} -C prjxray env
.PHONY: clean
clean:
@rm -f *.bit
@rm -f *.frames
@rm -f *.fasm
@rm -f *.json
.PHONY: clobber
clobber:
rm -rf nextpnr-xilinx/build
rm -rf prjxray/build
rm -rf prjxray/env