Skip to content

Instantly share code, notes, and snippets.

@sgherbst
Created March 11, 2019 13:32
Show Gist options
  • Select an option

  • Save sgherbst/036456f807dc8aa84ffb2493d1536afd to your computer and use it in GitHub Desktop.

Select an option

Save sgherbst/036456f807dc8aa84ffb2493d1536afd to your computer and use it in GitHub Desktop.
Installing Verilator on Windows 10 using a fresh MSYS2 install
  1. Download and install MSYS2: https://sourceforge.net/projects/msys2/
  2. Open MSYS2 shell and run pacman -Syu
  3. After some time you will be prompted to close the MSYS2 shell by clicking the "X" button, which you should do :-)
  4. Relaunch MSYS2 shell and run pacman -Su
  5. Install the required packages for Verilator:
> pacman -S git make autoconf gcc flex bison man perl
  1. Clone the Verilator source and build the latest stable release:
> git clone http://git.veripool.org/git/verilator
> unset VERILATOR_ROOT
> cd verilator
> git checkout stable
> autoconf
> ./configure
> make
  1. Test Verilator:
> make test
  1. If the tests pass, install Verilator. Note that sudo is not used here since this is MSYS2, and that the PATH variable is updated so that the installer can find pod2man:
> PATH="/usr/bin/core_perl:${PATH}"
> make install
@harry-commin-enclustra
Copy link

harry-commin-enclustra commented Apr 17, 2024

I also get fatal error: FlexLexer.h: No such file or directory.

The spinalhdl link is dead and I didn't understand the comment about python3. What is the solution?

Edit: It looks like the spinalhdl link has moved to here:
https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Simulation/install/Verilator.html

Here is a copy-paste of their full instructions for installing from source:

pacman -Syuu
# Close the MSYS2 shell once you're asked to
pacman -Syuu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain \
                   git flex\
                   mingw-w64-x86_64-cmake

git clone http://git.veripool.org/git/verilator
unset VERILATOR_ROOT
cd verilator
git pull
git checkout v4.218   # Can use newer v4.228 and v5.xxx
autoconf
./configure
export CPLUS_INCLUDE_PATH=/usr/include:$CPLUS_INCLUDE_PATH
export PATH=/usr/bin/core_perl:$PATH
cp /usr/include/FlexLexer.h ./src

make -j$(nproc)
make install
echo "DONE"
# Add C:\msys64\usr\bin;C:\msys64\mingw64\bin to your Windows PATH

I guess the relevant part is to do this after ./configure:

export CPLUS_INCLUDE_PATH=/usr/include:$CPLUS_INCLUDE_PATH
export PATH=/usr/bin/core_perl:$PATH
cp /usr/include/FlexLexer.h ./src

Unfortunately, make test still fails for me. The only error I can see is this:

make: help2man: No such file or directory
make: *** [Makefile:195: verilator_gantt.1] Error 127

@harry-commin-enclustra
Copy link

harry-commin-enclustra commented Apr 17, 2024

Since I couldn't get Verilator to build from source, I followed the spinalhdl instructions to install via pacman.

Here's a full copy-paste of their instructions:

pacman -Syuu
# Close the MSYS2 shell once you're asked to
pacman -Syuu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain \
                   git flex\
                   mingw-w64-x86_64-cmake

pacman -U http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-verilator-4.032-1-any.pkg.tar.xz

# Add C:\msys64\usr\bin;C:\msys64\mingw64\bin to your Windows PATH

I modified the package URL, as I assume the one above is outdated. In other words, I browsed to http://repo.msys2.org/mingw/x86_64/, searched for mingw-w64-x86_64-verilator and found these matches:

image

I guess 5.024 is the latest version, so I installed Verilator like this:

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

Edit: It seems like a better option is to just install the latest version like this:

pacman -S mingw-w64-x86_64-verilator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment