Skip to content

Commit d8f430d

Browse files
Update installation instructions
1 parent e160aa3 commit d8f430d

File tree

7 files changed

+194
-66
lines changed

7 files changed

+194
-66
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ docs/*
88
*.bin
99
.cache/
1010
.venv*/
11+
12+
# artifacts from compiling the examples
13+
examples/project
14+
.metals
15+
.scala-build
16+
.bsp

source/SpinalHDL/Getting Started/Install and setup.rst

Lines changed: 166 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,91 @@
33
Install and setup
44
=================
55

6-
Spinal is a Scala library so it requires setting up a Scala environment; there
7-
are many ways to do so. Also, it generates VHDL, Verilog or SystemVerilog, which
8-
can be used by many different tools. This section describes the supported way to
9-
install a *SpinalHDL description to Simulation* flow, but there can be many
10-
variations.
6+
Spinal is a Scala library (a programming language using the Java VM) so it
7+
requires setting up a Scala environment; there are many ways to do so.
8+
Also, it generates VHDL, Verilog or SystemVerilog, which can be used by many
9+
different tools. This section describes the supported way to install a
10+
*SpinalHDL description to Simulation* flow, but there can be many variations.
1111

12-
13-
Mandatory requirements
14-
----------------------
12+
Required/Recommended tools
13+
--------------------------
1514

1615
Before you download the SpinalHDL tools, you need to install a Scala environment:
1716

1817
* `Java JDK <https://www.oracle.com/java/technologies/downloads/>`_, a Java
1918
environment
19+
* `Scala 2 <https://www.scala-lang.org/>`_, compiler and library
2020
* `SBT <https://www.scala-sbt.org/download.html>`_, a Scala build tool
2121

2222
These tools enable to use Spinal; but without any other tools, it is limited to
23-
code generation.
23+
HDL code generation.
24+
25+
To enable more features we recommend:
26+
27+
* An IDE (for instance the currently recommended `IntelliJ <https://www.jetbrains.com/idea/>`_
28+
with its Scala plugin or `VSCodium <https://vscodium.com/>`_ with Metals extension) to
29+
get features such as:
30+
31+
* Code suggestions / completion
32+
* Automatic build with syntax errors right in the code
33+
* Generate code with a single click
34+
* Run simulation / tests with a single click (if a supported simulator is
35+
set up)
36+
37+
* A supported simulator like `Verilator <https://www.veripool.org/verilator/>`_
38+
to test the design right from SpinalHDL.
39+
* `Gtkwave <https://gtkwave.sourceforge.net/>`_ to view the waves generated by
40+
Verilator during simulation.
41+
* `Git <https://git-scm.com/>`_ for version control system
42+
* A C++ toolchain, needed for simulating with Verilator
43+
* A linux shell, needed for simulating with Verilator
2444

2545
Linux Installation
26-
----------------------
46+
------------------
2747

28-
For instance, to install them on the Debian distribution:
48+
At time of writing the recommended way of installing Scala and SBT is via `Coursier <https://get-coursier.io/docs/cli-installation>`_.
49+
Coursier is able to in addition to the scala tools install a Java JDK to use, in the
50+
example below we install Java from the package manager. We recommend to install JDK 17 (LTS)
51+
because of compatibility with the used Scala version.
52+
53+
For Debian or Ubuntu we run:
2954

