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