(no commit message)
[libreriscv.git] / HDL_workflow / coriolis2.mdwn
index b447c544e6a43b3fedbbb7189a5a6cc23b6efab6..8b8ca88216bad9c747480fa92e6e43637370ddfd 100644 (file)
@@ -2,12 +2,16 @@
 
 ## debootstrap
 
-First set up an schroot debootstrap jail with debian 9.0.
-Follow these instructions taken from here:
+First set up an schroot debootstrap jail with debian 10.
+These instructions are based on information taken from here:
 <https://www.debian.org/releases/stretch/amd64/apds03.html.en>
 
-In advance, edit /etc/fstab and add mount points: personally I prefer using
-mount --bind points
+In advance, on the host system, edit /etc/fstab and add mount points:
+
+(edit: personally I prefer using mount --bind points.  however if doing
+that then after a reboot the chroot will lose the bind mountpoints
+and the commands need to be re-run, without which the chroot is
+unusable)
 
     /dev    /home/chroot/coriolis/dev   none    bind    0   0
     /dev/pts /home/chroot/coriolis/dev/pts  none    bind    0   0
@@ -20,8 +24,12 @@ Then run these commands:
     sudo bash
     apt-get install debootstrap schroot
     mkdir /opt/chroot/coriolis
-    /usr/sbin/debootstrap stretch !$ http://ftp.us.debian.org/debian
-    mount -a
+    /usr/sbin/debootstrap buster !$ http://ftp.us.debian.org/debian
+    mount /home/chroot/coriolis/dev
+    mount /home/chroot/coriolis/dev/pts
+    mount   /home/chroot/coriolis/proc
+    mount   /home/chroot/coriolis/sys
+    mount   /home/chroot/coriolis/tmp
     echo "coriolis2" > /home/chroot/coriolis/etc/debian_chroot
 
 To do some preparation (users):
@@ -44,16 +52,16 @@ of your main system, as well as /etc/passwd.
 
 You may wish to follow some of the other things such as configuring apt,
 locales and keyboard, from the above-linked debian-admin HOWTO.
-bootloader, kernel, ssh access, all these are
-unnecessary.  do run "apt clean" to clear out /var/cache/apt/archives
-in the chroot.
+
+bootloader, kernel, ssh access, are unnecessary. Do run "apt clean" to clear out /var/cache/apt/archives in the chroot.
 
 ## schroot
 
-Create an schroot file section:
+Create an schroot file section for the coriolis chroot by
+editing /etc/schroot/schroot.conf:
 
-    [coriolis] 
-    description=Debian Stable for Coriolis
+    [coriolis]
+    description=Debian Buster for Coriolis
     directory=/home/chroot/coriolis
     groups=sbuild-security,lkcl,users
 
@@ -65,7 +73,16 @@ and, due to the contents of /etc/debian\_chroot, and that you were in
 fact logged in as uid 1000 and did in fact add a user to the chroot
 as uid 1000, the prompt should become:
 
-    (coriolis2)lkcl@fizzy:~$ 
+    (coriolis2)lkcl@fizzy:~$
+
+If however you need to run as root, then from outside the chroot,
+as *root*, you run this:
+
+    lkcl@fizzy:~# schroot -c coriolis
+
+and you will see this as a result:
+
+    (coriolis2)lkcl@fizzy:~#
 
 ## coriolis2
 
@@ -80,36 +97,32 @@ them will be quicker, and you can run the GUI from the chroot:
     export PATH=/usr/lib/ccache:"$PATH"
     export DISPLAY=:0.0
 
-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).
+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).
 
 Then run the following commands, as root, *in* the chroot:
 
     apt-get update
-    apt-get install -y build-essential binutils-dev               \
-                  git cmake bison flex gcc python-dev               \
-                  libboost-all-dev libboost-python-dev               \
-                  zlib1g-dev                                         \
-                  libbz2-dev libxml2-dev rapidjson-dev libbz2-dev     \
-                  doxygen dvipng graphviz python-sphinx               \
-                  texlive-fonts-extra texlive-lang-french            \
-                  libqwt-dev qt4-dev-tools python-qt4               \
-                   libxt-dev libxpm-dev libmotif-dev                \
-                   yosys
+    apt-get install -y automake binutils-dev bison build-essential \
+    ccache clang cmake doxygen dvipng flex gcc git graphviz \
+    imagemagick libboost-all-dev libboost-python-dev libbz2-dev \
+    libmpfr-dev libgmp-dev libmotif-dev libreadline-dev \
+    libqwt-dev libtool libx11-dev libxaw7-dev libxml2-dev \
+    libxpm-dev libxt-dev python3.7 python3-jinja2 python3-pip \
+    python3-setuptools python-dev python-qt4 python-sphinx \
+    qt4-dev-tools rapidjson-dev tcl tcl-dev tcl-tclreadline \
+    texlive texlive-fonts-extra texlive-lang-french \
+    texlive-latex-extra texlive-pictures xfig yosys zlib1g-dev
 
 Then, as the ordinary (non-root) user in the schroot:
 
     mkdir -p ~/coriolis-2.x/src
     cd ~/coriolis-2.x/src