3055
.. code-block:: sh
3156
32-
sudo apt-get install openjdk-8-jdk
33-
sudo apt-get install scala
34-
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
35-
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
36-
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
3757
sudo apt-get update
38-
sudo apt-get install sbt
58+
sudo apt-get install openjdk-17-jdk-headless curl git
59+
curl -fL "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" | gzip -d > cs
60+
chmod +x cs
61+
# should find the just installed jdk, agree to cs' questions for adding to your PATH
62+
./cs setup
63+
source ~/.profile
64+
65+
If you want to install the tools for simulation and/or formal proofs, we recommend `oss-cad-suite <https://github.com/YosysHQ/oss-cad-suite-build>`_.
66+
It contains a waveform viewer (gtkWave), verilog simulators (verilator and iverilog), VHDL simulator (GHDL) and other tools.
67+
In case you want to build the tools yourself have a look at the legacy simulation tool :ref:`installation instructions <sim backend install>`.
68+
69+
We first install the needed C++ toolchain and download oss-cad-suite. To use it we must load the oss-cad-suite
70+
environment for each shell we want to use it in. Note that oss-cad-suite contains a Python 3 interpreter that
71+
may interfere with the system Python installation if loaded permanently.
72+
73+
Go to the oss-cad-suite `release page <https://github.com/YosysHQ/oss-cad-suite-build/releases/latest>`_ to get the
74+
download link for the latest version. You can download/extract oss-cad-suite to a folder of your choice.
75+
(last tested version of oss-cad-suite is `2023-10-22`, but more recent ones will most likely also work)
76+
77+
.. code-block:: sh
78+
79+
sudo apt-get install make gcc g++ zlib1g-dev
80+
curl -fLO <download link>
81+
tar xzf <file that you downloaded>
82+
83+
To use oss-cad-suite in a shell you need to load it's environment, e.g. via ``souce <path to oss-cad-suite>/environment``.
84+
3985

