47c37c439db30923219fce835d85e5df416282a2
[libreriscv.git] / HDL_workflow / coriolis2.mdwn
1 # Installing Coriolis2
2
3 ## debootstrap
4
5 First set up an schroot debootstrap jail with debian 10.
6 These instructions are based on information taken from here:
7 <https://www.debian.org/releases/stretch/amd64/apds03.html.en>
8
9 In advance, on the host system, edit /etc/fstab and add mount points:
10
11 (edit: personally I prefer using mount --bind points. however if doing
12 that then after a reboot the chroot will lose the bind mountpoints
13 and the commands need to be re-run, without which the chroot is
14 unusable)
15
16 /dev /home/chroot/coriolis/dev none bind 0 0
17 /dev/pts /home/chroot/coriolis/dev/pts none bind 0 0
18 /proc /home/chroot/coriolis/proc none bind 0 0
19 /sys /home/chroot/coriolis/sys none bind 0 0
20 /tmp /home/chroot/coriolis/tmp none bind 0 0
21
22 Then run these commands:
23
24 sudo bash
25 apt-get install debootstrap schroot
26 mkdir /opt/chroot/coriolis
27 /usr/sbin/debootstrap buster !$ http://ftp.us.debian.org/debian
28 mount /home/chroot/coriolis/dev
29 mount /home/chroot/coriolis/dev/pts
30 mount /home/chroot/coriolis/proc
31 mount /home/chroot/coriolis/sys
32 mount /home/chroot/coriolis/tmp
33 echo "coriolis2" > /home/chroot/coriolis/etc/debian_chroot
34
35 To do some preparation (users):
36
37 chroot /home/chroot/coriolis2 /bin/bash
38 adduser {yourpreferredusername}
39
40 It is best to make the username the same as the first user that
41 was added during the *main* (non-chroot) debian install, so that
42 uid 1000 matches between both main and chroot. You can check
43 this by looking at /etc/passwd as root, or by typing "id".
44
45 lkcl@fizzy:~$ id
46 uid=1000(lkcl) gid=1000(lkcl) groups=1000(lkcl),5(tty),....
47
48 Alternatively, /etc/passwd and /etc/group may
49 be mount-bound as well as /home however if you later forget you did
50 this and decide to delete the chroot, you will delete the entire /home
51 of your main system, as well as /etc/passwd.
52
53 You may wish to follow some of the other things such as configuring apt,
54 locales and keyboard, from the above-linked debian-admin HOWTO.
55
56 bootloader, kernel, ssh access, are unnecessary. Do run "apt clean" to clear out /var/cache/apt/archives in the chroot.
57
58 ## schroot
59
60 Create an schroot file section for the coriolis chroot by
61 editing /etc/schroot/schroot.conf:
62
63 [coriolis]
64 description=Debian Buster for Coriolis
65 directory=/home/chroot/coriolis
66 groups=sbuild-security,lkcl,users
67
68 Now as an *ordinary* user - not as root - you may type:
69
70 lkcl@fizzy:~$ schroot -c coriolis
71
72 and, due to the contents of /etc/debian\_chroot, and that you were in
73 fact logged in as uid 1000 and did in fact add a user to the chroot
74 as uid 1000, the prompt should become:
75
76 (coriolis2)lkcl@fizzy:~$
77
78 If however you need to run as root, then from outside the chroot,
79 as *root*, you run this:
80
81 lkcl@fizzy:~# schroot -c coriolis
82
83 and you will see this as a result:
84
85 (coriolis2)lkcl@fizzy:~#
86
87 ## coriolis2
88
89 These are nominally taken from
90 <https://www-soc.lip6.fr/equipe-cian/logiciels/coriolis/>
91 however there are errors in the original at the moment.
92 Do not try qt5, it will not work.
93
94 In ~/.bash\_profile add the following so that builds (rebuilds) if you need
95 them will be quicker, and you can run the GUI from the chroot:
96
97 export PATH=/usr/lib/ccache:"$PATH"
98 export DISPLAY=:0.0
99
100 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).
101
102 Then run the following commands, as root, *in* the chroot:
103
104 apt-get update
105 apt-get install -y automake binutils-dev bison build-essential \
106 ccache clang cmake doxygen dvipng flex gcc git graphviz \
107 imagemagick libboost-all-dev libboost-python-dev libbz2-dev \
108 libmpfr-dev libgmp-dev libmotif-dev libreadline-dev \
109 libqwt-dev libtool libx11-dev libxaw7-dev libxml2-dev \
110 libxpm-dev libxt-dev python3.7 python3-jinja2 python3-pip \
111 python3-setuptools python-dev python-qt4 python-sphinx \
112 qt4-dev-tools rapidjson-dev tcl tcl-dev tcl-tclreadline \
113 texlive texlive-fonts-extra texlive-lang-french \
114 texlive-latex-extra texlive-pictures xfig yosys zlib1g-dev
115
116 Then, as the ordinary (non-root) user in the schroot:
117
118 mkdir -p ~/coriolis-2.x/src
119 cd ~/coriolis-2.x/src
120 git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
121 cd coriolis
122 git checkout devel
123 ./bootstrap/ccb.py --project=coriolis --make="-j$(nproc) install"
124
125 To set up the coriolis2 environment, run this:
126
127 eval `~/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py`
128
129 For convenience that may be placed in a file and "sourced", to avoid
130 having to look this page up every time
131
132 echo "`~/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py`" > \
133 ~/coriolisenv
134 source ~/coriolisenv
135
136 ## Testing coriolis2
137
138 To run the graphical editor go to the bin directory
139
140 cd ~/coriolis-2.x/Linux.MyARCH/Release.Shared/install/bin
141 ./cgt
142
143 Then run the following commands from the menubar
144
145 Tutorials / Run Demo (Python Flavour)
146
147 If the following window appears you have an error.
148
149 [[!img chicken.png ]]
150
151 click on the chicken several times
152
153 If you have the following, congratulations:
154
155 [[!img demo_cell.png ]]
156
157 # Upgrading to latest yosys in the chroot
158
159 yosys in debian may not be enough to work with nmigen,
160 therefore it's probably a good idea to upgrade.
161
162 As root, in the chroot, run the following:
163
164 apt-get update
165 apt-get build-dep yosys
166 apt-get install clang
167 apt-get remove yosys
168
169 This will remove debian/buster yosys however getting the build dependencies is quick and easy enough.
170
171 As the ordinary user, the following instructions can be followed
172 (<http://www.clifford.at/yosys/download.html>)
173
174 cd ~
175 git clone https://github.com/cliffordwolf/yosys.git
176 cd yosys
177 make config-clang
178 make -j$(nproc)
179
180 As root, run:
181
182 make install
183
184 ## Check out alliance and alliance-check-toolkit
185
186 Adapted from <https://www-soc.lip6.fr/en/team-cian/softwares/alliance/>
187
188 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:
189
190 export PATH=/usr/lib/ccache:"$PATH"
191
192 In the chroot, as the ordinary schroot user:
193
194 mkdir -p alliance/build alliance/install
195 cd ~/alliance
196 git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
197 mv alliance/alliance/src alliance
198 rm -rf alliance/alliance
199 cd alliance/src
200 ./autostuff
201 cd ~/alliance/build
202 export ALLIANCE_TOP=$HOME/alliance/install
203 export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib:${LD_LIBRARY_PATH}
204 export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib64:${LD_LIBRARY_PATH}
205 ../alliance/src/configure --prefix=$ALLIANCE_TOP --enable-alc-shared
206 make -j1 install
207
208 The three exports are best added to ~/.bash_profile for later convenience
209
210 # Tutorials and checks
211
212 Install alliance-check-toolkit in the chroot:
213
214 * <https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git>
215 * See coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/main/PythonTutorial/index.html
216
217 Run the following (if not done already):
218
219 source ~/coriolisenv
220
221 Git clone alliance-check-toolkit:
222
223 git clone https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git
224
225 You must create a configuration for your user in alliance-check-toolkit to define where the various tools are installed:
226
227 touch alliance-check-toolkit/etc/mk/users.d/user-$USERNAME.mk
228 cat <<EOF >>alliance-check-toolkit/etc/mk/users.d/user-$USERNAME.mk
229 export CORIOLIS_TOP=/home/$USERNAME/coriolis-2.x/Linux.x86_64/Release.Shared/install
230 export ALLIANCE_TOP=/home/$USERNAME/alliance/install
231 export CHECK_TOOLKIT=/home/$USERNAME/alliance-check-toolkit
232 export YOSYS_TOP=/home/$USERNAME/yosys
233 EOF
234
235 You can try the ARM in alliance-check-toolkit:
236
237 cd alliance-check-toolkit/benchsARM/cmos/
238 make lvx
239
240 This should take about five minutes. It's symbolic, but should be a configuration compatible with 180nm. To actually see the results:
241
242 make cgt
243
244 Then:
245
246 Select File -> Open Cell or press CTRL + o
247
248 Enter as the cell name (without the single quotation marks):
249
250 'arm_chip_cts_r'
251
252 As a very rough approximation, you can say that one lambda equals 180nm.
253
254 It depends on the zoom level and of the fact that you ask to see the inside of the cells.
255
256 To actually see the transistors:
257
258 Tools -> Controller -> Filter Tab -> check "Process Terminal Cells"
259
260 You can also tweak the layer display by selecting:
261
262 Tools -> Controller -> Layers & Go
263
264 You can quicly hide/show the Controller with:
265
266 CTRL+I
267
268 The up-to-date documentation is supplied directly in the Coriolis repository:
269
270 coriolis/documentation/output/index.html
271
272 The links toward the doxygen doc will be invalid a this point, but everything else works.
273
274 After installation, it is put in:
275
276 coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/index.html
277
278 ## More Information from Jean-Paul
279
280 There is a WIP documentation website for Alliance/Coriolis at <http://coriolis.lip6.fr/>.
281
282 There are also very cursory informations about installing Alliance here:
283 https://www-soc.lip6.fr/en/team-cian/softwares/alliance/
284
285 You also have a third repository for various blocks/chip/examples here:
286 https://gitlab.lip6.fr/jpc/alliance-check-toolkit
287
288 (with a basic doc under "doc/"...)
289
290 # Clone "soclayout" repository and place and route a layout experiment
291
292 In order to do the physical layout of the logical
293 netlists generated by yosys we use coriolis and
294 alliace installed above by doing the following
295 (using experiment9 as an example):
296
297 $ cd ~/src
298 $ git clone https://git.libre-soc.org/git/soclayout.git
299 $ cd soclayout/
300 $ git submodule update --init --recursive
301 $ find . -type f -exec sed -i 's/'lkcl'/'"$USER"'/g' {} \;
302 $ ./mksym.sh
303 $ cd experiments9
304 $ ./mksym.sh
305 $ yosys
306 yosys> read_ilang test_issuer.il
307 yosys> heirarchy -check -top test_issuer
308 yosys> synth -top test_issuer
309 yosys> dfflibmap -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
310 yosys> abc -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
311 yosys> clean
312 yosys> write_blif test_issuer.blif
313 yosys> exit
314 $ make pinmux
315 $ make layout (will take between 20min and 2 hours depending on your hardware)
316 $ make view
317
318 A window should open with with contents that look like this (pretty isn't it?)
319
320 [[!img 180nm_Oct2020/2020-07-03_11-04.png size="825x" ]]
321
322 # Issues running from (e.g.) archlinux as host and debian as a chroot
323
324 You may run into difficulties firing up GUI applications from the chroot.
325 Try installing Xnest <https://box.matto.nl/xnest.html> which you should
326 do in the *host* system. Also remember to install a "basic" window manager
327 (twm, fvwm2)
328
329 On the *host*, run Xnest and a window manager:
330
331 Xnest :1 -ac &
332 twm -display :1 &
333
334 Then, in the chroot, change DISPLAY environment variable (permanently
335 in ~/.bash_profile if desired)
336
337 export DISPLAY=:1.0
338
339 Then, in the chroot, follow the cgt instructions above, or use "make view"
340 in any of the soclayout experiments or alliance-check-toolkit bench tests