F P G A   




 Limerick(3) - SpinalHDL Tutorial: Setting up the Development Environment 2/25/2023



Hello, everyone. Welcome to the third episode of FPGA limerick. In this episode, we will get hands-on for SpinalHDL, starting by setting up the Development Environment.

Setup for Windows/MSYS2

As mentioned in the first episode, we will use Windows 11 + MSYS2 + WSL2 as our host platform. And we will start by MSYS2 first. To install MSYS2, please open your browser and go to https://www.msys2.org/

And at this point, we will install the following version for MSYS2:

https://github.com/msys2/msys2-installer/releases/download/2023-01-27/msys2-x86_64-20230127.exe

After the MSYS2 is installed, it needs to be setup for additional packages. Please open the MSYS2 MINGW64 from Windows Start Menu, and type in the following:

pacman -Syuu

After this command, the MSYS2 window will be closed automatically.

Please reopen it through Windows Start Menu (Please choose MSYS2 MINGW64 again), and type in

pacman -Syuu

again. Then please type in the following:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain git flex mingw-w64-x86_64-cmake

One thing I want to mention is that you will find similar steps on SpinalHDL’s official website. But it seems those steps on the official website is not up-to-date. So please follow the steps listed above exactly. This is especially true for the last step above when you try to install verilator.

Ok. Now after the last step to install verilator, you can close the MSYS2 window, and the put the following two paths in the system path:

C:\msys64\usr\bin
C:\msys64\mingw64\bin

(From the start menu, you can choose settings / system / about / advanced system settings, then choose environment variables

Double-click the path in system variables, click new and copy paste those two paths. Please make sure those two paths are at the top of the list.)


Setup for Windows/SBT 

Now, at this point, we are done with the MSYS2.  And next we will install the SBT. Please open your browser and go to https://www.scala-sbt.org/

And currently we are using SBT 1.8.2 for Windows, which can be directly downloaded from the following path:

https://github.com/sbt/sbt/releases/download/v1.8.2/sbt-1.8.2.msi

Just run the installer, click “More info” and then click “Run anyway”.

And the installer will add sbt executable to the system path automatically. 


Setup for Windows/JDK

After the SBT is installed, the next is to install JDK. The JDK can be downloaded from the following path:

https://www.oracle.com/java/technologies/downloads/

For Windows, we currently use JDK19, which can be downloaded directly from

https://download.oracle.com/java/19/latest/jdk-19_windows-x64_bin.msi

And after installation of the JDK, please add the following path to the system path (like what we did early for MSYS2):

C:\Program Files\Java\jdk-19\bin


Test with Hello World example

Now, at this point, we should be able to run the SBT in command line and compile the SpinalHDL source code. For this purpose, we have got a HelloWorld example in the GitHub repo.

Please open a command prompt and use the following command to check out the GitHub repo for FPGA Limerick

git clone --depth 1 --branch v1.0.0 https://github.com/PulseRain/FpgaLimerick.git

cd FpgaLimerick

cd HelloWorld

sbt

If everything is setup correctly, it will show something like:

C:\GitHub\FpgaLimerick\HelloWorld>sbt
[info] welcome to sbt 1.8.2 (Oracle Corporation Java 19.0.2)
[info] loading global plugins from C:\Users\chang\.sbt\1.0\plugins
[info] loading settings for project helloworld-build from plugins.sbt ...
[info] loading project definition from C:\GitHub\FpgaLimerick\HelloWorld\project
[info] loading settings for project helloworld from build.sbt ...
[info] set current project to helloworld (in build file:/C:/GitHub/FpgaLimerick/HelloWorld/)
[info] sbt server started at local:sbt-server-e926ab8ee3957332f208
[info] started sbt server
sbt:helloworld> run
[info] compiling 4 Scala sources to C:\GitHub\FpgaLimerick\HelloWorld\target\scala-2.12\classes ...
[warn] 6 feature warnings; re-run with -feature for details
[warn] one warning found

Multiple main classes detected. Select one to run:
 [1] com.pulserain.fpga.NcoCounter
 [2] com.pulserain.fpga.NcoCounterSim


Choose option 2 to run the simulation in verilator. And you are supposed to see the following output:

Enter number: 2
[info] running (fork) com.pulserain.fpga.NcoCounterSim
[info] [Runtime] SpinalHDL v1.8.0    git head : 4e3563a282582b41f4eaafc503787757251d23ea
[info] [Runtime] JVM max memory : 10144.0MiB
[info] [Runtime] Current date : 2023.02.25 17:26:48
[info] [Progress] at 0.000 : Elaborate components
[info] [Progress] at 0.484 : Checks and transforms
[info] [Progress] at 0.564 : Generate Verilog
[info] [Done] at 0.645
[info] [Progress] Simulation workspace in C:\GitHub\FpgaLimerick\HelloWorld\.\simWorkspace\NcoCounter
[info] [Progress] Verilator compilation started
[info] [Progress] Verilator compilation done in 8036.094 ms
[info] [Progress] Start NcoCounter test simulation with seed 924781703
[info] =========== start
[info] =========== done
[info] ==== measured 240000 / 1000001 = 23.999976 MHz, expected 24.000000 MHz
[info] === Output clock is accurate enough!
[info] [Done] Simulation done in 6882.373 ms
[success] Total time: 29 s, completed Feb 25, 2023, 5:27:04 PM
sbt:helloworld>

 

If you see this, congratulation! You have setup the SBT and Verilator correctly on Windows!


Setup for Linux

We will talk about the Linux setup in later episodes when we get to the cocotb. However, if you are really itchy to try it out on Linux, you can start by the following:

Use WSL (Windows Subsystem for Linux), set up the distro as:

wsl --install -d Ubuntu-20.04

In other words, please use Ubuntu 20.04 LTS.

And please run the setup script in FpgaLimerick/HelloWorld/script/wsl_setup.sh to install the necessary packages, including verialtor and questa.

Although this script has only been verified on WSL, I believe it can also be applied on the native version of Ubuntu 20.04 LTS.

    Posted by FPGA Limerick at February 25, 2023

2 Comments:

  • On September 10, 2024 at 8:33 PM, Blogger sidhisudia  Said

    pacman -U https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-verilator-4.228-1-any.pkg.tar.zst

    this link does not work, it returns 404

     

  • On October 5, 2024 at 4:14 AM, Blogger sidhisudia  Said

    updated verilator link: https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-verilator-5.004-1-any.pkg.tar.zst

     

Post a Comment

<< Home  

   

 

    

README

*) Legal Disclaimer
*) Introduction

Links

*) GitHub Repo
*) YouTube
*) reddit
*) SpinalHDL
*) cocotb


*) FCC Wireless
*) ARRL
*) PAPA System
*) EARS