4086
Mac OS X Installation
4187
----------------------
4288
You can use homebrew to install on Mac OS X. By default homebrew installs Java 21, but the SpinalHDL tutorial
43-
SpinalTemplateSbt uses Scala version 2.12.16, which is not supported by Java 21 (17 is still the recommended LTS version, https://whichjdk.com/). So to install Java version 1.7 do:
89+
SpinalTemplateSbt uses Scala version 2.12.16, which is not supported by Java 21 (17 is still the recommended LTS version,
90+
https://whichjdk.com/). So to install Java version 1.7 do:
4491

4592
.. code-block:: sh
4693
@@ -52,7 +99,7 @@ And then add this to your path.
5299
53100
export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"
54101
55-
To manage multiple versions of Java, it is also essential to have jenv installed.
102+
To manage multiple versions of Java it is also essential to have jenv installed.
56103

57104
.. code-block:: sh
58105
@@ -73,64 +120,125 @@ Next you have to install scala's interactive build tool sbt.
73120
74121
If this works for you, please let us know. If this does not work for you, you can read the github issue about Mac o SX installation here.
75122
https://github.com/SpinalHDL/SpinalHDL/issues/1216
76-
77-
Installing SBT in an internet-free environment
78-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123+
124+
If you want to install the tools for simulation and/or formal proofs, we recommend `oss-cad-suite <https://github.com/YosysHQ/oss-cad-suite-build>`_.
125+
126+
Windows installation
127+
--------------------
79128

80129
.. note::
81-
If you do not need this, you can skip to the next section:
82-
:ref:`recommended`.
130+
While a native installation is possible the simpler and currently recommended way is to use WSL on Windows.
131+
If you want to use WSL, install `it <https://learn.microsoft.com/en-us/windows/wsl/install>`_, a distribution of your choice and
132+
follow the Linux installation instructions. Data in your WSL instance can be accessed from windows under ``\\wsl$``.
133+
In case you want to use IntelliJ you'll have to download the Linux version to WSL, if you want to use VSCode then the Windows
134+
version can be used to remotely edit in WSL.
83135

84-
Normally, SBT uses online repositories to download and cache your projects
85-
dependencies. This cache is located in several folders:
136+
At time of writing the recommended way of installing Scala and SBT is via `Coursier <https://get-coursier.io/docs/cli-installation>`_.
137+
Coursier is able to in addition to the scala tools install a Java JDK to use, in the
138+
example below we install Java manually. We recommend to install JDK 17 (LTS) because of
139+
compatibility with Scala.
86140

87-
* ``~/.sbt``
88-
* ``~/.cache/JNA``
89-
* ``~/.cache/coursier``
141+
First download and install `Adoptium JDK 17 <https://adoptium.net/temurin/releases/?os=windows&version=17>`_.
142+
Download, unzip and run the `Coursier installer <https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-win32.zip>`_,
143+
when asked agree to an update of your ``PATH`` variable. Reboot to force an update of ``PATH``.
90144

91-
To set up an internet-free environment, you can:
145+
This is sufficient for generating hardware. For simulation continue with either choice below.
146+
In case you want to build the tools yourself have a look at the legacy simulation tool :ref:`installation instructions <sim backend install>`.
92147

93-
#. Set up an environment with internet
94-
#. Launch a Spinal command (see :ref:`Using SBT`) to fetch dependencies (for
95-
instance using the `getting started
96-
<https://github.com/SpinalHDL/SpinalTemplateSbt>`_ repository)
97-
#. Copy the caches to the internet-free environment.
148+
MSYS2 verilator for simulation
149+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98150

99-
.. note::
100-
You can get a portable SBT setup here: https://www.scala-sbt.org/download.html
151+
We recommend to install compiler/verilator through `MSYS2 <https://www.msys2.org>`.
152+
Other methods of installing gcc/make/shell (e.g. chocolatey, scoop, etc.) may also work but are untested.
101153

102-
.. note::
103-
You might be interested in `SpinalNomad <https://github.com/SpinalHDL/SpinalNomad/tree/main/sbt>`_.
154+
SpinalHDL maintainer `Readon <https://github.com/Readon>` is maintaining a MSYS2 fork that default
155+
installs all needed officially available and custom built packages (also maintained by Readon `here <https://github.com/Readon/MINGW-SpinalHDL>`)
156+
for simulation and formal verification. It can be found `here <https://github.com/Readon/msys2-installer>`.
157+
If used then the packages installed below via ``pacman`` are already installed and those
158+
installation steps can be skipped.
104159

160+
Currently verilator 4.228 is latest available version known to work.
105161

106-
.. _recommended:
162+
Download the latest installer and install MSYS2 with default settings. You should get a MSYS2 terminal at
163+
the end of the installation, there run:
107164

108-
Recommended requirements
109-
------------------------
165+
.. code-block:: sh
110166
111-
To enable more features:
167+
pacman -Syuu
168+
# will (request) close down terminal
169+
# open 'MSYS2 MINGW64' from start menu
170+
pacman -Syuu
171+
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-iverilog mingw-w64-x86_64-ghdl-llvm git
172+
curl -O https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-verilator-4.228-1-any.pkg.tar.zst
173+
pacman -U mingw-w64-x86_64-verilator-4.228-1-any.pkg.tar.zst
112174
113-
* An IDE (for instance `IntelliJ <https://www.jetbrains.com/idea/>`_ with its
114-
Scala plugin or `VSCodium <https://vscodium.com/>`_ with Metals extension) to
115-
get features such as:
175+
In a MSYS2 MINGW64 terminal we need to set some environment variables to make Java/sbt available (you can make these
176+
settings persistent by adding them to ``~/.bashrc`` in MSYS2):
116177

117-
* Code suggestions / completion
118-
* Automatic build with syntax errors right in the code
119-
* Generate code with a single click
120-
* Run simulation / tests with a single click (if a supported simulator is
121-
set up)
178+
.. code-block:: sh
122179
123-
* A supported simulator like `Verilator <https://www.veripool.org/verilator/>`_
124-
to test the design right from SpinalHDL.
125-
* `Gtkwave <https://gtkwave.sourceforge.net/>`_ to view the waves generated by
126-
Verilator during simulation.
127-
* `Git <https://git-scm.com/>`_ for version control system
180+
export VERILATOR_ROOT=/mingw64/share/verilator/
181+
export PATH=/c/Program\ Files/Eclipse\ Adoptium/jdk-17.0.8.101-hotspot/bin:$PATH
182+
export PATH=/c/Users/User/AppData/Local/Coursier/data/bin:$PATH
183+
184+
With this you should be able to run sbt/verilator simulations from MSYS2 terminals (sbt via calling ``sbt.bat``).
185+
186+
MSYS2 for formal verification
187+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
188+
189+
In addition to the steps above we also need to install yosys, sby, z3 and yices. Both yosys and sby are
190+
not available as official MSYS2 packages, but packages are provided by `Readon <https://github.com/Readon>`.
191+
If you used their installer then these steps are not needed (you should check if there are newer packages available).
192+
193+
.. code-block:: sh
194+
195+
pacman -S mingw-w64-x86_64-z3 mingw-w64-x86_64-yices mingw-w64-x86_64-autotools
196+
curl -O https://github.com/Readon/MINGW-SpinalHDL/releases/download/v0.4.9/mingw-w64-x86_64-yosys-0.31-1-any.pkg.tar.zst
197+
curl -O https://github.com/Readon/MINGW-SpinalHDL/releases/download/v0.4.9/mingw-w64-x86_64-python-sby-0.31-1-any.pkg.tar.zst
198+
pacman -U --noconfirm --root *-yosys-*.pkg.tar.*
199+
pacman -U --noconfirm --root *-python-sby-*.pkg.tar*
200+
201+
OCI Container
202+
-------------
128203

204+
A container for SpinalHDL development is available as well.
205+
The container is hosted at ``ghcr.io/spinalhdl/docker:master`` and can be used with Docker/Podman/Github Codespaces.
206+
It is used for the SpinalHDL CI regression and can therefore be an easy way to run the CI commands locally.
207+
208+
To run the container run e.g. ``podman run -v .:/workspace -it ghcr.io/spinalhdl/docker:master`` in a SpinalHDL project
209+
root directory, making the project directory available in ``/workspace``.
210+
211+
Please consult the documentation of you Distribution (Linux, WSL) or Docker (Windows) on how to install the container
212+
runtime you want to use. Multiple editors/IDEs (e.g. VSCode, IntelliJ, Neovide) allow for remote development in a container.
213+
Please consult the documentation of the editor on how to do remote development.
214+
215+
Installing SBT in an internet-free Linux environment
216+
----------------------------------------------------
217+
218+
.. note::
219+
If you are not using an air-gapped environment we recommend to
220+
go with the normal linux installation. (which is a subset of the
221+
installation for an air-gapped environment)
222+
223+
Normally, SBT uses online repositories to download and cache your projects
224+
dependencies. This cache is located in several folders:
225+
226+
* ``~/.sbt``
227+
* ``~/.cache/JNA``
228+
* ``~/.cache/coursier``
229+
230+
To set up an internet-free environment, you can:
231+
232+
#. Set up an environment with internet (see above)
233+
#. Launch a Spinal command (see :ref:`Using SBT`) to fetch dependencies (for
234+
instance using the `getting started
235+
<https://github.com/SpinalHDL/SpinalTemplateSbt>`_ repository)
236+
#. Copy the caches to the internet-free environment.
129237

