Install and setup¶
Spinal is a Scala library so it requires setting up a Scala environment; there are many ways to do so. Also, it generates VHDL, Verilog or SystemVerilog, which can be used by many different tools. This section describes the supported way to install a SpinalHDL description to Simulation flow, but there can be many variations.
Before you download the SpinalHDL tools, you need to install a Scala environment:
For instance, to install them on the Debian distribution:
sudo apt-get install openjdk-8-jdk sudo apt-get install scala echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add sudo apt-get update sudo apt-get install sbt
These tools enable to use Spinal; but without any other tools, it is limited to code generation.
Installing SBT in an internet-free environment¶
If you do not need this, you can skip to the next section: Recommended requirements.
Normally, SBT uses online repositories to download and cache your projects dependencies. This cache is located in several folders:
To set up an internet-free environment, you can:
Set up an environment with internet
Launch a Spinal command (see Using Spinal from CLI with SBT) to fetch dependencies (for instance using the getting started repository)
Copy the caches to the internet-free environment.
You can get a portable SBT setup here: https://www.scala-sbt.org/download.html
You might be interested in SpinalNomad.
To enable more features:
An IDE (for instance IntelliJ with its Scala plugin or VSCodium with Metals extension) to get features such as:
Code suggestions / completion
Automatic build with syntax errors right in the code
Generate code with a single click
Run simulation / tests with a single click (if a supported simulator is set up)
A supported simulator like Verilator to test the design right from SpinalHDL.
Gtkwave to view the waves generated by Verilator during simulation.
Git for version control system
Create a SpinalHDL project¶
We have prepared a ready-to-go project for you the: getting started repository.
You can download it, or clone it.
The following commands clone the project into a new directory named
MySpinalProject and initialize a fresh
git clone --depth 1 https://github.com/SpinalHDL/SpinalTemplateSbt.git MySpinalProject cd MySpinalProject rm -rf .git git init git add . git commit -m "Initial commit from template"
The directory structure of a project¶
The structure described here is the default structure, but it can be easily modified.
In the root of the project are the following files:
Scala configuration for
Scala configuration for
The folder containing hardware descriptions
More Scala configuration
List of files to ignore in versioning
More configuration for
Configuration of rules to auto-format the code
As you probably guessed it, the interesting thing here is
hw/. It contains
vhdl/ for your IPs and
for IPs generated with Spinal.
hw/spinal/ contains a folder named after your project name. This name must
be set in
build.sbt (along with the company name) and in
it must be the one in
package yourprojectname at the beginning of
hw/spinal/yourprojectname/, are the descriptions of your IPs, simulation
tests, formal tests; and there is
Config.scala, which contains the
sbt must be used only at the root of the project, in the folder
Using Spinal on SpinalHDL code¶
Now the tutorial shows how to use Spinal on SpinalHDL code depending on your development environment: