From e67d6b44551fcd5455804ce07c190f4a8b9ca79b Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Sun, 20 Feb 2022 22:23:44 +1030 Subject: [PATCH 01/13] Add prjxray repository as a submodule. --- .gitmodules | 3 +++ prjxray | 1 + 2 files changed, 4 insertions(+) create mode 160000 prjxray diff --git a/.gitmodules b/.gitmodules index b0a3e64..e07238f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "nextpnr-xilinx"] path = nextpnr-xilinx url = git@github.com:kintex-chatter/nextpnr-xilinx.git +[submodule "prjxray"] + path = prjxray + url = git@github.com:kintex-chatter/prjxray.git diff --git a/prjxray b/prjxray new file mode 160000 index 0000000..5349556 --- /dev/null +++ b/prjxray @@ -0,0 +1 @@ +Subproject commit 5349556bc2c230801d6df0cf11bccb9cfd171639 From a6dc61ba195db013fb3eaa7c113e1e63e7440696 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Sun, 20 Feb 2022 22:26:26 +1030 Subject: [PATCH 02/13] Add setup and clobber targets to automate the complex steps required to set up the build environment. Assumes that nextpnr-xilinx and prjxray are submodules. --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Makefile b/Makefile index 5e8da20..8de3a55 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,15 @@ PREFIX ?= ${HOME}/opt DB_DIR = ${PREFIX}/nextpnr/prjxray-db CHIPDB_DIR = ${PREFIX}/nextpnr/xilinx-chipdb XRAY_DIR ?= ${PREFIX}/prjxray +NEXTPNR_DIR ?= ${PREFIX}/nextpnr SHELL = /bin/bash PYTHONPATH ?= ${XRAY_DIR} +ifeq ($(shell uname -s),Darwin) +NEXTPNR_BUILD_ENV = env CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" +NEXTPNR_CMAKE_FLAGS = -DBUILD_GUI=0 +endif + ifeq (${BOARD}, qmtech) PART = xc7k325tffg676-1 else ifeq (${BOARD}, genesys2) @@ -38,9 +44,40 @@ ${PROJECT_NAME}.bit: ${PROJECT_NAME}.frames @. "${XRAY_DIR}/utils/environment.sh" xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@ +.PHONY: setup +setup: + ${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 -j2 all + make -C nextpnr-xilinx/build install + if [ ! -f nextpnr-xilinx/xilinx/xc7k325tffg676-1.bba ] ; then \ + cd nextpnr-xilinx ; \ + python3 xilinx/python/bbaexport.py --device xc7k325tffg676-1 --bba xilinx/xc7k325tffg676-1.bba ; \ + fi + if [ ! -f nextpnr-xilinx/xilinx/xc7k325tffg676-1.bin ] ; then \ + cd nextpnr-xilinx ; \ + build/bbasm -l xilinx/xc7k325tffg676-1.bba xilinx/xc7k325tffg676-1.bin ; \ + fi + if [ ! -f ${NEXTPNR_DIR}/xilinx-chipdb/xc7k325tffg676-1.bin ] ; then \ + mkdir -p ${NEXTPNR_DIR}/xilinx-chipdb ; \ + cp nextpnr-xilinx/xilinx/xc7k325tffg676-1.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 + cmake -S prjxray -B prjxray/build -DCMAKE_INSTALL_PREFIX=${XRAY_DIR} + make -C prjxray/build + make -C prjxray/build install + make -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 From c3a106e605908e62472607ab1c7007f6e15241b5 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Sun, 20 Feb 2022 22:27:10 +1030 Subject: [PATCH 03/13] Run nextpnr-xilinx directly from the install location, so that altering the PATH is not required. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8de3a55..c9ed49e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ ${PROJECT_NAME}.json: ${PROJECT_NAME}.v yosys -p "synth_xilinx -flatten -abc9 -nobram -arch xc7 -top ${PROJECT_NAME}; write_json ${PROJECT_NAME}.json" $< ${PROJECT_NAME}.fasm: ${PROJECT_NAME}.json - nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}_routed.json --fasm $@ --verbose --debug + ${NEXTPNR_DIR}/bin/nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}_routed.json --fasm $@ --verbose --debug ${PROJECT_NAME}.frames: ${PROJECT_NAME}.fasm @. "${XRAY_DIR}/utils/environment.sh" From f0de2b84fe1d1b0f4e28d943b0579712e6bd9a45 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Sun, 20 Feb 2022 22:28:07 +1030 Subject: [PATCH 04/13] Run fasm2frames from the local python environment and xc7frames2bit directly from the install location. --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c9ed49e..112a85f 100644 --- a/Makefile +++ b/Makefile @@ -37,12 +37,10 @@ ${PROJECT_NAME}.fasm: ${PROJECT_NAME}.json ${NEXTPNR_DIR}/bin/nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}_routed.json --fasm $@ --verbose --debug ${PROJECT_NAME}.frames: ${PROJECT_NAME}.fasm - @. "${XRAY_DIR}/utils/environment.sh" - fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@ + prjxray/env/bin/fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@ ${PROJECT_NAME}.bit: ${PROJECT_NAME}.frames - @. "${XRAY_DIR}/utils/environment.sh" - xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@ + ${XRAY_DIR}/bin/xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@ .PHONY: setup setup: From a7e80ff219abdd9ad59bc1067034548d366a25c0 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Sun, 20 Feb 2022 22:37:21 +1030 Subject: [PATCH 05/13] Update the README to reflect the simplified setup. --- README.md | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ac235c1..18cc346 100644 --- a/README.md +++ b/README.md @@ -21,20 +21,9 @@ 1. clone/build/install yosys from https://github.com/YosysHQ/yosys or download a release from https://github.com/YosysHQ/oss-cad-suite-build/releases note: test have been performed with Yosys 0.13+28 (git sha1 bf85dfee5, gcc 10.2.1-6 -fPIC -Os) 2. git clone --recurse-submodules https://github.com/kintex-chatter/xc7k325t-blinky-nextpnr.git -3. cd xc7k325t-blinky-nextpnr/nextpnr-xilinx -4. mkdir build -5. pushd build -6. cmake -DARCH=xilinx -DCMAKE_INSTALL_PREFIX=~/opt/nextpnr .. -7. make -j2 && make install -8. popd -9. python3 xilinx/python/bbaexport.py --device xc7k325tffg676-1 --bba xilinx/xc7k325tffg676-1.bba -10. build/bbasm -l xilinx/xc7k325tffg676-1.bba xilinx/xc7k325tffg676-1.bin -11. mkdir -p ~/opt/nextpnr/xilinx-chipdb -12. ln -s $PWD/xilinx/external/prjxray-db ~/opt/nextpnr/ -13. cp xilinx/xc7k325tffg676-1.bin ~/opt/nextpnr/xilinx-chipdb/ -14. Set XRAY_DIR to the path where Project Xray has been cloned and built, see https://symbiflow.readthedocs.io/en/latest/prjxray/docs/db_dev_process/readme.html#quickstart-guide for details. You will need to follow steps 2-5. You may be able to skip installation of Vivado if you do not plan to run the fuzzers. -15. Change directory to this project -16. BOARD=qmtech make +3. cd xc7k325t-blinky-nextpnr +4. make BOARD=qmtech setup +5. make BOARD=qmtech all Note: Every time you change the installation of nextpnr-xilinx you will have to regenerate the chipdb, because the chipdb does not seem to be compatible between different binaries of nextpnr-xilinx From 6ac6fab533e27a3ff4f247dcbad4a5254448c5be Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:13:41 +1030 Subject: [PATCH 06/13] Use PART to distinguish the target part. --- Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 112a85f..b75b167 100644 --- a/Makefile +++ b/Makefile @@ -44,20 +44,23 @@ ${PROJECT_NAME}.bit: ${PROJECT_NAME}.frames .PHONY: setup setup: +ifeq (${PART},) + make check +endif ${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 -j2 all make -C nextpnr-xilinx/build install - if [ ! -f nextpnr-xilinx/xilinx/xc7k325tffg676-1.bba ] ; then \ + if [ ! -f nextpnr-xilinx/xilinx/${PART}.bba ] ; then \ cd nextpnr-xilinx ; \ - python3 xilinx/python/bbaexport.py --device xc7k325tffg676-1 --bba xilinx/xc7k325tffg676-1.bba ; \ + python3 xilinx/python/bbaexport.py --device ${PART} --bba xilinx/${PART}.bba ; \ fi - if [ ! -f nextpnr-xilinx/xilinx/xc7k325tffg676-1.bin ] ; then \ + if [ ! -f nextpnr-xilinx/xilinx/${PART}.bin ] ; then \ cd nextpnr-xilinx ; \ - build/bbasm -l xilinx/xc7k325tffg676-1.bba xilinx/xc7k325tffg676-1.bin ; \ + build/bbasm -l xilinx/${PART}.bba xilinx/${PART}.bin ; \ fi - if [ ! -f ${NEXTPNR_DIR}/xilinx-chipdb/xc7k325tffg676-1.bin ] ; then \ + if [ ! -f ${NEXTPNR_DIR}/xilinx-chipdb/${PART}.bin ] ; then \ mkdir -p ${NEXTPNR_DIR}/xilinx-chipdb ; \ - cp nextpnr-xilinx/xilinx/xc7k325tffg676-1.bin ${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}/ ; \ From 5e346aaa9936fc353420ab4f5cdd2b0f2213849e Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:16:50 +1030 Subject: [PATCH 07/13] Identify the reason for this platform-specific work-around. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index b75b167..93f7946 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ NEXTPNR_DIR ?= ${PREFIX}/nextpnr SHELL = /bin/bash PYTHONPATH ?= ${XRAY_DIR} +# This workaround is only required for macOS, because Apple has explicitly disabled OpenMP support in their compilers. ifeq ($(shell uname -s),Darwin) NEXTPNR_BUILD_ENV = env CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" NEXTPNR_CMAKE_FLAGS = -DBUILD_GUI=0 From ca0ae4c77fada951d2202381e2808fc5aa570b04 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:18:32 +1030 Subject: [PATCH 08/13] Define XRAY_UTILS_DIR and XRAY_TOOLS_DIR to point to the two different locations used to run fasm2frames and xc7frames2bit. --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 93f7946..9586181 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ 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} @@ -38,10 +40,10 @@ ${PROJECT_NAME}.fasm: ${PROJECT_NAME}.json ${NEXTPNR_DIR}/bin/nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}_routed.json --fasm $@ --verbose --debug ${PROJECT_NAME}.frames: ${PROJECT_NAME}.fasm - prjxray/env/bin/fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@ + ${XRAY_UTILS_DIR}/fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@ ${PROJECT_NAME}.bit: ${PROJECT_NAME}.frames - ${XRAY_DIR}/bin/xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@ + ${XRAY_TOOLS_DIR}/xc7frames2bit --part_file ${DB_DIR}/kintex7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@ .PHONY: setup setup: From 7c6008166bdffbcfc59928678f1e0c9d6b22bcce Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:18:52 +1030 Subject: [PATCH 09/13] Use PROJECT_NAME instead of blinky. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9586181..33bcfc6 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ ifeq (${BOARD}, qmtech) PART = xc7k325tffg676-1 else ifeq (${BOARD}, genesys2) PART = xc7k325tffg900-2 -PROG = openFPGALoader --cable digilent --bitstream blinky.bit --ftdi-channel 1 +PROG = openFPGALoader --cable digilent --bitstream ${PROJECT_NAME}.bit --ftdi-channel 1 else .PHONY: check check: From 991708daa720ba5a20768efd3db5c14dc7d0aa1c Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:21:33 +1030 Subject: [PATCH 10/13] Add PROG definition for the QMTech board, using Tigard as the default (but easily overridable) cable. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 33bcfc6..3cd96e9 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ XRAY_TOOLS_DIR = ${XRAY_DIR}/bin NEXTPNR_DIR ?= ${PREFIX}/nextpnr SHELL = /bin/bash PYTHONPATH ?= ${XRAY_DIR} +QMTECH_CABLE ?= tigard # This workaround is only required for macOS, because Apple has explicitly disabled OpenMP support in their compilers. ifeq ($(shell uname -s),Darwin) @@ -17,6 +18,7 @@ endif ifeq (${BOARD}, qmtech) PART = xc7k325tffg676-1 +PROG = openFPGALoader --cable ${QMTECH_CABLE} --board qmtechKintex7 --bitstream ${PROJECT_NAME}.bit else ifeq (${BOARD}, genesys2) PART = xc7k325tffg900-2 PROG = openFPGALoader --cable digilent --bitstream ${PROJECT_NAME}.bit --ftdi-channel 1 From 6f0a42d7c3c7bace51adb731981122ac18047437 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:25:37 +1030 Subject: [PATCH 11/13] Genesys2 board has a board definition in OpenFPGALoader, which defaults to the correct digilent cable configuration automatically. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3cd96e9..ad728a8 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ PART = xc7k325tffg676-1 PROG = openFPGALoader --cable ${QMTECH_CABLE} --board qmtechKintex7 --bitstream ${PROJECT_NAME}.bit else ifeq (${BOARD}, genesys2) PART = xc7k325tffg900-2 -PROG = openFPGALoader --cable digilent --bitstream ${PROJECT_NAME}.bit --ftdi-channel 1 +PROG = openFPGALoader --board genesys2 --bitstream ${PROJECT_NAME}.bit else .PHONY: check check: From b0715ae8ed7047301e9c266309ec38f5ba151d31 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Thu, 24 Feb 2022 18:57:21 +1030 Subject: [PATCH 12/13] Make the generated files specific to the BOARD, so that multiple BOARDs can be supported in a single project directory. --- .gitignore | 9 ++++----- Makefile | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 9b99a35..43dbebb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -blinky.bit -blinky.fasm -blinky.frames -blinky.json -blinky_routed.json +*.bit +*.fasm +*.frames +*.json diff --git a/Makefile b/Makefile index ad728a8..439de49 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ endif ifeq (${BOARD}, qmtech) PART = xc7k325tffg676-1 -PROG = openFPGALoader --cable ${QMTECH_CABLE} --board qmtechKintex7 --bitstream ${PROJECT_NAME}.bit +PROG = openFPGALoader --cable ${QMTECH_CABLE} --board qmtechKintex7 --bitstream ${PROJECT_NAME}-${BOARD}.bit else ifeq (${BOARD}, genesys2) PART = xc7k325tffg900-2 -PROG = openFPGALoader --board genesys2 --bitstream ${PROJECT_NAME}.bit +PROG = openFPGALoader --board genesys2 --bitstream ${PROJECT_NAME}-${BOARD}.bit else .PHONY: check check: @@ -32,19 +32,19 @@ check: endif .PHONY: all -all: ${PROJECT_NAME}.bit +all: ${PROJECT_NAME}-${BOARD}.bit ${PROG} ${PROJECT_NAME}.json: ${PROJECT_NAME}.v yosys -p "synth_xilinx -flatten -abc9 -nobram -arch xc7 -top ${PROJECT_NAME}; write_json ${PROJECT_NAME}.json" $< -${PROJECT_NAME}.fasm: ${PROJECT_NAME}.json - ${NEXTPNR_DIR}/bin/nextpnr-xilinx --chipdb ${CHIPDB_DIR}/${PART}.bin --xdc ${PROJECT_NAME}-${BOARD}.xdc --json $< --write ${PROJECT_NAME}_routed.json --fasm $@ --verbose --debug +${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}.frames: ${PROJECT_NAME}.fasm +${PROJECT_NAME}-${BOARD}.frames: ${PROJECT_NAME}-${BOARD}.fasm ${XRAY_UTILS_DIR}/fasm2frames --part ${PART} --db-root ${DB_DIR}/kintex7 $< > $@ -${PROJECT_NAME}.bit: ${PROJECT_NAME}.frames +${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 From 55b923f35823695c95e64ce4cd1a763c553ce404 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Fri, 25 Feb 2022 09:02:33 +1030 Subject: [PATCH 13/13] Allow the project name to be easily overridden. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 439de49..5dfd14b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PROJECT_NAME = blinky +PROJECT_NAME ?= blinky PREFIX ?= ${HOME}/opt DB_DIR = ${PREFIX}/nextpnr/prjxray-db CHIPDB_DIR = ${PREFIX}/nextpnr/xilinx-chipdb