Skip to content

Commit 7b7293d

Browse files
authored
Merge pull request #133 from antmicro/add-nisp-data
Add building data for NISP
2 parents d5561d5 + 269257a commit 7b7293d

File tree

10 files changed

+70
-4
lines changed

10 files changed

+70
-4
lines changed

.github/scripts/centos-setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ make install
2828
popd
2929
ln -sf /usr/local/bin/make /usr/bin/make
3030

31+
# Copy java.capnp needed by NISP
32+
cp ./third_party/nextpnr-fpga-interchange-site-preprocessor/third_party/capnproto-java/compiler/src/main/schema/capnp/java.capnp /usr/include/capnp/java.capnp
33+
3134
# Check versions
3235
make --version
3336
cmake --version

.github/scripts/pack-interchange-data.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ LINK_PREFIX=$3
3737
INSTALL_DIR="$(pwd)/install"
3838

3939
# Prepare environment
40+
source "$HOME/.cargo/env"
4041
make env
4142
source env/conda/bin/activate fpga-interchange
4243

.github/scripts/ubuntu-setup.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
set -e
1111
apt-get -qqy update
1212
apt-get -qqy install build-essential git make locales libtinfo-dev \
13-
cmake python3 wget unzip curl openjdk-11-jdk-headless capnproto
13+
cmake python3 wget unzip curl openjdk-11-jdk-headless capnproto libcapnp-dev
1414
dpkg-reconfigure locales
1515

16+
# Copy java.capnp needed by NISP
17+
cp ./third_party/nextpnr-fpga-interchange-site-preprocessor/third_party/capnproto-java/compiler/src/main/schema/capnp/java.capnp /usr/include/capnp/java.capnp
18+
1619
# Vivado is erroring out due to a missing library in CI.
1720
# https://support.xilinx.com/s/article/76585?language=en_US
1821
ln -s /lib/x86_64-linux-gnu/libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.5

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ jobs:
8080
run: |
8181
.github/scripts/ubuntu-setup.sh
8282
83+
- name: Install Rust
84+
run: |
85+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
86+
8387
- name: Create environment
84-
run: make env
88+
run: |
89+
make env
8590
8691
- name: Build CMake
8792
run: |
93+
source "$HOME/.cargo/env"
8894
make build
8995
make update
9096

.github/workflows/upload.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
steps:
3737

3838
- uses: actions/checkout@v2
39+
with:
40+
submodules: recursive
3941

4042
- name: Install prerequisites
4143
run: |
@@ -47,6 +49,10 @@ jobs:
4749
apt update -qqy
4850
apt install -qqy gnupg2 google-cloud-cli
4951
52+
- name: Install Rust
53+
run: |
54+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
55+
5056
- name: Save timestamp
5157
id: timestamp
5258
run: |

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@
3434
[submodule "third_party/litex-boards"]
3535
path = third_party/litex-boards
3636
url = https://github.com/litex-hub/litex-boards.git
37+
[submodule "third_party/nextpnr-fpga-interchange-site-preprocessor"]
38+
path = third_party/nextpnr-fpga-interchange-site-preprocessor
39+
url = https://github.com/antmicro/nextpnr-fpga-interchange-site-preprocessor

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ set_program(vvp)
5353
set_program(xcfasm)
5454
set_program(yosys)
5555

56+
if(DEFINED ENV{"NISP"})
57+
set(NISP_PATH $ENV{"NISP"})
58+
else()
59+
get_filename_component(NISP_PATH "third_party/nextpnr-fpga-interchange-site-preprocessor/nisp" ABSOLUTE)
60+
endif()
61+
62+
set_target_properties(
63+
programs PROPERTIES NISP ${NISP_PATH}
64+
)
65+
5666
include(boards/boards.cmake)
5767
include(devices/chipdb.cmake)
5868

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ENVIRONMENT_FILE := conda_lock.yml
1212

1313
# Paths
1414
RAPIDWRIGHT_PATH ?= $(TOP_DIR)/third_party/RapidWright
15+
NISP_PATH = third_party/nextpnr-fpga-interchange-site-preprocessor
1516

1617
third_party/make-env/conda.mk:
1718
git submodule init
@@ -26,11 +27,23 @@ update:
2627
make compile && \
2728
popd
2829

30+
${NISP_PATH}/nisp:
31+
@$(IN_CONDA_ENV) cd ${NISP_PATH} && (FPGA_INTERCHANGE_SCHEMA_DIR=third_party/fpga-interchange-schema cargo build --release)
32+
@ln -s `realpath ${NISP_PATH}/target/release/nisp` ${NISP_PATH}/nisp
33+
34+
.PHONY: nisp
35+
nisp: ${NISP_PATH}/nisp
36+
37+
.PHONY: clean-nisp
38+
clean-nisp:
39+
@rm -rf ${NISP_PATH}/target
40+
-@unlink ${NISP_PATH}/nisp
41+
2942
.PHONY: build
30-
build:
43+
build: ${NISP_PATH}/nisp
3144
# Build test suite
3245
@$(IN_CONDA_ENV) mkdir -p build && cd build && cmake .. ${CMAKE_FLAGS}
3346

3447
.PHONY: clean-build
35-
clean-build:
48+
clean-build: clean-nisp
3649
rm -rf build/*

devices/chipdb.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ function(generate_chipdb)
248248

249249
get_target_property(PYTHON3 programs PYTHON3)
250250
get_target_property(BBASM programs BBASM)
251+
get_target_property(NISP programs NISP)
251252

252253
get_target_property(device_loc ${device_target} LOCATION)
253254
set(chipdb_bba ${CMAKE_CURRENT_BINARY_DIR}/chipdb.bba)
@@ -280,6 +281,22 @@ function(generate_chipdb)
280281

281282
add_custom_target(chipdb-${device}-bin DEPENDS ${chipdb_bin})
282283

284+
# TODO: Currently we invoke NISP to generate JSON data and we keep the
285+
# JSON file. Ultimately this data should be imported to the BBA file.
286+
set(nisp_json ${CMAKE_CURRENT_BINARY_DIR}/${device}_site_routability.json)
287+
add_custom_command(
288+
OUTPUT ${nisp_json}
289+
COMMAND
290+
${NISP} ${device_loc} ${chipdb_bba} preprocess --json :all --threads 1 --no-formula-opt -c
291+
DEPENDS
292+
chipdb-${device}-bba
293+
${device_target}
294+
${device_loc}
295+
${NISP}
296+
)
297+
298+
add_custom_target(chipdb-${device}-json DEPENDS ${nisp_json})
299+
283300
# Setting device target properties
284301
add_custom_target(device-${device})
285302
set_target_properties(
@@ -299,16 +316,19 @@ function(generate_chipdb)
299316

300317
install(FILES ${device_loc} DESTINATION devices/${device})
301318
install(FILES ${chipdb_bin} DESTINATION devices/${device})
319+
install(FILES ${nisp_json} DESTINATION devices/${device})
302320

303321
add_custom_target(
304322
install_${device}_device
305323
ALL
306324
DEPENDS
307325
${device_target}
308326
chipdb-${device}-bin
327+
chipdb-${device}-json
309328
)
310329

311330
add_dependencies(all-device-data chipdb-${device}-bin)
331+
add_dependencies(all-device-data chipdb-${device}-json)
312332

313333
endfunction()
314334

0 commit comments

Comments
 (0)