12cd38938773a799e86fb60c2f0f042d157aaf02
[libreriscv.git] / HDL_workflow / symbiflow.mdwn
1 # Installation instructions for Symbiflow with Xilinx Artix7 100T Board
2
3 * <https://symbiflow.github.io/>
4 * <https://github.com/SymbiFlow>
5
6 ## Bugzilla page
7
8 * <https://bugs.libre-soc.org/show_bug.cgi?id=654>
9
10 ## Setting up new debootstrap and chroot into it
11
12 Run the following if you wish to isolate the symbiflow build
13 from other software (reproducible builds) or use the schroot
14 auto-preparation script here:
15 <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=mk-deb-chroot;hb=HEAD>
16
17 export MY_CHROOT=/stable-chroot
18 mkdir $MY_CHROOT
19 debootstrap buster $MY_CHROOT http://deb.debian.org/debian/
20 mount -t proc proc $MY_CHROOT/proc
21 mount -t sysfs sysfs $MY_CHROOT/sys
22 mount -t devpts devpts $MY_CHROOT/dev/pts/
23 chroot $MY_CHROOT /bin/bash
24
25 ## Add Buster Backports Repo and Update
26
27 ""buster backports is needed for cmake""
28
29 cat << EOF > /etc/apt/sources.list.d/buster_backports.list
30 deb http://deb.debian.org/debian buster-backports main
31 EOF
32
33 ""oooo annoying, pin preferences for buster-backports""
34
35 cat << EOF > /etc/apt/preferences.d/99buster-backports
36 Package: *
37 Pin: release a=buster-backports
38 Pin-Priority: 900
39 EOF
40
41 ""upgrade to buster-backports""
42
43 apt-get update -y
44 apt-get upgrade -y
45
46
47 ## Download neccessary softwares
48
49 apt-get install -y libcurl3-gnutls/buster git/buster wget
50
51 git clone https://github.com/steveicarus/iverilog.git
52 git clone https://github.com/YosysHQ/yosys.git
53 git clone https://github.com/YosysHQ/abc.git
54 git clone https://github.com/oneapi-src/oneTBB.git
55 git clone https://github.com/verilog-to-routing/vtr-verilog-to-routing.git
56 git clone https://github.com/cliffordwolf/icestorm.git
57 git clone https://github.com/SymbiFlow/prjxray.git
58 git clone https://github.com/SymbiFlow/prjxray-db.git
59 git clone https://github.com/SymbiFlow/yosys-symbiflow-plugins.git
60 git clone https://github.com/SymbiFlow/symbiflow-examples.git
61 git clone https://github.com/SymbiFlow/symbiflow-arch-defs.git
62 git clone https://github.com/QuickLogic-Corp/quicklogic-fasm.git
63 git clone https://github.com/QuickLogic-Corp/quicklogic-fasm-utils.git
64 git clone https://github.com/SymbiFlow/python-fpga-interchange.git
65 git clone https://github.com/capnproto/capnproto.git
66 git clone https://github.com/capnproto/pycapnp.git
67
68 wget http://xmlsoft.org/sources/libxml2-2.9.12.tar.gz
69 wget http://xmlsoft.org/sources/libxslt-1.1.34.tar.gz
70
71 ## Steps to compile Icarus Verilog
72
73 ### Necessary software to install
74
75 apt-get install -y build-essential autoconf make g++ bison flex gperf \
76 libreadline6-dev
77
78 ### Build Icarus Verilog
79
80 cd iverilog
81 git checkout v11_0
82 sh autoconf.sh
83 ./configure --prefix=/usr/local/symbiflow/iverilog
84 make -j$(nproc)
85 make check
86 make install
87 export PATH=/usr/local/symbiflow/iverilog/bin:$PATH
88 cd ..
89
90 ## Steps to compile Yosys
91
92 ### Necessary software to install
93
94 apt-get install -y cmake
95 apt-get install -y python3 clang libreadline-dev gawk tcl-dev \
96 libffi-dev pkg-config libboost-system-dev libboost-python-dev \
97 libboost-filesystem-dev zlib1g-dev
98
99 ### Build Yosys
100
101 cd abc
102 git checkout 4f5f73d18b137930fb3048c0b385c82fa078db38
103 cd ../yosys
104 git checkout f44110c62561b21fa673f44d8e115c3ee70d2900
105 ln -s ../abc .
106 make -j $(nproc) PREFIX=/usr/local/symbiflow/yosys
107 make PREFIX=/usr/local/symbiflow/yosys install
108 install -d -m 0755 /usr/local/symbiflow/share
109 ln -s ../yosys/share/yosys /usr/local/symbiflow/share
110 export PATH=/usr/local/symbiflow/yosys/bin:$PATH
111 cd ..
112
113 ## Steps to compile oneTBB
114
115 * Note: TBB is needed for multi-threading VTR-Verilog-to-routing
116 * If not need multi-threading do not build TBB and VTR with TBB
117
118 ### Necessary software to install
119
120 apt-get install -y libhwloc-dev
121
122 ### Build TBB
123
124 cd oneTBB
125 git checkout v2020.3
126 make -j$(nproc) tbb tbbmalloc tbbproxy tbbbind
127 install -d -m 0755 /usr/local/symbiflow/oneTBB/lib
128 cp -dpr include /usr/local/symbiflow/oneTBB
129 install -Dm755 build/linux_*/*.so* -t /usr/local/symbiflow/oneTBB/lib
130 cmake -DINSTALL_DIR=/usr/local/symbiflow/oneTBB/lib/cmake/TBB \
131 -DTBB_VERSION_FILE=/usr/local/symbiflow/oneTBB/include/tbb/tbb_stddef.h \
132 -DSYSTEM_NAME=Linux -P cmake/tbb_config_installer.cmake
133 echo "/usr/local/symbiflow/oneTBB/lib" > /etc/ld.so.conf.d/symbiflow.conf
134 ldconfig
135 cd ..
136
137 ## Steps to compile vtr-verilog-to-routing
138
139 ### Necessary software to install
140
141 apt-get install -y libeigen3-dev
142
143 # Only if want GUI place and route
144 #apt-get install libcairo2-dev libfontconfig1-dev libx11-dev libxft-dev \
145 #libgtk-3-dev
146
147 ### Build vtr
148
149 cd vtr-verilog-to-routing
150 git checkout 77a3df829fdf509a76b9d7b941376f3835c2576a
151 mkdir build; cd build
152 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/symbiflow/vtr ..
153 make -j $(nproc)
154 make install
155 install -d -m 0755 /usr/local/symbiflow/share/vtr
156 install -m 0644 ../libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp \
157 /usr/local/symbiflow/share/vtr
158 export PATH=/usr/local/symbiflow/vtr/bin:$PATH
159 cd ../..
160
161 ### Build vtr-tbb
162
163 cd vtr-verilog-to-routing
164 git checkout 77a3df829fdf509a76b9d7b941376f3835c2576a
165 mkdir build-tbb; cd build-tbb
166 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/symbiflow/vtr-tbb \
167 -DTBB_INCLUDE_DIR=/usr/local/symbiflow/oneTBB/include \
168 -DTBB_LIBRARY=/usr/local/symbiflow/oneTBB/lib -DBUILD_TYPE=Release ..
169 LIBRARY_PATH=/usr/local/symbiflow/oneTBB/lib make -j $(nproc)
170 LIBRARY_PATH=/usr/local/symbiflow/oneTBB/lib make install
171 install -d -m 0755 /usr/local/symbiflow/share/vtr
172 install -m 0644 ../libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp \
173 /usr/local/symbiflow/share/vtr
174 # Choose either one of path for vtr-binaries
175 # This one or above one
176 #export PATH=/usr/local/symbiflow/vtr-tbb/bin:$PATH
177 cd ../..
178
179 ## Steps to compile libxml2
180
181 * Newer version is needed which fixes a integer overflow error and is not
182 provided by Buster.
183
184 ### Necessary software to install
185
186 apt-get install -y python3-dev
187
188 ### Build libxml2
189
190 tar -xf libxml2-2.9.12.tar.gz
191 cd libxml2-2.9.12
192 ./configure --prefix=/usr/local/symbiflow/libxml2 --with-history \
193 --with-python=/usr/bin/python3
194 make -j $(nproc)
195 make install
196 echo "/usr/local/symbiflow/libxml2/lib" >> /etc/ld.so.conf.d/symbiflow.conf
197 ldconfig
198 export PATH=/usr/local/symbiflow/libxml2/bin:$PATH
199 cd ..
200
201 ## Steps to compile libxslt
202
203 * Needed by python3 lxml
204
205 ### Build libxslt
206
207 tar -xf libxslt-1.1.34.tar.gz
208 cd libxslt-1.1.34
209 sed -i s/3000/5000/ libxslt/transform.c doc/xsltproc.{1,xml}
210 sed -i -r '/max(Parser)?Depth/d' ./tests/fuzz/fuzz.c
211 ./configure --prefix=/usr/local/symbiflow/libxslt --disable-static \
212 --without-python \
213 PKG_CONFIG_PATH=/usr/local/symbiflow/libxml2/lib/pkgconfig
214 make -j $(nproc)
215 make install
216 echo "/usr/local/symbiflow/libxslt/lib" >> /etc/ld.so.conf.d/symbiflow.conf
217 ldconfig
218 export PATH=/usr/local/symbiflow/libxslt/bin:$PATH
219 cd ..
220
221 ## Steps to compile prjxray
222
223 ### Necessary software to install
224
225 ### Build prjxray
226
227 cd prjxray
228 git checkout f7f06896ad26bb7c94680dc323d4b871eded1f4e
229 git submodule update --init --recursive
230 mkdir build; cd build
231 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/symbiflow ..
232 make -j$(nproc)
233 make install
234 export PATH=/usr/local/symbiflow/bin:$PATH
235 cd ../..
236
237 ## Steps to compile yosys-symbiflow-plugins
238
239 ### Necessary software to install
240
241 ### Build yosys-symbiflow-plugins
242
243 cd yosys-symbiflow-plugins
244 git checkout b170f1d3575568d87901422f846b700169e299be
245 sed -i -e 's@-include third_party/make-env/conda.mk@#-include third_party/make-env/conda.mk@' Makefile
246 make -j$(nproc)
247 make install
248 cd ..
249
250 ## Steps to compile prjxray-db
251
252 ### Install prjxray-db
253
254 cd prjxray-db
255 git archive --format=tar --prefix=prjxray-db/ \
256 cd41f08a8a4d2a60053750a0fe10623b1e2e35da | \
257 tar -C /usr/local/symbiflow -xf -
258
259 cat > /usr/local/symbiflow/bin/prjxray-config << EOF
260 #!/bin/bash
261 echo /usr/local/symbiflow/prjxray-db
262 EOF
263
264 chmod +x /usr/local/symbiflow/bin/prjxray-config
265 cd ..
266
267 ## Steps to compile Icestorm
268
269 ### Necessary software to install
270
271 apt-get install -y libftdi-dev
272
273 ### Build Icestorm
274
275 cd icestorm
276 git checkout 83b8ef947f77723f602b706eac16281e37de278c
277 make -j $(nproc) PREFIX=/usr/local/symbiflow/icestorm
278 make PREFIX=/usr/local/symbiflow/icestorm install
279 export PATH=/usr/local/symbiflow/icestorm/bin:$PATH
280 cd ..
281
282 ## Steps to compile capnproto
283
284 ### Necessary software to install
285
286 apt-get install -y automake autoconf libtool
287
288 ### Build capnproto
289
290 cd capnproto
291 git checkout v0.8.0
292 cd c++
293 autoreconf -i
294 ./configure --prefix=/usr/local/symbiflow/capnproto
295 make -j $(nproc)
296 make install
297 echo "/usr/local/symbiflow/capnproto/lib" >> /etc/ld.so.conf.d/symbiflow.conf
298 ldconfig
299 export PATH=/usr/local/symbiflow/capnproto/bin:$PATH
300 cd ../..
301
302 ## Steps to compile pycapnp
303
304 ### Necessary software to install
305
306 apt-get install -y python3-pip cython3
307
308 ### Build pycapnp
309
310 cd pycapnp
311 git checkout v1.0.0b1
312 pip3 install .
313 cd ..
314
315 ## Git checkout python-fpga-interchange
316
317 cd python-fpga-interchange
318 git checkout 1959b40e998db987c604c0a75664ccb209df13f7
319 cd ..
320
321 ## Git checkout quicklogic-fasm-utils
322
323 cd quicklogic-fasm-utils
324 git checkout 3d6a375ddb6b55aaa5a59d99e44a207d4c18709f
325 cd ..
326
327 ## Git checkout quicklogic-fasm
328
329 cd quicklogic-fasm
330 git checkout ee546ff09b2ee25894db3f419366afaf3c4bfe32
331 cd ..
332
333 ## Steps to compile symbiflow-arch-defs
334
335 ## Necessary software to install
336
337 apt-get install -y nodejs npm python-pytest openocd flake8 python3-numpy \
338 python3-intervaltree python3-simplejson python3-intelhex \
339 python3-importlib-metadata python3-jsonschema python3-packaging \
340 python3-pyparsing python3-pyrsistent python3-tqdm python3-zipp \
341 python3-typing-extensions python3-ply
342
343 pip3 install textx fasm pyjson5 pyyaml tinyfpgab tinyprog pyjson lxml \
344 progressbar2 hilbertcurve==1.0.5 python-constraint parameterized \
345 yapf==0.26.0 python-sat
346
347 ### Build symbiflow
348
349 cd symbiflow-arch-defs
350 git checkout c2c0f00960baf538eb31e4c42bf5d09dca87bad7
351 git submodule init
352 git submodule update --init --recursive
353 pip3 install ../python-fpga-interchange
354 pip3 install -e third_party/prjxray
355 pip3 install -e third_party/xc-fasm
356 pip3 install ../quicklogic-fasm-utils
357 pip3 install ../quicklogic-fasm
358 pip3 install -e third_party/qlf-fasm
359 pip3 install -e quicklogic/common/utils/quicklogic-timings-importer
360 pip3 install -e third_party/vtr-xml-utils
361 pip3 install -e third_party/python-symbiflow-v2x
362 pip3 install -e third_party/python-sdf-timing
363 pip3 install -e third_party/symbiflow-xc-fasm2bels
364
365 mkdir -p env/conda/envs
366 ln -s /usr/local/symbiflow env/conda/envs/symbiflow_arch_def_base
367
368 sed -i -e 's@add_subdirectory(litex)@#add_subdirectory(litex)@g' \
369 -e 's@add_subdirectory(ibex)@#add_subdirectory(ibex)@g' \
370 xc/xc7/tests/soc/CMakeLists.txt
371
372 ### Build symbiflow-arch-defs-xc7-artix7-100t
373
374 export VPR_NUM_WORKERS=$(nproc)
375
376 mkdir build; cd build
377 cmake -DUSE_CONDA=FALSE -DPRJXRAY_DB_DIR=/usr/local/symbiflow/prjxray-db \
378 -DINSTALL_FAMILIES=xc7 -DINSTALL_ARCHS=artix7_100t \
379 -DINSTALL_DEVICES=xc7a100t -DCMAKE_INSTALL_PREFIX=/usr/local/symbiflow ..
380 cd xc/xc7/archs/artix7_100t
381 make install
382 cd ../..
383 make PINMAP_INSTALL_arty100t-full_xc7a100t_test_arty100t-full_pinmap.csv
384 install -d -m 0755 /usr/local/symbiflow/share/symbiflow/arch/xc7a100t_test/xc7a100tcsg324-1
385 install -m 0644 arty100t-full_pinmap.csv /usr/local/symbiflow/share/symbiflow/arch/xc7a100t_test/xc7a100tcsg324-1/pinmap.csv
386
387 # Now you can skip to symbiflow-examples.git for external test
388
389 # To do builtin counter test; it should build top.bit as final bitstream
390 cd tests/counter
391 make counter_arty100t_bit
392
393 # see file counter_arty100t/artix7_100t-xc7a100t-virt-xc7a100t-test/top.bit
394 # it is the bitstream file and if built then success
395
396 cd ../../../../..
397
398 ### Build symbiflow-arch-defs-xc7-artix7 (xc7a50t)
399
400 "If you do not want this target skip"
401
402 export VPR_NUM_WORKERS=$(nproc)
403
404 mkdir build_artix7; cd build_artix7
405 cmake -DUSE_CONDA=FALSE -DPRJXRAY_DB_DIR=/usr/local/symbiflow/prjxray-db \
406 -DINSTALL_FAMILIES=xc7 -DINSTALL_ARCHS=artix7_100t \
407 -DINSTALL_DEVICES=xc7a50t \
408 -DCMAKE_INSTALL_PREFIX=/usr/local/symbiflow ..
409 cd xc/xc7/archs/artix7
410 make install
411 cd ../..
412 make PINMAP_INSTALL_arty-full_xc7a50t_test_arty-full_pinmap.csv
413 install -d -m 0755 /usr/local/symbiflow/share/symbiflow/arch/xc7a50t_test/xc7a50tfgg484-1
414 install -m 0644 arty-full_pinmap.csv /usr/local/symbiflow/share/symbiflow/arch/xc7a50t_test/xc7a50tfgg484-1/pinmap.csv
415 install -d -m 0755 /usr/local/symbiflow/share/symbiflow/arch/xc7a50t_test/xc7a35tcsg324-1
416 ln -s ../xc7a50tfgg484-1/pinmap.csv /usr/local/symbiflow/share/symbiflow/arch/xc7a50t_test/xc7a35tcsg324-1
417
418 # Now you can skip to symbiflow-examples.git for external test
419
420 # To do builtin counter test; it should build top.bit as final bitstream
421 cd tests/counter
422 make counter_arty100t_bit
423
424 # see file counter_arty/artix7-xc7a50t-arty-swbut-roi-virt-xc7a50t-arty-swbut-test/top.bit
425 # it is the bitstream file and if built then success
426
427 cd ../../../../../..
428
429 ## Steps to compile symbiflow-examples
430
431 ### Build counter test for arty_100
432
433 cd symbiflow-examples
434 git checkout 07a6353627e0b6083728d1022ce30f9093d4c2de
435
436 cd xc7
437 TARGET="arty_100" make -C counter_test
438
439 # Should produce top.bit bitstream
440 # see file counter_test/build/arty_100/top.bit
441
442 ### Build counter test for arty_35
443
444 TARGET="arty_35" make -C counter_test
445
446 # Should produce top.bit bitstream
447 # see file counter_test/build/arty_/top.bit
448
449 ### Build picosoc demo for arty_100
450
451 TARGET="arty_100" make -C picosoc_demo
452
453 # Should produce top.bit bitstream
454 # see file picosoc_demo/build/arty_100/top.bit
455
456 ### Build picosoc demo for arty_35
457
458 TARGET="arty_35" make -C picosoc_demo
459
460 # Should produce top.bit bitstream
461 # see file picosoc_demo/build/arty_35/top.bit
462
463 ### Build Linux Litex Demo for arty_100
464
465 TARGET="arty_100" make -C linux_litex_demo
466
467 # Should produce top.bit bitstream
468 # see file linux_litex_demo/build/arty_100/top.bit
469
470 ### Build Linux Litex Demo for arty_35
471
472 TARGET="arty_35" make -C linux_litex_demo
473
474 # Should produce top.bit bitstream
475 # see file linux_litex_demo/build/arty_35/top.bit
476
477 cd ../..
478
479 ## Steps to compile symbiflow-examples Litex
480
481 ### Get Litex
482
483 mkdir litex
484 cd litex
485
486 git clone https://github.com/m-labs/migen
487 git clone https://github.com/litex-hub/pythondata-software-compiler_rt
488 git clone https://github.com/enjoy-digital/litex
489 git clone https://github.com/enjoy-digital/litedram
490 git clone https://github.com/enjoy-digital/liteeth
491 git clone https://github.com/enjoy-digital/liteiclink
492 git clone https://github.com/enjoy-digital/litesdcard
493 git clone https://github.com/litex-hub/litespi
494 git clone https://github.com/litex-hub/litex-boards
495 git clone https://github.com/litex-hub/pythondata-cpu-picorv32
496 git clone https://github.com/litex-hub/pythondata-cpu-vexriscv
497 git clone https://github.com/litex-hub/pythondata-software-picolibc.git
498
499 ### Build Litex
500
501 "Git Commits"
502
503 migen=6e3f8e565704b4293174aedfb15b3470d233f528
504 pythondata-software-compiler_rt=fcb03245613ccf3079cc833a701f13d0beaae09d
505 litex=db20cb172dc982c5879aa8080ec7aa18de181cc5
506 litedram=1d5192f572c2eb97bc85eb56667e25dc88d725f1
507 liteeth=8ecc3ca6d9476dd1a8b32b2b6bf3584cd6dcfc02
508 liteiclink=3d8ecdbcf9f0260292221ff63b0ad3f5e409a955
509 litesdcard=4edf05e627a8b5f03e632215accec8ab588737e3
510 litespi=4cb907881bb75999e4c6bb68e211dd5cfc301de9
511 litex-boards=9e18d9bc34bafb18839512a55dc66ba62e0d4824
512 pythondata-cpu-picorv32=2e8be513726fb6ffd960f7e18d24e3a86d895107
513 pythondata-cpu-vexriscv=c4eca1837ebca20b637a0a61e3a93d9446488459
514 pythondata-software-picolibc=e27c8a7ef8a8e75b6474823aae338efb1a2ca1a9
515
516 for pkg in migen pythondata-software-compiler_rt litex litedram \
517 liteeth liteiclink litesdcard litespi litex-boards \
518 pythondata-cpu-picorv32 pythondata-cpu-vexriscv \
519 pythondata-software-picolibc; do
520 cd "$pkg"
521 eval git checkout $`echo $pkg`
522 pip3 install -e .
523 cd ..
524 done
525
526 #### Build Litex Demo
527
528 cd litex-boards
529
530 # Arty 100T Picorv32
531 ./litex_boards/targets/digilent_arty.py --toolchain=symbiflow \
532 --cpu-type=picorv32 --sys-clk-freq 80e6 --variant a7-100 \
533 --output-dir build/picorv32/arty_100 --build --no-compile-software
534 # see file build/picorv32/arty_100/gateware/digilent_arty.bit
535 # this is the built bitstream
536
537 # Arty 100T VexRiscv
538
539 ./litex_boards/targets/digilent_arty.py --toolchain=symbiflow \
540 --cpu-type=vexriscv --sys-clk-freq 80e6 --variant a7-100 \
541 --output-dir build/vexriscv/arty_100 --build --no-compile-software
542 # see file build/vexriscv/arty_100/gateware/digilent_arty.bit
543 # this is the built bitstream
544
545 # Arty 35T Picorv32
546
547 ./litex_boards/targets/digilent_arty.py --toolchain=symbiflow \
548 --cpu-type=picorv32 --sys-clk-freq 80e6 --variant a7-35 \
549 --output-dir build/picorv32/arty_35 --build --no-compile-software
550 # see file build/picorv32/arty_35/gateware/digilent_arty.bit
551 # this is the built bitstream
552
553 # Arty 35T VexRiscv
554
555 ./litex_boards/targets/digilent_arty.py --toolchain=symbiflow \
556 --cpu-type=vexriscv --sys-clk-freq 80e6 --variant a7-35 \
557 --output-dir build/vexriscv/arty_35 --build --no-compile-software
558 # see file build/vexriscv/arty_35/gateware/digilent_arty.bit
559 # this is the built bitstream
560