Using Verilator and other EDA tools

Feed

date: 2026-04-24 07:49:33

categories: hardware

firstPublishDate: 2026-04-24 07:49:33

The EDA tools I'm using are: `verilator`, `gtkwave` and `vivado`

`verilator` and `gtkwave` are open souce and `vivado` is free for small FPGAs. These tools are not well integrated together but they are good enough for small designs and free.

Verilator

GTKwave

Vivado

Related:

System with the c16 CPU and Gpu1

C16 CPU

Gpu1

Install

`gtkwave` is available in apt:

`verilator` is also available in apt but it is better to compile it from source and use the latest version to avoid issues.

I compile `verilator` with these commands:

`vivado` needs a specific version of a linux distribution so I created a virtual machine with `Ubuntu 24.04 LTS`. I installed `vivado` in my home directory. I don't update the system because after each update there is a risk `vivado` is not compatible with the updates, here is the compatibility table:

I have 32GB RAM for the virtual machine which is enough for small design, when compiling my design with `vivado` it takes less than 16GB RAM.

If the design is too big for the target FPGA, `vivado` doesn't stop, it tries to fit the design and takes more than 50GB RAM after running for 3 days.

`vivado` compiles small designs in less than 10 minutes using 8 cores in some steps.

Compiling verilog code

I usually compile the design with `verilator` and `vivado` because they don't issue the same errors, when `vivado` generates a bit stream then the design is ok.

I simulate the verilog code with `verilator` by compiling it to an executable and then run the executable:

I prefer having a testbench written in verilog and the design under test is inside the testbench. I use `--trace-fst` to save the signals in fst format instead of vcd. With fst, the traces are smaller because fst is binary and compressed whereas vcd is text and not compressed.

I compile the design with `vivado` using batch mode:

`flow.tcl` looks like this:

The compilation result is `./out/stream.bit` which should be uploaded to the FPGA.

`io.xdc` looks like:

Use latest verilator from git repo

When I was using `verilator` 5.006 from apt, I encountered an error initializing an array with this code:

This error is fixed in `verilator` 5.032 2025-01-01.

Writing verilog code

Unused signals have to used somehow:

At the end of the tb file, add:

The output type from modules have to be type wire, `vivado` requires it.

regs have to be declared outside always blocks, `vivado` requires it . I use the `-Wno-BLKSEQ` option for `verilator` because I'm ok with this:

Big arrays take a lot of resources in the FPGA, they should be replaced with a RAM interface and they will be mapped to block RAM.

`vivado` doesn't support fopen and fread to load data, use `$readmemh("data.mem", mem);` instead. `data.mem` is a text file with data in hexadecimal for one memory address per line.

I convert binary files to mem text file with hexdump:

blog post about converting binary files

`vivado` maps modules like this to block ram:

The data is read 1 clock cycle after the address.

Small FPGA designs

Feed

Guestbook