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