GHDL on Windows

Posted on December 28, 2021 in Hardware

When simulating VHDL without commercial software, there is only one solution : GHDL.
As for many free software, GHDL is very easy to install and use under Linux. With Windows, it is a bit more complicated. There are native Windows versions, but these are obsolete. The project no longer generates such versions.

The solution is to use a Linux sub-system.

I haven't tried WSL, the Linux system integrated in Windows. I don't know if it would work, but I've already had problems with other projects on WSL.
Since the GHDL project officially supports versions running on MSYS2, I naturally went this way.

Installing MSYS2 :

To install GHDL, you must therefore start by installing MSYS2.
To do this, go to the project's WEB site, download and install MSYS2.
Do not forget to follow the complete procedure for updating the system.

Installing GHDL :

With MSYS2 installed, let's move on to the installation of GHDL.

First thing to do, open a MSYS2 MSYS console from the Windows Start menu.
MSYS2 MSYS

GHDL can be installed in two different ways.

  • Using the MSYS2 package :

    To install the 64-bit version of GHDL use the following command :

    pacman -S mingw64/mingw-w64-x86_64-ghdl-llvm

    Done.

    Updates will be done with the command pacman -Syu , command that updates the whole MSYS2 system.
    The MSYS2 GHDL package is updated regularly, but not very often.
  • Using a "nightly package" generated by the GHDL project :

    Personally, I prefer this method which has the advantage of sticking to the GHDL development, and of having a much faster and lighter update process (we don't update the whole MSYS2 system).

    To do this, enter the following commands (preferably in a dedicated directory):

    wget -O mingw-w64-x86_64-ghdl-llvm-ci-1-any.pkg.tar.zst https://github.com/ghdl/ghdl/releases/download/nightly/mingw-w64-x86_64-ghdl-llvm-ci-1-any.pkg.tar.zst
    pacman -U mingw-w64-x86_64-ghdl-llvm-ci-1-any.pkg.tar.zst

    The same commands are used to update the package.
    Put these two lines in a bash file to facilitate updates.

Installing GtkWave :

GHDL allows to save the state of the signals of a simulation in a file. It is possible to choose the VCD format, which is widely used and is part of the verilog standard. With this format, you will have the choice of the waveform visualization tool, integrated to a development environment or not.

The VHDL language being richer than verilog, the VCD file format is not the most suitable for recording data from a VHDL simulation. It is preferable to use the GHDL specific format: GHW [1] .
The downside is that you don't have the choice of the visualization tool. Only GtkWave can read this format.

To install GtkWave, we have 3 possibilities :

  • Using the MSYS2 package :

    To install the 64-bit version of GtkWave the command is :

    pacman -S mingw64/mingw-w64-x86_64-gtkwave

  • Using a "nightly package" generated by the GtkWave project :

    It is possible to choose between a Gtk2 and a Gtk3 version. It is recommended to use the Gtk3 version, the Gtk2 version should disappear in the long term [2] .

    The commands are :

    wget -O mingw-w64-x86_64-gtkwave-gtk3-ci-1-any.pkg.tar.zst https://github.com/gtkwave/gtkwave/releases/download/nightly/mingw-w64-x86_64-gtkwave-gtk3-ci-1-any.pkg.tar.zst
    pacman -U mingw-w64-x86_64-gtkwave-gtk3-ci-1-any.pkg.tar.zst
  • Using a Windows native package (prefered solution) :

    With this method, we get a zip from the GtkWave project's github and unzip it into a folder.
    And that's it.
    You can find the zip files here .
    The files whose name starts with gtkwave_ are the ones we are interested in. In the screenshot below, we can see that we have the choice between a 64-bit Gtk2 version and two Gtk3 versions (32-bit and 64-bit). The actual list can be different.
MSYS2 MSYS

The GHW file format is not fixed. It happens (rarely) that an evolution of GHDL requires a modification of the data structure of this file format. It will then be necessary to update GtkWave (the import of GHW files into GtkWave is managed by the GHDL developers).

Using GHDL :

There are two ways to use GHDL.

  • The first is to use the MSYS2 MinGW 64-bit console

    MSYS2 MSYS

    In this console, all GHDL commands work directly. It is possible to access Windows files directly. For example, if your project is in D:\my_project , you just have to do cd /d/my_project to get to the right folder.

  • The second way is to use a standard Windows command line and modify the PATH accordingly with the following command:

    PATH=C:\msys64\mingw64\bin;%PATH%

    It is also possible to run GHDL commands directly from other tools, such as an Integrated Development Environment, as long as the PATH is properly modified.

Eclipse PATH

Modification of the PATH for a launch configuration in Eclipse.

Using GtkWave :

If you have chosen an integrated version of MSYS2, it is possible to create a shortcut on the desktop :

GtkWave Shortcut

Configuration of a shortcut for GtkWave integrated in MSYS2.

If you have chosen a "native Windows " version, you just need to create a shortcut on gtkwave.exe.
In the following example, the GtkWave package has been unzipped in the folder C:\GtkWave_Gtk3" .
GtkWave Shortcut

Configuration of a shortcut for a "Windows native" GtkWave.

To view a GHW file, simply Drag & Drop the file onto the shortcut icon.






[1]To generate files in GHW format, the option --wave=my_waveform.ghw must be used during the simulation phase.
[2]At the time of writing, the Gtk3 version has display performance problems.


Translated with the help of www.DeepL.com/Translator (free version)