130238
.. _template:
131239

132-
Create a SpinalHDL project
133-
--------------------------
240+
Create a first SpinalHDL project
241+
================================
134242

135243
We have prepared a ready-to-go project for you the: `getting started <https://github.com/SpinalHDL/SpinalTemplateSbt>`_ repository.
136244

source/SpinalHDL/Simulation/index.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
Simulation
33
==========
44

5-
As always, you can use your standard simulation tools to simulate the VHDL/Verilog generated by SpinalHDL. However, since SpinalHDL 1.0.0, the language integrates an API to write testbenches and test your hardware directly in Scala. This API provides the capabilities to read and write the DUT signals, fork and join simulation processes, sleep and wait until a given condition is reached. Therefore, using SpinalHDL's simulation API, it is easy to integrate testbenches with the most common Scala unit-test frameworks.
5+
As always, you can use your standard simulation tools to simulate the VHDL/Verilog generated by SpinalHDL.
6+
However, since SpinalHDL 1.0.0, the language integrates an API to write testbenches and test your hardware
7+
directly in Scala. This API provides the capabilities to read and write the DUT signals, fork and join
8+
simulation processes, sleep and wait until a given condition is reached. Therefore, using SpinalHDL's
9+
simulation API, it is easy to integrate testbenches with the most common Scala unit-test frameworks.
610

