Author: Andrew Hanlon
Creation Date: 2020/07/21
Using MSYS2 is probably the easiest way to get a recent version of Verilator up and running on Windows. However, if you would like greater control of your Verilator installation, you can follow the instructions to install it under Cygwin.
-
Install MSYS2 according to the instructions on its website, https://www.msys2.org/.
-
Install Verilator with MSYS2 by running
pacman -S mingw-w64-x86_64-verilator
in the MSYS2 terminal.
That's it! Verilator should now be ready to use. Note that you may want to add Verilator to your PATH environment variable, if this fits your needs.
To update MSYS2 and Verilator, run pacman -Syu
in the MSYS2 terminal. This will update everything under MSYS2. To update just Verilator, the command is the same as installing - pacman -S mingw-w64-x86_64-verilator
.
These instructions assume Git is set up and installed.
-
Download the Cygwin installer "setup-x86_64.exe" from https://www.cygwin.com/. Make sure you keep this program, as it is used to update as well as install Cygwin and the programs installed under it.
-
I installed Cygwin to
C:\cygwin64
, withC:\cygwin64
as the "Local Package Directory." Afterwards, I moved "setup-x86_64.exe" toC:\cygwin64
as well, to keep all of Cygwin's stuff in one place. -
Add
C:\cygwin64\bin
to the Windows PATH variable. The fastest way to get to the PATH settings is by typing "path" into the Windows search tool and selecting "Edit the system environment variables." In the window that comes up, click the "Environment Variables" button near the bottom. From the list in the next popup window, select "PATH" and click "Edit". Here, you can add an entry to the PATH.
The following instructions follow Verilator's installation instructions:
- Having installed base Cygwin, run Cygwin's "setup-x86_64.exe" program again to download Verilator's dependencies. That means ensuring the latest (non-test) version of each of the following programs are installed:
- perl
- python3
- make
- gcc-g++
- autoconf
- flex
- bison
-
Clone Verilator into your location of choice with
git clone https://github.com/verilator/verilator
. I cloned it toC:\
, giving me the source inC:\verilator\
-
In the Cygwin terminal, run
cd /cygdrive/c/verilator
or wherever you cloned the Verilator repository -
Run
git pull
-
Checkout the "stable" branch of Verilator by running
git checkout stable
-
Run
autoconf
-
From here, we follow the recommended "Run-in-Place from VERILATOR_ROOT" style of Verilator setup. Run
export VERILATOR_ROOT=`pwd`
. Note the use of backticks aroundpwd
, not single quotes! -
Run
make -j
. This will compile and link Verilator from source. Verilator is a very large C++ program, so this takes time. Prepare to let your computer chug at full steam for some minutes. -
Run
make test
to ensure there were no problems. If things were successful,Tests passed!
should have been printed near the end of the long train of test output. -
To make sure things are set up such Cygwin-based programs can be run from PowerShell, Command Prompt, or other programs, open PowerShell and run
\verilator\bin\verilator_bin.exe -V
. Something likeVerilator 4.038 2020-07-11 rev v4.038-8-gdd03d0f3
should be printed immediately. If the command was unsuccessful, or printed nothing, it's likely that something went astray along the way here.
That's it! Verilator should now be ready to use. Note that you may want to add Verilator to your PATH environment variable, if this fits your needs.
To update Verilator compiled from source:
-
Run
git pull
-
Go through Part 3 of the installation instructions again to recompile the updated source code.