101d91ff95f805359df115cd6147c633dbb4202e
[libreriscv.git] / HDL_workflow / coriolis2.mdwn
1 # Installing Coriolis2
2
3 TODO: include tasyagle <https://www-soc.lip6.fr/en/team-cian/softwares/tasyagle/>
4
5 Videos and links:
6
7 * <https://www.youtube.com/watch?v=TN9AQgoVwDw&list=PLj2N46Uqs4huGN-redGHVEILPz17OBu37&index=11>
8 * <http://coriolis.lip6.fr/>
9 * <https://gitlab.lip6.fr/vlsi-eda>
10
11 ## Automated Installation - One-liner
12 The new automated method of installing/setting up Coriolis2 is as follows:
13
14 1. Clone the repo "dev-env-setup".
15 Tutorial assumes the directory is located under user's home.
16 1. Run the script "coriolis2-chroot" to create a new chroot environment,
17 and setup Coriolis2.
18 1. Once cgt window appears, go to File, Open Cell, and type chip_r.
19 1. You should now have a working Coriolis chroot!
20
21 In a terminal:
22
23 $ cd ~/dev-env-setup
24 $ sudo bash
25 # ./coriolis2-chroot
26
27 And now you wait... (about 30-45min, depends on your CPU).
28 I suggest occasionallly checking the status messages,
29 especially after apt finished updating the packages and the script moves on
30 to compiling yosys, coriolis2, alliance, as well as when
31 alliance-check-toolkit generates the floorplan for you.
32
33 This is what the chip floorplan should look like:
34
35 [[!img chip_r_floorplan.png ]]
36
37 ## Automated Installation - Separated Steps
38 The steps performed by "coriolis2-chroot" can be done manually and are:
39
40 1. Run the script "mk-deb-chroot" to create a chroot environment.
41 Tutorial assumes the name is "coriolis"
42 1. Run the script "cp-scripts-to-chroot" to copy the dev-env-setup directory
43 over to your new chroot environment.
44 1. Login into the new scroot environment as a normal user
45 (should be the same as your current user).
46 1. Run the script "coriolis-install"
47
48 In a terminal:
49
50 $ cd ~/dev-env-setup
51 $ sudo bash
52 # ./mk-deb-chroot coriolis
53 # ./cp-scripts-to-chroot coriolis
54
55 In a separate terminal as normal user:
56
57 $ scroot -c coriolis
58 (coriolis)$ cd ~/dev-env-setup
59 (coriolis)$ ./coriolis-install
60
61 # Further Details
62
63 ## Python3 Coriolis Support
64
65 A separate script will be written to use the latest development version of Coriolis2.
66 For now however, a stable version is pulled in, which still uses Python2.
67
68 ## Chroot/Jail Environment
69
70 See [[devscripts]] for explanation of the "mk-deb-chroot" script.
71
72 ## Coriolis2 Setup
73
74 These are nominally taken from
75 <https://www-soc.lip6.fr/equipe-cian/logiciels/coriolis/>
76 however there are errors in the original at the moment.
77 Do not try qt5, it will not work.
78
79 In ~/.bash\_profile add the following so that builds (rebuilds) if you need
80 them will be quicker, and you can run the GUI from the chroot:
81
82 export PATH=/usr/lib/ccache:"$PATH"
83 export DISPLAY=:0.0
84
85 Second (or at a new terminal / xterm), log in as root on the host (not the chroot) then do schroot -c coriolis to get to be root in the chroot (or, you can install sudo in the chroot and then do "sudo bash" in the chroot).
86
87 Then run the following commands, as root, *in* the chroot:
88
89 apt-get update
90 apt-get install -y automake binutils-dev bison build-essential \
91 ccache clang cmake doxygen dvipng flex gcc git graphviz \
92 imagemagick libboost-all-dev libboost-python-dev libbz2-dev \
93 libmpfr-dev libgmp-dev libmotif-dev libreadline-dev \
94 libqwt-dev libtool libx11-dev libxaw7-dev libxml2-dev \
95 libxpm-dev libxt-dev python3.7 python3-jinja2 python3-pip \
96 python3-setuptools python-dev python-qt4 python-sphinx \
97 qt4-dev-tools rapidjson-dev tcl tcl-dev tcl-tclreadline \
98 texlive texlive-fonts-extra texlive-lang-french \
99 texlive-latex-extra texlive-pictures xfig yosys zlib1g-dev
100
101 Then, as the ordinary (non-root) user in the schroot:
102
103 mkdir -p ~/coriolis-2.x/src
104 cd ~/coriolis-2.x/src
105 git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
106 cd coriolis
107 git checkout LS180_RC7_FINAL
108 ./bootstrap/ccb.py --project=coriolis --make="-j$(nproc) install"
109
110 Note: Instead of "devel", "LS180_RC7_FINAL" is used as it is more stable.
111 Once Python3 support is added, can switch to using "devel".
112
113 To set up the coriolis2 environment, run this:
114
115 eval `~/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py`
116
117 For convenience that may be placed in a file and "sourced", to avoid
118 having to look this page up every time
119
120 /bin/bash << EOF
121 /home/$USER/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > /home/$USER/coriolisenv
122 EOF
123 source ~/coriolisenv
124
125 For now a workaround must be used for coriolisEnv.py to correctly detect the shell (Bash in this case).
126
127 ## Testing coriolis2
128
129 To run the graphical editor go to the bin directory
130
131 cd ~/coriolis-2.x/Linux.MyARCH/Release.Shared/install/bin
132 ./cgt
133
134 Then run the following commands from the menubar
135
136 Tutorials / Run Demo (Python Flavour)
137
138 If the following window appears you have an error.
139
140 [[!img chicken.png ]]
141
142 click on the chicken several times
143
144 If you have the following, congratulations:
145
146 [[!img demo_cell.png ]]
147
148 # Upgrading to latest yosys in the chroot
149
150 yosys in debian may not be enough to work with nmigen,
151 therefore it's probably a good idea to upgrade.
152
153 As root, in the chroot, run the following:
154
155 apt-get update
156 apt-get build-dep yosys
157 apt-get install clang
158 apt-get remove yosys
159
160 This will remove debian/buster yosys however getting the build dependencies is quick and easy enough.
161
162 As the ordinary user, the following instructions can be followed
163 (<http://www.clifford.at/yosys/download.html>)
164
165 cd ~
166 git clone https://github.com/cliffordwolf/yosys.git
167 cd yosys
168 git checkout 049e3abf9baf795e69b9ecb9c4f19de6131f8418
169 make config-clang
170 make -j$(nproc)
171
172 Note: For now a stable version of yosys is used!
173
174 As root, run:
175
176 make install
177
178 ## Alliance
179
180 Adapted from <https://www-soc.lip6.fr/en/team-cian/softwares/alliance/>
181
182 In the chroot, as the ordinary schroot user, in ~/.bash\_profile add the following so that builds (rebuilds, if you need them) will be quicker:
183
184 export PATH=/usr/lib/ccache:"$PATH"
185
186 In the chroot, as the ordinary schroot user:
187
188 mkdir -p alliance/build alliance/install
189 cd ~/alliance
190 git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
191 mv alliance/alliance/src alliance
192 rm -rf alliance/alliance
193 cd alliance/src
194 ./autostuff
195 cd ~/alliance/build
196 export ALLIANCE_TOP=$HOME/alliance/install
197 export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib:${LD_LIBRARY_PATH}
198 export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib64:${LD_LIBRARY_PATH}
199 ../alliance/src/configure --prefix=$ALLIANCE_TOP --enable-alc-shared
200 make -j1 install
201
202 The three exports are best added to ~/.bash_profile for later convenience
203
204 # Tutorials and checks
205
206 Install alliance-check-toolkit in the chroot:
207
208 * <https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git>
209 * See coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/main/PythonTutorial/index.html
210
211 Run the following (if not done already):
212
213 source ~/coriolisenv
214
215 Git clone alliance-check-toolkit:
216
217 git clone https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git
218
219 You must create a configuration for your user in alliance-check-toolkit to define where the various tools are installed:
220
221 touch alliance-check-toolkit/etc/mk/users.d/user-$USERNAME.mk
222 cat <<EOF >>alliance-check-toolkit/etc/mk/users.d/user-$USERNAME.mk
223 export CORIOLIS_TOP=/home/$USERNAME/coriolis-2.x/Linux.x86_64/Release.Shared/install
224 export ALLIANCE_TOP=/home/$USERNAME/alliance/install
225 export CHECK_TOOLKIT=/home/$USERNAME/alliance-check-toolkit
226 export YOSYS_TOP=/home/$USERNAME/yosys
227 EOF
228
229 You can try the user adder benchmark in alliance-check-toolkit:
230
231 cd alliance-check-toolkit/benchs/adder/cmos
232 make lvx
233
234 This should take about five minutes. It's symbolic, but should be a configuration compatible with 180nm. To actually see the results:
235
236 make cgt
237
238 Then:
239
240 Select File -> Open Cell or press CTRL + o
241
242 Enter as the cell name (without the single quotation marks):
243
244 'chip_r'
245
246 As a very rough approximation, you can say that one lambda equals 180nm.
247
248 It depends on the zoom level and of the fact that you ask to see the inside of the cells.
249
250 To actually see the transistors:
251
252 Tools -> Controller -> Filter Tab -> check "Process Terminal Cells"
253
254 You can also tweak the layer display by selecting:
255
256 Tools -> Controller -> Layers & Go
257
258 You can quicly hide/show the Controller with:
259
260 CTRL+I
261
262 The up-to-date documentation is supplied directly in the Coriolis repository:
263
264 coriolis/documentation/output/index.html
265
266 The links toward the doxygen doc will be invalid a this point, but everything else works.
267
268 After installation, it is put in:
269
270 coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/index.html
271
272 ## More Information from Jean-Paul
273
274 There is a WIP documentation website for Alliance/Coriolis at <http://coriolis.lip6.fr/>.
275
276 There are also very cursory informations about installing Alliance here:
277 https://www-soc.lip6.fr/en/team-cian/softwares/alliance/
278
279 You also have a third repository for various blocks/chip/examples here:
280 https://gitlab.lip6.fr/jpc/alliance-check-toolkit
281
282 (with a basic doc under "doc/"...)
283
284 # Clone "soclayout" repository and place and route a layout experiment
285
286 In order to do the physical layout of the logical
287 netlists generated by yosys we use coriolis and
288 alliace installed above by doing the following
289 (using experiment9 as an example):
290
291 $ cd ~/src
292 $ git clone https://git.libre-soc.org/git/soclayout.git
293 $ cd soclayout/
294 $ git submodule update --init --recursive
295 $ find . -type f -exec sed -i 's/'lkcl'/'"$USER"'/g' {} \;
296 $ ./mksym.sh
297 $ cd experiments9
298 $ ./mksym.sh
299 $ yosys
300 yosys> read_ilang test_issuer.il
301 yosys> heirarchy -check -top test_issuer
302 yosys> synth -top test_issuer
303 yosys> dfflibmap -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
304 yosys> abc -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
305 yosys> clean
306 yosys> write_blif test_issuer.blif
307 yosys> exit
308 $ make pinmux
309 $ make layout (will take between 20min and 2 hours depending on your hardware)
310 $ make view
311
312 A window should open with with contents that look like this (pretty isn't it?)
313
314 [[!img 180nm_Oct2020/2020-07-03_11-04.png size="825x" ]]
315
316 # Issues running from (e.g.) archlinux as host and debian as a chroot
317
318 You may run into difficulties firing up GUI applications from the chroot.
319 Try installing Xnest <https://box.matto.nl/xnest.html> which you should
320 do in the *host* system. Also remember to install a "basic" window manager
321 (twm, fvwm2)
322
323 On the *host*, run Xnest and a window manager:
324
325 Xnest :1 -ac &
326 twm -display :1 &
327
328 Then, in the chroot, change DISPLAY environment variable (permanently
329 in ~/.bash_profile if desired)
330
331 export DISPLAY=:1.0
332
333 Then, in the chroot, follow the cgt instructions above, or use "make view"
334 in any of the soclayout experiments or alliance-check-toolkit bench tests
335
336 # Libre-SOC 180nm ASIC reproducible build<a name="ls180_repro_build"></a>
337
338 Prerequisites:
339
340 * machine with debian/10 (or if you absolutely must, ubuntu)
341 * minimum 32 GB RAM
342 * minimum XEON processor or Intel i9 or IBM POWER9
343 * enough time to complete the build in full
344 * around 50 GB free space (this is more than enough)
345
346 **WARNING! DO NOT TRY RUNNING CORIOLIS2 IN QEMU OR OTHER VM!**
347 VLSI builds are far too CPU and memory intensive.
348
349 Follow these instructions to build the ls180 GDS-II files
350
351 * clone the dev-env-setup repository
352 * run the coriolis2-chroot script as root
353 * drop into the schroot
354 * navigate to the soclayout/experiments9 directory
355 * run the ./build_full_4k_sram.sh script
356 * run "make view" to see the results.
357
358 The FreePDK45 Chips4Makers FlexLib variant is slightly
359 different, in that it builds GDS-II rather than Alliance Symbolic
360 and so requires klayout to view the GDS-II. We do not yet
361 have a build script for klayout, it will be in dev-env-setup
362 when it is. In the meantime you can follow instructions
363 on the website <https://klayout.de/>
364
365 Please check these scripts before running them.
366 **This is your responsibility**. Also as explained in
367 the [[HDL_workflow]] the standard OS for reproducible
368 builds is debian/10. It is just about possible to use
369 ubuntu to run the debootstrap chroot setup but it is
370 not recommended.
371
372 Commands to run:
373
374 ```
375 $ git clone https://git.libre-soc.org/git/dev-env-setup.git
376 $ cd dev-env-setup
377 $ sudo bash
378 # ./coriolis2-chroot
379 # exit
380 $ schroot -c cotiolis
381 $ cd soclayout/experiments9
382 $ ./build_full_4k_sram.sh
383 ```
384 (now do something else for the next 90 minutes)
385