-    git clone https://www-soc.lip6.fr/git/coriolis.git
-
+    git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
     cd coriolis
     git checkout devel
-    ./bootstrap/ccb.py --project=coriolis --make="-j4 install"
+    ./bootstrap/ccb.py --project=coriolis --make="-j$(nproc) install"
 
-To set up the alliance environment, run this:
+To set up the coriolis2 environment, run this:
 
     eval `~/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py`
 
@@ -120,81 +133,151 @@ having to look this page up every time
             ~/coriolisenv
     source ~/coriolisenv
 
+## Testing coriolis2
+
 To run the graphical editor go to the bin directory
-     cd ~/coriolis-2.x/Linux.MyARCH/Release.Shared/install/bin
+
+    cd ~/coriolis-2.x/Linux.MyARCH/Release.Shared/install/bin
     ./cgt
 
 Then run the following commands from the menubar
 
     Tutorials / Run Demo (Python Flavour)
-    
-The following window will appear
+
+If the following window appears you have an error.
 
 [[!img chicken.png ]]
 
 click on the chicken several times
 
-## check out alliance and alliance-check-toolkit
+If you have the following, congratulations:
 
-in the schroot:
+[[!img demo_cell.png ]]
 
-    git clone https://gitlab.lip6.fr/jpc/alliance-check-toolkit.git
+# Upgrading to latest yosys in the chroot
 
-TODO: document how to build alliance, basically this:
+yosys in debian may not be enough to work with nmigen,
+therefore it's probably a good idea to upgrade.
 
-In the chroot, as root:
+As root, in the chroot, run the following:
 
     apt-get update
-    apt-get install git build-essential libtool automake aclocal \
-             flex bison xfig imagemagick \
-             texlive texlive-pictures texlive-latex-extra \
-             libx11-dev libxt-dev libxaw7-dev libxpm-dev libmotif-dev
+    apt-get build-dep yosys
+    apt-get install clang
+    apt-get remove yosys
 
-In the chroot, as the ordinary schroot user:
+This will remove debian/buster yosys however getting the build dependencies is quick and easy enough.
 
