6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

svlint: SystemVerilogのlinterを作ってみた

Posted at

初めに

最近のプログラミング言語ではlinterなどが標準でついてくるのが当たり前になりつつあります。しかしSystemVerilog用のOSSツールというのはそもそもほとんどなく、当然linterもありません。商用のリントチェッカもあるにはありますが、ライセンスが高価なのでCIなどで気軽に並列で回すというわけにはいきません。

「ないなら自作するしかない」ということでSystemVerilog用のlinterをRustで作りました。

こんな感じでチェックできます。

67759664-377b5480-fa83-11e9-895f-7deef6dde516.png

使い方

リリースページからのダウンロードか、snapのパッケージがあります。Rustを使っている方はcargo install svlintでもOKです。

インストールしたら最初に設定ファイルを生成します。

$ svlint --example > .svlint.toml

設定ファイルは.gitignoreなどと同様にリポジトリルートに置くといいと思います。
この状態では全てのルールがOFFになっているので必要なルールを有効にします。

.svlint.toml
[option]
exclude_paths = []

[rules]
case_default = false
enum_with_type = false
for_with_begin = false
function_same_as_system_function = false
function_with_automatic = false
generate_for_with_label = false
generate_if_with_label = false
generate_keyword = false
genvar_declaration = false
if_with_begin = false
inout_with_tri = false
input_with_var = false
legacy_always = false
level_sensitive_always = false
loop_variable_declaration = false
non_ansi_module = false
output_with_var = false
parameter_in_package = false
priority_keyword = false
tab_charactor = false
unique0_keyword = false
unique_keyword = false
wire_reg = false

使いたいものをtrueにすればいいです。各ルールの説明はこちら

また、exclude_pathsには正規表現のリストを設定出来て、マッチするパスは除外できます。例えばipディレクトリのファイルをチェックしたくないなら

[option]
exclude_paths = ["ip/.*"]

という感じです。

ルールについて

現状は個人的に使うものしか実装していませんが、プルリクエストでのルール追加やIssuesでのリクエストも歓迎します。

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?