From 01ecf2a75f60fff8884ad7858da44b3c5f71bc11 Mon Sep 17 00:00:00 2001 From: Tarik Graba Date: Thu, 29 Jun 2017 10:15:52 +0200 Subject: =?UTF-8?q?Adds=20an=20option=20to=20pass=20additional=20arguments?= =?UTF-8?q?=20to=20the=20verilog/verilator=20=E2=80=A6=20(#698)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds an option to pass additional arguments to the verilog/verilator linter The new otion is g:ale_verilog_verilator_options + doc * Spell check verilog linter doc file * Add entries to the verilog linters in the doc table of content * Vader test for verilog/verilator linter args option verilog_verilator_options --- ale_linters/verilog/verilator.vim | 9 ++++++- doc/ale-verilog.txt | 43 +++++++++++++++++++++++++++++++ doc/ale.txt | 3 +++ test/test_verilog_verilator_options.vader | 25 ++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 doc/ale-verilog.txt create mode 100644 test/test_verilog_verilator_options.vader diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim index b44731c7..aa5e7047 100644 --- a/ale_linters/verilog/verilator.vim +++ b/ale_linters/verilog/verilator.vim @@ -1,6 +1,11 @@ " Author: Masahiro H https://github.com/mshr-h " Description: verilator for verilog files +" Set this option to change Verilator lint options +if !exists('g:ale_verilog_verilator_options') + let g:ale_verilog_verilator_options = '' +endif + function! ale_linters#verilog#verilator#GetCommand(buffer) abort let l:filename = tempname() . '_verilator_linted.v' @@ -8,7 +13,9 @@ function! ale_linters#verilog#verilator#GetCommand(buffer) abort call ale#engine#ManageFile(a:buffer, l:filename) call writefile(getbufline(a:buffer, 1, '$'), l:filename) - return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' . ale#Escape(l:filename) + return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' + \ . ale#Var(a:buffer, 'verilog_verilator_options') .' ' + \ . ale#Escape(l:filename) endfunction function! ale_linters#verilog#verilator#Handle(buffer, lines) abort diff --git a/doc/ale-verilog.txt b/doc/ale-verilog.txt new file mode 100644 index 00000000..6566ad42 --- /dev/null +++ b/doc/ale-verilog.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Verilog/SystemVerilog Integration *ale-verilog-options* + + +------------------------------------------------------------------------------- +ALE can use two different linters for Verilog HDL: + + iverilog: + Using `iverilog -t null -Wall` + + verilator + Using `verilator --lint-only -Wall` + +By default, both 'verilog' and 'systemverilog' filetypes are checked. + +You can limit 'systemverilog' files to be checked using only 'verilator' by +defining 'g:ale_linters' variable: +> + au FileType systemverilog + \ let g:ale_linters = {'systemverilog' : ['verilator'],} +< + +------------------------------------------------------------------------------- +iverilog *ale-verilog-iverilog* + + No additional options + + +------------------------------------------------------------------------------- +verilator *ale-verilog-verilator* + +g:ale_verilog_verilator_options *g:ale_verilog_verilator_options* + *b:ale_verilog_verilator_options* + Type: |String| + Default: `''` + + This variable can be changed to modify 'verilator' command arguments + + For example `'-sv --default-language "1800-2012"'` if you want to enable + SystemVerilog parsing and select the 2012 version of the language. + +------------------------------------------------------------------------------- + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 0c2ecbb7..f9532fc4 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -101,6 +101,9 @@ CONTENTS *ale-contents* eslint..............................|ale-typescript-eslint| tslint..............................|ale-typescript-tslint| tsserver............................|ale-typescript-tsserver| + verilog/systemverilog.................|ale-verilog-options| + iverilog............................|ale-verilog-iverilog| + verilator...........................|ale-verilog-verilator| vim...................................|ale-vim-options| vint................................|ale-vim-vint| xml...................................|ale-xml-options| diff --git a/test/test_verilog_verilator_options.vader b/test/test_verilog_verilator_options.vader new file mode 100644 index 00000000..561786ee --- /dev/null +++ b/test/test_verilog_verilator_options.vader @@ -0,0 +1,25 @@ +Before: + Save g:ale_verilog_verilator_options + let g:ale_verilog_verilator_options = '' + +After: + Restore + call ale#linter#Reset() + +Execute(Set Verilog Verilator linter additional options to `-sv --default-language "1800-2012"`): + runtime! ale_linters/verilog/verilator.vim + + " Additional args for the linter + let g:ale_verilog_verilator_options = '-sv --default-language "1800-2012"' + + call ale#Lint() + + let g:run_cmd = ale_linters#verilog#verilator#GetCommand(bufnr('')) + let g:matched = match(g:run_cmd, '\s' . g:ale_verilog_verilator_options . '\s') + + " match returns -1 if not found + AssertNotEqual + \ g:matched , + \ -1 , + \ 'Additionnal arguments not found in the run command' + -- cgit v1.2.3