-    mkdir -p alliance/build alliance/install
-    cd ~/alliance
-    git clone https://www-soc.lip6.fr/git/alliance.git
-    cd alliance/src
+As the ordinary user, the following instructions can be followed
+(<http://www.clifford.at/yosys/download.html>)
 
-Modify the following file (may not be necessary later):
+    cd ~
+    git clone https://github.com/cliffordwolf/yosys.git
+    cd yosys
+    make config-clang
+    make -j$(nproc)
 
-    diff --git a/alliance/src/pat/src/pat_desc_y.y b/alliance/src/pat/src/pat_desc_y.y
-    index 14720dbc..5390d2a4 100644
-    --- a/alliance/src/pat/src/pat_desc_y.y
-    +++ b/alliance/src/pat/src/pat_desc_y.y
-    @@ -85,8 +85,8 @@ unsigned short  position; /* # of statement since last comment    */
-     static struct papat *lcl_addpapat (lastpapat, label, line)
+As root, run:
 
-     struct papat   *lastpapat; /* pointer on the last papat structure  */
-    -char           *label;     /* pattern's label          */
-    -unsigned short  line;      /* pattern' line number         */
-    +char           *label;
-    +unsigned short  line;
+    make install
 
-       {
-       struct papat *ptpat;
+## Check out alliance and alliance-check-toolkit
 
-Continue running as user:
+Adapted from <https://www-soc.lip6.fr/en/team-cian/softwares/alliance/>
 
+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:
+
+    export PATH=/usr/lib/ccache:"$PATH"
+
+In the chroot, as the ordinary schroot user:
+
+    mkdir -p alliance/build alliance/install
+    cd ~/alliance
+    git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
+    mv alliance/alliance/src alliance
+    rm -rf alliance/alliance
+    cd alliance/src
     ./autostuff
     cd ~/alliance/build
     export ALLIANCE_TOP=$HOME/alliance/install
     export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib:${LD_LIBRARY_PATH}
+    export LD_LIBRARY_PATH=${ALLIANCE_TOP}/lib64:${LD_LIBRARY_PATH}
     ../alliance/src/configure --prefix=$ALLIANCE_TOP --enable-alc-shared
     make -j1 install
 
+The three exports are best added to ~/.bash_profile for later convenience
+
 # Tutorials and checks
 
-* <https://gitlab.com/Chips4Makers/alliance-check-toolkit>
+Install alliance-check-toolkit in the chroot:
+
+* <https://gitlab.lip6.fr/vlsi-eda/alliance.git>
+* See coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/main/PythonTutorial/index.html
+
+Run the following (if not done already):
+
+    source ~/coriolisenv
+
+Git clone alliance-check-toolkit:
+
+    git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
+
+You must create a configuration for your user in alliance-check-toolkit to define where the various tools are installed:
+
+    touch alliance-check-toolkit/etc/mk/users.d/user-USERNAME.mk
+    cat <<EOF >>alliance-check-toolkit/etc/mk/users.d/user-USERNAME.mk
+    export CORIOLIS_TOP=/home/USERNAME/coriolis-2.x/Linux.x86_64/Release.Shared/install
+    export ALLIANCE_TOP=/home/USERNAME/alliance/install
+    export CHECK_TOOLKIT=/home/USERNAME/alliance-check-toolkit
+    export YOSYS_TOP=/home/USERNAME/yosys
+    EOF
 
-## Information from Jean-Paul
+You can try the ARM in alliance-check-toolkit:
 
-There should be very soon a website at https://coriolis.lip6.fr (it is not yet
-online). Where I intend to put all the documentation about Alliance/Coriolis.
+    cd alliance-check-toolkit/benchsARM/cmos/
+    make lvx
 
-In the meantime did you find the doc shipped with Coriolis ?
+This should take about five minutes. It's symbolic, but should be a configuration compatible with 180nm. To actually see the results:
+
+    make cgt
+
+Then:
+
+    Select File -> Open Cell or press CTRL + o
+
+Enter as the cell name (without the single quotation marks):
+
+    'arm_chip_cts_r'
+
+As a very rough approximation, you can say that one lambda equals 180nm.
+
+It depends on the zoom level and of the fact that you ask to see the inside of the cells.
+
+To actually see the transistors:
+
+    Tools -> Controller -> Filter Tab -> check "Process Terminal Cells"
+
+You can also tweak the layer display by selecting:
+
+    Tools -> Controller -> Layers & Go
+
+  You can quicly hide/show the Controller with:
+
+    CTRL+I
+
+The up-to-date documentation is supplied directly in the Coriolis repository:
+
+    coriolis/documentation/output/index.html
+
+The links toward the doxygen doc will be invalid a this point, but everything else works.
+
+After installation, it is put in:
+
+    coriolis-2.x/Linux.x86_64/Release.Shared/install/share/doc/coriolis2/en/html/index.html
+
+## More Information from Jean-Paul
+
+There is a WIP documentation website for Alliance/Coriolis at <http://coriolis.lip6.fr/>.
 
 There are also very cursory informations about installing Alliance here:
     https://www-soc.lip6.fr/en/team-cian/softwares/alliance/
@@ -204,3 +287,52 @@ You also have a third repository for various blocks/chip/examples here:
 
 (with a basic doc under "doc/"...)
 
+# Clone "soclayout" repository and place and route a layout experiment
+
+In order to do the physical layout of the logical 
+netlists generated by yosys we use coriolis and 
+alliace installed above by doing the following 
+(using experiment9 as an example):
+
+    $ cd ~/src
+    $ git clone https://git.libre-soc.org/git/soclayout.git
+    $ cd soclayout/
+    $ find . -type f -exec sed -i 's/'lkcl'/'"$USER"'/g' {} \;
+    $ ./mksym.sh
+    $ cd experiments9
+    $ ./mksym.sh
+    $ yosys
+    yosys> read_ilang test_issuer.il
+    yosys> heirarchy -check -top test_issuer
+    yosys> synth -top test_issuer
+    yosys> dfflibmap -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
+    yosys> abc -liberty /home/USERNAME/alliance/install/cells/sxlib/sxlib.lib
+    yosys> clean
+    yosys> write_blif test_issuer.blif
+    yosys> exit
+    $ make layout (will take between 20min and 2 hours depending on your hardware)
+    $ make view
+
+A window should open with with contents that look like this (pretty isn't it?)
+
+[[!img 180nm_Oct2020/2020-07-03_11-04.png size=825x825 ]]
+
+# Issues running from (e.g.) archlinux as host and debian as a chroot
+
+You may run into difficulties firing up GUI applications from the chroot.
+Try installing Xnest <https://box.matto.nl/xnest.html> which you should
+do in the *host* system.  Also remember to install a "basic" window manager
+(twm, fvwm2)
+
+On the *host*, run Xnest and a window manager:
+
+    Xnest :1 -ac &
+    twm -display :1 &
+
+Then, in the chroot, change DISPLAY environment variable (permanently
+in ~/.bash_profile if desired)
+
+    export DISPLAY=:1.0
+
+Then, in the chroot, follow the cgt instructions above, or use "make view"
+in any of the soclayout experiments or alliance-check-toolkit bench tests