Skip to main content

Verilator

· loading · loading · · ·
HDL Verilog 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
#

Command Description
verilator --version Shows the installed Verilator version.
verilator --lint-only file.v Lints Verilog file for syntax/warnings.
verilator --trace Enables waveform tracing during simulation.
verilator --cc file.v Translates 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

Blocking vs Non-Blocking Assignments
· loading · loading
HDL Verilog HDL
Command-Line Input
· loading · loading
HDL Verilog HDL
Compiler Directives & Macros
· loading · loading
HDL Verilog HDL
Control Flow
· loading · loading
HDL Verilog HDL
Delay Controls
· loading · loading
HDL Verilog HDL
Git Installition for Windows
· loading · loading
HDL Verilog HDL

comments powered by Disqus