|
| 1 | +============================= |
| 2 | +Ready made Docker environment |
| 3 | +============================= |
| 4 | + |
| 5 | +This self contained tutorial will show you how to pull a Docker container with all the |
| 6 | +dependencies preinstalled so that you can start right away without having to compile any |
| 7 | +of the dependencies from scratch. |
| 8 | + |
| 9 | +Simply pull the Docker image from the Docker hub and get started. |
| 10 | + |
| 11 | +The scope of this tutorial is: |
| 12 | + |
| 13 | +* Fetching the Docker image |
| 14 | +* Generating the verilog |
| 15 | +* Running a simulation |
| 16 | +* Opening the traces (gtkwave + konata) |
| 17 | + |
| 18 | +**Important** |
| 19 | + |
| 20 | +Starting the Docker image might take much longer, when your own user owning the folder |
| 21 | +where you cloned the repo to doesn't have the same uid as the ubuntu user inside the |
| 22 | +Docker container! The uid of the ubuntu user is 1000 |
| 23 | + |
| 24 | +Linux and MacOS X |
| 25 | +------------------ |
| 26 | + |
| 27 | +There's a bash script called run_docker.sh which automatically pulls the most |
| 28 | +recent Docker image, starts it and then launches a VNC viewer. |
| 29 | + |
| 30 | +Just make sure that you have Tiger VNC, bash and of course Docker installed |
| 31 | +and that the Docker demon is running. |
| 32 | + |
| 33 | +Then you can simply run |
| 34 | + |
| 35 | +.. code-block:: bash |
| 36 | +
|
| 37 | + ./run_docker.sh |
| 38 | +
|
| 39 | +After the image has been fetched and the virtual X server has started you should |
| 40 | +be greated with an XFCE4 desktop in a VNC viewer |
| 41 | + |
| 42 | +Windows |
| 43 | +------- |
| 44 | + |
| 45 | +Windows is a bit trickier, but similar as what we do on Linux and Mac |
| 46 | + |
| 47 | +In the Power Shell, first fetch the Docker image, then start it as demon and check |
| 48 | +with the inspect command what the IP of the container is. |
| 49 | + |
| 50 | +After that, you should be able to connect with a VNC client. |
| 51 | + |
| 52 | +TigerVNC also exists for Windows: https://sourceforge.net/projects/tigervnc |
| 53 | + |
| 54 | +.. code-block:: bash |
| 55 | +
|
| 56 | + docker.exe pull leviathanch/vexiiriscv |
| 57 | + docker.exe run -v `pwd`:/work --privileged=true -idt leviathanch/vexiiriscv |
| 58 | +
|
| 59 | +After that, run the inspect command with the container ID docker returns when starting |
| 60 | +the image as a demonized process. |
| 61 | + |
| 62 | +.. code-block:: bash |
| 63 | +
|
| 64 | + docker.ext inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_id |
| 65 | +
|
| 66 | +
|
| 67 | +Next run the Tiger VNC vncviewer |
| 68 | + |
| 69 | +.. code-block:: bash |
| 70 | +
|
| 71 | + vncviewer.exe $ip |
| 72 | +
|
| 73 | +
|
| 74 | +Generating the verilog |
| 75 | +---------------------- |
| 76 | + |
| 77 | +First open the terminal by clicking the terminal icon as shown below |
| 78 | + |
| 79 | +.. image:: Screenshot_20241203_152813.png |
| 80 | + :width: 400 |
| 81 | + :alt: Shell Icon |
| 82 | + |
| 83 | +As soon as you've started the Docker container as shown above you can obtain the Verilog |
| 84 | +code by simply running the following command from within the terminal. |
| 85 | + |
| 86 | +Make sure however that you're in the proper folder |
| 87 | + |
| 88 | +.. code-block:: bash |
| 89 | +
|
| 90 | + ~/generate_verilog.sh |
| 91 | +
|
| 92 | +Take care that the path is correct, then press enter |
| 93 | + |
| 94 | +.. image:: Screenshot_20241203_165329.png |
| 95 | + :width: 400 |
| 96 | + :alt: Generate Command |
| 97 | + |
| 98 | +This script simply contains the following command: |
| 99 | + |
| 100 | +.. code-block:: bash |
| 101 | +
|
| 102 | + #!/bin/bash |
| 103 | + sbt "Test/runMain vexiiriscv.Generate" |
| 104 | +
|
| 105 | +
|
| 106 | +
|
| 107 | +After it has been running through, you should now have a file called "VexiiRiscv.v" |
| 108 | +right there in your source folder |
| 109 | + |
| 110 | +.. image:: Screenshot_20241203_152940.png |
| 111 | + :width: 400 |
| 112 | + :alt: Generation Result |
| 113 | + |
| 114 | + |
| 115 | +Running a simulation |
| 116 | +-------------------- |
| 117 | + |
| 118 | +Running a simulation also is straight forward, in the same shell as you used for generating |
| 119 | +the Verilog code. |
| 120 | + |
| 121 | +.. image:: Screenshot_20241203_165608.png |
| 122 | + :width: 400 |
| 123 | + :alt: Run simulation |
| 124 | + |
| 125 | +.. code-block:: bash |
| 126 | +
|
| 127 | + ~/run_simulation.sh |
| 128 | +
|
| 129 | +This readily available script contains the simple command |
| 130 | + |
| 131 | +.. code-block:: bash |
| 132 | +
|
| 133 | + #!/bin/bash |
| 134 | + sbt "Test/runMain vexiiriscv.tester.TestBench --with-mul --with-div --load-elf ext/NaxSoftware/baremetal/dhrystone/build/rv32ima/dhrystone.elf --trace-all" |
| 135 | +
|
| 136 | +This will run through for a moment, and should look like this, finishing without errors |
| 137 | + |
| 138 | +.. image:: Screenshot_20241203_165858.png |
| 139 | + :width: 400 |
| 140 | + :alt: Run simulation |
| 141 | + |
| 142 | +After the simulation has run through, you should now have a wave file in simWorkspace/VexiiRiscv/test/ |
| 143 | + |
| 144 | +Opening the traces with GTKWave |
| 145 | +------------------------------- |
| 146 | + |
| 147 | +You can convert the wave file from the simulation into the VCD format and view it by opening |
| 148 | +it with GTKWve, which is already installed in the Docker image. |
| 149 | + |
| 150 | +To do so, simply run in the shell |
| 151 | + |
| 152 | +.. code-block:: bash |
| 153 | +
|
| 154 | + gtkwave simWorkspace/VexiiRiscv/test/wave.fst |
| 155 | +
|
| 156 | +
|
| 157 | +This will start GTKWave. |
| 158 | + |
| 159 | +.. image:: Screenshot_20241203_170009.png |
| 160 | + :width: 400 |
| 161 | + :alt: Start GTKWave |
| 162 | + |
| 163 | +You can now select signal lines and add them to the viewer |
| 164 | + |
| 165 | +.. image:: Screenshot_20241203_170056.png |
| 166 | + :width: 400 |
| 167 | + :alt: GTKWave open |
| 168 | + |
| 169 | + |
| 170 | +Opening the traces with Konata |
| 171 | +------------------------------ |
| 172 | + |
| 173 | +In order to visualize the instruction pipeline, you may wanna open Konata. |
| 174 | +For doing so, click on the Konata icon |
| 175 | + |
| 176 | +.. image:: Screenshot_20241203_151217.png |
| 177 | + :width: 400 |
| 178 | + :alt: Konata Icon |
| 179 | + |
| 180 | +Next load the konata log by going into the folder as shown in the picture |
| 181 | + |
| 182 | +.. image:: Screenshot_20241203_151018.png |
| 183 | + :width: 400 |
| 184 | + :alt: Load konata log |
| 185 | + |
| 186 | +You should be greated with a colorful representation of the instructions |
| 187 | +in the RISC-V pipeline during boot up |
| 188 | + |
| 189 | +.. image:: Screenshot_20241203_151124.png |
| 190 | + :width: 400 |
| 191 | + :alt: Pipeline visualization |
| 192 | + |
| 193 | +Opening Intellij IDEA |
| 194 | +---------------------- |
| 195 | + |
| 196 | +First click onto the Intellij IDEA icon |
| 197 | + |
| 198 | +.. image:: Screenshot_20241203_153149.png |
| 199 | + :width: 400 |
| 200 | + :alt: Intellij IDEA: Icon |
| 201 | + |
| 202 | +Accept the terms and conditions |
| 203 | + |
| 204 | +.. image:: Screenshot_20241203_153048.png |
| 205 | + :width: 400 |
| 206 | + :alt: Intellij IDEA: Terms and conditions |
| 207 | + |
| 208 | +We don't send data |
| 209 | + |
| 210 | +.. image:: Screenshot_20241203_163222.png |
| 211 | + :width: 400 |
| 212 | + :alt: Intellij IDEA: No telemetry |
| 213 | + |
| 214 | +Load the VexiiRiscv project |
| 215 | + |
| 216 | +.. image:: Screenshot_20241203_153226.png |
| 217 | + :width: 400 |
| 218 | + :alt: Intellij IDEA: New projects |
| 219 | + |
| 220 | +Enter the folder where your cloned repo is mounted to from outside, which is |
| 221 | +configured to be /work. |
| 222 | + |
| 223 | +Then press OK |
| 224 | + |
| 225 | +.. image:: Screenshot_20241203_163411.png |
| 226 | + :width: 400 |
| 227 | + :alt: Intellij IDEA: Load Project |
| 228 | + |
| 229 | +Confirm that you trust the project |
| 230 | + |
| 231 | +.. image:: Screenshot_20241203_163438.png |
| 232 | + :width: 400 |
| 233 | + :alt: Intellij IDEA: Trust project |
| 234 | + |
| 235 | +After that it will take a while until the entire project has been loaded |
| 236 | +and indexed. Make a cup of coffee or tea in the meanwhile. |
| 237 | + |
| 238 | +Shutting down the Container |
| 239 | +--------------------------- |
| 240 | + |
| 241 | +In order to shut down the container, simply logout from XFCE4 which will |
| 242 | +make the process stop and the container terminate |
| 243 | + |
| 244 | +.. image:: Screenshot_20241203_153436.png |
| 245 | + :width: 400 |
| 246 | + :alt: Logout |
| 247 | + |
| 248 | +Confirm that you wanna log out |
| 249 | + |
| 250 | +.. image:: Screenshot_20241203_164155.png |
| 251 | + :width: 400 |
| 252 | + :alt: Confirm Logout |
| 253 | + |
| 254 | + |
| 255 | +Using the build environment |
| 256 | +--------------------------- |
| 257 | + |
| 258 | +Now that your build environment is up and running and you've got Intellij running as well as are familiar with the shell, you can now take your first dive into modifying the configurations and generating and testing your own modified version of the VexiiRiscv |
| 259 | + |
| 260 | +Here are some ideas of things to try: |
| 261 | + |
| 262 | +* How to add a custom instruction and how to test it: |
| 263 | + https://spinalhdl.github.io/VexiiRiscv-RTD/master/VexiiRiscv/Execute/custom.html |
| 264 | +* How to add that custom instruction the MicroSoc: |
| 265 | + https://spinalhdl.github.io/VexiiRiscv-RTD/master/VexiiRiscv/Soc/microsoc.html#adding-a-custom-instruction |
| 266 | +* How to export an APB3 bus from the MicroSoc toplevel: |
| 267 | + https://spinalhdl.github.io/VexiiRiscv-RTD/master/VexiiRiscv/Soc/microsoc.html#exporting-an-apb3-bus-to-the-toplevel |
0 commit comments