Building and running most basic Verilator

1.4k views Asked by At

Trying to get started with basic Verilator c++ example on Windows 10.

Attempt 1: Using WSL, install from apt

  • apt install verilator seems to run fine

  • verilator --version returns Verilator 4.038 2020-07-11 rev v4.036-114-g0cd4a57ad

  • export VERILATOR_ROOT=/usr/share/verilator (after a few attempts at this step)

  • Using our.v and sim_main.cpp as in the example

  • verilator --cc --exe --build -j 0 -Wall sim_main.cpp our.v returns %Error: -j accepts positive integer, but 0 is passed. Ok so maybe that's a version 5 argument.

  • Try again verilator --cc --exe --build -j 1 -Wall sim_main.cpp our.v returns

      Can't exec "/usr/share/verilator/verilator_bin": No such file or directory at /usr/bin/verilator line 173.
      %Error: verilator: Misinstalled, or VERILATOR_ROOT might need to be in environment
      %Error: Verilator threw signal -1. Suggest trying --debug --gdbbt
      %Error: Command Failed /usr/share/verilator/verilator_bin --cc --exe --build -j 1 -Wall sim_main.cpp our.v
    
  • verilator_bin is installed next to verilator in /usr/bin, not in /usr/share/verilator which is where VERILATOR_ROOT points to.

  • When I had VERILATOR_ROOT accidentally pointing to /usr/bin in third step above, the tool could not find verilated.mk

  • I went into obj_dir/ and did make Vour directly, but it complained about not finding verilated_heavy.h

  • So it looks like VERILATOR_ROOT is the main lever here, and pointing to either /usr/bin or /usr/share/verilator doesn't work, but in different ways.

Attempt 2: Using WSL, build V5.008 from git source, from instructions

  • apt remove verilator to remove attempt 1

  • Download from git and build everything as per "Git Quick Install" section

  • Needed to install help2man before make install, which is not in instructions

  • verilator --version returns Verilator 5.008 2023-03-04 rev v5.008-32-gaaaf8e75a

  • make test -- all passed

  • which verilator returns /usr/local/bin/verilator

  • export VERILATOR_ROOT=/usr/local/bin then verilator --cc --exe --build -j 0 -Wall sim_main.cpp our.v returns Cannot find verilated_std.sv``/usr/local/share/verilator/include/verilated_std.sv.

  • Put export VERILATOR_ROOT=/usr/local/share/verilator in .bashrc, then restart, then verilator --cc --exe --build -j 0 -Wall sim_main.cpp our.v returns

      Can't exec "/usr/local/share/verilator/verilator_bin": No such file or directory at /usr/local/bin/verilator line 207.
      %Error: verilator: Misinstalled, or VERILATOR_ROOT might need to be in environment
      %Error: Verilator threw signal -1. Suggest trying --debug --gdbbt
      %Error: Command Failed /usr/local/share/verilator/verilator_bin --cc --exe --build -j 1 -Wall sim_main.cpp our.v
    
  • So basically same problem as attempt #1 -- I can't find a good setting for VERILATOR_ROOT

  • Checked https://github.com/verilator/verilator/issues/1116

  • Removed VERILATOR_ROOT from .bashrc, start WSL again

  • make clean, autoconf, make, make test, make install all good

  • Same results as above after updating VERILATOR_ROOT to /usr/local/share/verilator and optionally adding $VERILATOR_ROOT/bin to path.

Attempt 3: Using MSVC and CMAKE, build V5.008 from git source

  • More difficulties, but eventually got a binary
  • Program does not generate any output.
1

There are 1 answers

0
Sonicsmooth On

I just needed to unset VERILATOR_ROOT completely, even after make install.