Chisel is a Domain Specific Hardware Description Language developed at UC Berkeley. It is embedded in Scala which uses the sbt build tool and package manager to manage dependencies.
sbt
automatically downloads everything you need, including the exact version
of sbt
itself that you need for the project.
Thus the only thing you need for Chisel
and Scala
is to installsbt
.
Follow the instructions in the
official installation guide.
In order to simulate the low level Verilog
code generated by Chisel
you need the open source circuit simulator
verilator.
At least version 3.886
is required.
On Fedora 27, you can install version 3.890
from the default repositories.
On a recent Ubuntu 17.04
or Ubuntu 17.10 version 3.9
is available from the default repositories.
If your distribution does not offer a recent version of verilator
,
you can compile it yourself by following the
Chisel Readme.
You can test your installation by running the chisel
tests:
- change to the
chisel
directory in this repository:> cd chisel
- launch
sbt
:> sbt
- once
sbt
is booted, run the tests:sbt:queue> test
- The first test
(with firrtl)
should succeed if you have installedsbt
andChisel
is able to run on your system correctly. - The second test
(with verilator
) will succeed if yourverilator
installation is working.
We recommend using version 2017.3
which can be downloaded directly from
Xilinx.
Use the All OS installer Single-File Download
which has proven to be reliable.
In the explaination below we assume that you want to install Vivado into a
user writable directory instead of a system directory.
We use /home/kevin/xilinx_test
as the example path.
If you want to install to e.g. /opt
, you need to launch xsetup
with sudo
.
- extract the Vivado files:
tar -xf Xilinx_Vivado_SDK_2017.3_1005_1.tar.gz
- change into the extracted directory and launch
./xsetup
- click
next
- accept all three license agreements and click
next
- select
Vivado HL WebPack
(this is the free - as in beer - version) and clicknext
- we only need
Vivado
andZynq-7000
support: - click
next
- select the installation directory. We recommend to deselect all shortcut options on the right:
- review your selection and install
- wait until you see the
Installation completed successfully.
promt.
By default, Vivado does not know about the PYNQ
board that we are using.
Luckily, digilent
provides a board description file for the very similar
arty-z7-20
board.
- Checkout the
digilent
board files repository:git clone https://github.com/Digilent/vivado-boards.git
Alternatively you can download and extract the ZIP file:wget https://github.com/Digilent/vivado-boards/archive/master.zip
- Copy the
arty-z7-20
board file into your Vivado installation, e.g.:cp new/board_files/arty-z7-20 /home/kevin/xilinx_test/Vivado/2017.3/data/boards/board_files -r
To be able to use Vivado, a free (as in beer) license needs to be requested using a Xilinx account and then installed.
- Launch Vivado:
source /home/kevin/xilinx_test/Vivado/2017.3/settings64.sh && vivado
- Launch the
License Manager
by clicking onHelp -> Manage License
- Got to the
Optain License
tab, selectGet Free WebPack [...]
and click onConnect Now
- If this does not work, try
Save Link As
and manually navigate to the website. - Follow the instructions on the Xilinx website to optain a
Xilinx.lic
file. - Go to the
Load License
tab and click onCopy License
. - Navigate to the
Xilinx.lic
file that you downloaded in step 5 and select it. - After the success promt, you can exit the
License Manager
and then exit the Vivado GUI.
This requires that you have installed and tested Chisel
.
- change to the
chisel
directory in this repository:> cd chisel
- launch
sbt
:> sbt
- once
sbt
is booted, generate the low levelVerilog
inchisel/ip
:sbt:queue> run
- quit
sbt
- change to the root directory in this repository:
> cd ..
- load Vivado:
source /home/kevin/xilinx_test/Vivado/2017.3/settings64.sh
- synthesize the example design and generate the bitstream:
make
- if this succeeds, your
Vivado
andChisel
installation are working
In order to control the circuits on the FPGA, we will use the modern
systems programming language Rust.
Compared to C
, Rust
offers modern programming features such as
traits,
pattern matching,
a module system,
a collections library
and much more.
Whereas a lot of programs written in C
or C++
suffer from memory errors,
the Rust
compiler can prove at compile time, that our code is free of these
errors.
Rust
is a better fit for system programming compared to Python
or
Java
, since it compiled into a single static binary without any
complicated runtime requirements (such as a garbage collector).
The recommended way of installing rust is to use the rustup
tool.
Just follow their installation instructions.
We will be targeting the ARMv7
core on the Zynq
chip to run our program on.
For this purpose we need to install a rust toolchain that compile to this
target:
> rustup target add armv7-unknown-linux-gnueabihf
This installs the rust compiler for the armv7
target, however,
we still need a linker. For this purpose you need to install
the gcc
cross compile toolchain for this target.
On Fedora you can find a compatible toolchain on copr.
On Ubuntu you can just install the gcc-arm-linux-gnueabihf
package.
More details are explained in this readme,
but please be aware that creating a .cargo
configuration is not needed
since we include a local version in this repository.
To test whether your Rust
installation can cross compile our code:
- change to the
control
directory in this repository:> cd control
- build the application:
> cargo build --target=armv7-unknown-linux-gnueabihf
- make a release build:
> cargo build --target=armv7-unknown-linux-gnueabihf --release
- if there are no error, you are ready to test the application on the FPGA
In order to experiment with and learn Chisel
without an FPGA at hand,
you can checkout the Jupyter
notebooks that were created by folks at
Berkeley as interactive teaching material.
Just follow their installation guide.