Verilog/SystemVerilog Setup in Vim

This post guides you through setting up Verilog/SystemVerilog in Vim, covering ctags generation and linting. While vim-ale is often seen as an optimal solution, uncertainties arise in its linting capability for large projects. This prompts the consideration of decoupling Vim editing from linting. Nonetheless, valuable experiences gained during this process are documented below.

List of Tools

  • universal-ctags
  • vim-ale
  • slang
  • verible

universtal-ctags

The tool universal-ctags is considered as a better replacement over traditional ctags tools. Make sure you have it installed, since its ancestors don’t seem to work for Verilog. Although some blogs suggested to manually update the ~/.ctags file for Verilog/Systemverilog tag generation, it seems this feature is already integrated in Universal-ctags.

Generate tags files for UVM src code and your src files separately.

ctags --languages=systemverilog -R ./

In the local .vimrc file, add the following settings.

set tags=$WORK_HOME/tags;
set tags+=$UVM_HOME/src/tags

This file won’t take effect, unless you set the following in ~/.vimrc, as discussed in this blog.

if getcwd() =~# '^\($your_working_dir/\)'
  set secure exrc
endif

Now you can use Ctrl+] for jumping into UVM definitions in Vim. You may also consider using the vim plugin Tagbar.

vim-ale

vim-ale serves as a Lint Engine for various of languages. To start with, we use the open source verilator tool. To tell which linter is currently being used when opening a file in vim, check this issue, and add the following in .vimrc

let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'

You can also check the current value of a vim setting as in this answer

Parse and Linting

Source code parsing is primarily concerned with understanding the structure and syntax of code, while linting focuses on identifying potential issues, enforcing coding standards, and promoting good coding practices.

The results of of linters’ compatibility comparison is listed here. Nevertheless, it doesn’t provide details on how these results are obtained. Among all these tools, slang and verible demonstrated the best performance.

slang

Instead of the standard cmake process outlined in the Slang documentation, one my need to inclusion of extra options to explicitly specify the C and CXX compilers. This adjustment becomes crucial due to the default CLANG version on MacOS being 15, while Slang mandates version 16 or higher. For more guidance, refer to this answer.

cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...

slang seems to be a good candidate to replace the verilator, as its outputs seems similar to normal clang. TODO: merge slang with vim-ale, following the example of clang here.

FIXME: Run cmake under the build dir would still have 9 fail cases in total.

FIXME: The doc is not fully generated with python errors.

verible

Verible is another parser of SV, developed by Google groups. Nevertheless, the doc on the github and cs.opensource seems to be a little bit broken. Docs could be accessed under the doc dir directly.

Snippets

Use the following plugins for Vim.

Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets

Currently the Verilog/SystemVerilog snippets is already included in vim-snippets, but UVM snippets are not. However, VS Code has an extension named sv-1800-2012, which provides auto complete for UVM snippets. We could adapt the code for vim snippets. The process is described in another article.

2024

SSD Controller Verification

This article provides insights into considerations for SSD Controller Functional Verification.

Vim UVM Snippets

This article outlines the process of adding UVM snippets to the vim-snippet GitHub repository.

NVMe Introduction

Introduction to Non-Volatile Memory Express (NVMe) Interface for Beginners.

UVM Learning Path

This article provides a review of UVM learning resources, complete example projects, and useful tools to expedite the learning process.

vim-galore enhanced

The repository vim-galore is an excellent resource for Vim learners, focusing on fundamental Vim capabilities. However, to further augment Vim’s functionalit...

Verilog/SystemVerilog Setup in Vim

This post guides you through setting up Verilog/SystemVerilog in Vim, covering ctags generation and linting. While vim-ale is often seen as an optimal soluti...

Back to top ↑

2021

ICC Custom Floorplan

本文介绍 ICC 进行特定形状的 Floorplan 设计以及PIN脚摆放的方法。

Coverage 用法总结

本文介绍Coverage的概念以及使用Synopsys工具对其进行分析的方法。

DC High Fanout Nets

本文介绍 DC 综合阶段 High-Fanout Nets 可能遇到的相关问题

Euclide - Part0

本文介绍Synopsys的前端设计IDE Euclide。

Back to top ↑