Skip to main content

Verilator

· loading · loading · ·
HDL Verilog HDL
HDL
Axolot Logic
Author
Axolot Logic
Digital Design Engineer
Table of Contents

🧠 What is Verilator?
#

Verilator is an open-source simulator that converts Verilog HDL (Hardware Description Language) code into high-performance C++ or SystemC code. It is primarily used for hardware modeling and verification. Unlike other HDL simulators, Verilator is designed for cycle-accurate, synthesizable Verilog code.


πŸ”‘ Key Features of Verilator
#

  • Translates Verilog into high-speed C++/SystemC models.
  • Offers excellent performance for large-scale designs.
  • Open source under the GNU GPL license.
  • Supports waveform generation and debugging.
  • Suitable for FPGA and ASIC development flows.

πŸ› οΈ Verilator Installation Guide
#

There are several ways to install Verilator: prebuilt packages, source build, or package managers.


🐧 1. Installing on WSL (Ubuntu) or Native Linux
#

Step 1: Install Required Dependencies
#

Run the following in your terminal:

sudo apt update
sudo apt install git make autoconf g++ flex bison libfl2 libfl-dev zlib1g zlib1g-dev

Step 2: Clone Verilator Source Code
#

git clone https://github.com/verilator/verilator.git
cd verilator

Step 3: Checkout Stable Version & Build
#

git checkout stable

πŸ›‘ If you encounter an error related to help2man, it’s because the utility used for generating man pages is missing.

Fix: Install help2man
#

sudo apt install help2man -y

Step 4: Build and Install
#

autoconf
./configure
make -j$(nproc)
sudo make install

Step 5: Verify Installation
#

verilator --version

πŸͺŸ 2. Installing on Windows (via WSL)
#

  1. Install WSL and a Linux distribution (e.g., Ubuntu). WSL Setup Guide
  2. Open the WSL terminal and follow the Linux installation steps above.

🍏 3. Installing on macOS
#

Using Homebrew
#

brew update
brew install verilator
verilator --version

πŸ’» 4. Installing on Native Windows
#

Verilator cannot run natively on Windows without a Linux-like environment. Use:

  • WSL
  • Cygwin
  • Virtual Machine
  • Docker

πŸš€ Verilator Usage Example
#

Step 1: Create a Verilog Design
#

// hello.v
module hello(input logic clk, output logic led);
    always @(posedge clk) led <= ~led;
endmodule

Step 2: Simulate with Verilator
#

1. Generate C++ Model
#

verilator --cc hello.v --exe sim_main.cpp

2. Compile the Model
#

make -j -C obj_dir -f Vhello.mk Vhello

3. Run Simulation
#

./obj_dir/Vhello

Step 3: Generate Waveform (Optional)
#

Use the --trace flag to enable VCD waveform dumping:

verilator --cc hello.v --exe sim_main.cpp --trace

🧩 Useful Verilator Commands
#

CommandDescription
verilator --versionShows the installed Verilator version.
verilator --lint-only file.vLints Verilog file for syntax/warnings.
verilator --traceEnables waveform tracing during simulation.
verilator --cc file.vTranslates Verilog to C++ code.

❓ Frequently Asked Questions
#

1. Does Verilator support only synthesizable Verilog?
#

Yes. Verilator is limited to synthesizable, cycle-accurate Verilog. It does not support event-driven simulation or non-synthesizable testbenches.

2. Why is Verilator so fast?
#

Verilator converts Verilog to native C++/SystemC code, which is then compiled and run as a software applicationβ€”much faster than traditional interpreted simulators.


If you need further help or want a walkthrough for integrating with testbenches, waveform viewers (GTKWave), or CMake setups, feel free to ask! 😊

Related

Git Installition for Windows
· loading · loading
HDL Verilog HDL
HDL
Installing Make on Windows
· loading · loading
HDL Verilog HDL
HDL
Make Installition
· loading · loading
HDL Verilog HDL
HDL
MinGW-w64 Install on Windows
· loading · loading
HDL Verilog HDL
HDL
RISC-V Environment Installition
· loading · loading
HDL Verilog HDL
HDL
RISC-V GCC Toolchain Installation
· loading · loading
HDL Verilog HDL
HDL