711
To be able to simulate user-defined components, SpinalHDL uses external HDL simulators as backend. Currently, four simulators are supported:
812

@@ -12,7 +16,7 @@ To be able to simulate user-defined components, SpinalHDL uses external HDL simu
1216
- `VCS <https://www.synopsys.com/verification/simulation/vcs.html>`_ **(experimental, since SpinalHDL 1.7.0)**
1317
- `XSim <https://www.google.com/search?q=site%3Axilinx.com+xsim>`_ **(experimental, since SpinalHDL 1.7.0)**
1418

15-
With external HDL simulators it is possible to directly test the generated HDL sources without increasing the SpinalHDL codebase complexity.
19+
With external HDL simulators it is possible to directly test the generated HDL sources without increasing the SpinalHDL codebase complexity.
1620

1721
.. toctree::
1822
:hidden:

source/SpinalHDL/Simulation/install/GHDL.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Setup and installation of GHDL
33
==============================
44

5+
.. note::
6+
If you installed the recommended oss-cad-suite during SpinalHDL :ref:`setup <Install>` you
7+
can skip the instructions below - but you need to activate the oss-cad-suite environment.
8+
59
Even though GHDL is generally available in linux distributions package system, SpinalHDL depends on bugfixes of GHDL codebase that were added after the release of GHDL v0.37. Therefore it is reccomended to install GHDL from source.
610
The C++ library boost-interprocess, which is contained in the libboost-dev package in debian-like distributions, has to be installed too. boost-interprocess is required to generate the shared memory communication interface.
711

source/SpinalHDL/Simulation/install/Icarus Verilog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Setup and installation of Icarus Verilog
33
========================================
44

5+
.. note::
6+
If you installed the recommended oss-cad-suite during SpinalHDL :ref:`setup <Install>` you
7+
can skip the instructions below - but you need to activate the oss-cad-suite environment.
8+
59
In most recent linux distributions, a recent version of Icarus Verilog is generally available through the package system.
610
The C++ library boost-interprocess, which is contained in the libboost-dev package in debian-like distributions, has to be installed too. boost-interprocess is required to generate the shared memory communication interface.
711

source/SpinalHDL/Simulation/install/Verilator.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Setup and installation of Verilator
33
===================================
44

5+
.. note::
6+
If you installed the recommended oss-cad-suite during SpinalHDL :ref:`setup <Install>` you
7+
can skip the instructions below - but you need to activate the oss-cad-suite environment.
58

69
SpinalSim + Verilator is supported on both Linux and Windows platforms.
710

@@ -57,7 +60,7 @@ In order to get SpinalSim + Verilator working on Windows, you have to do the fol
5760
* Install `MSYS2 <https://www.msys2.org/>`_
5861
* Via MSYS2 get gcc/g++/verilator (for Verilator you can compile it from the sources)
5962
* Add ``bin`` and ``usr\bin`` of MSYS2 into your windows ``PATH`` (ie : ``C:\msys64\usr\bin;C:\msys64\mingw64\bin``)
60-
* Check that the JAVA_HOME environnement variable point to the JDK installation folder (ie : ``C:\Program Files\Java\jdk-13.0.2``)
63+
* Check that the JAVA_HOME environment variable points to the JDK installation folder (i.e.: ``C:\Program Files\Java\jdk-13.0.2``)
6164

6265
Then you should be able to run SpinalSim + Verilator from your Scala project without having to use MSYS2 anymore.
6366

source/SpinalHDL/Simulation/install/index.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
Installation instructions
2-
=========================
3-
4-
Scala
5-
^^^^^
1+
SBT setup for simulation
2+
========================
63

74
To enable SpinalSim, the following lines have to be added in your build.sbt file :
85

@@ -17,6 +14,8 @@ Also the following imports have to be added in testbenches sources :
1714
import spinal.core._
1815
import spinal.core.sim._
1916
17+
.. _sim backend install:
18+
2019
Backend-dependent installation instructions
2120
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2221

0 commit comments

Comments
 (0)