summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/verilog/yosys.vim42
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale-verilog.txt26
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/handler/test_yosys_handler.vader27
-rw-r--r--test/test_filetype_linter_defaults.vader2
7 files changed, 98 insertions, 2 deletions
diff --git a/ale_linters/verilog/yosys.vim b/ale_linters/verilog/yosys.vim
new file mode 100644
index 00000000..29657755
--- /dev/null
+++ b/ale_linters/verilog/yosys.vim
@@ -0,0 +1,42 @@
+" Author: Nathan Sharp <nwsharp+eda@live.com>
+" Description: Yosys for Verilog files
+
+call ale#Set('verilog_yosys_executable', 'yosys')
+call ale#Set('verilog_yosys_options', '-Q -T -p ''read_verilog %s''')
+
+function! ale_linters#verilog#yosys#GetCommand(buffer) abort
+ return '%e ' . ale#Var(a:buffer, 'verilog_yosys_options') . ' 2>&1'
+endfunction
+
+function! ale_linters#verilog#yosys#Handle(buffer, lines) abort
+ let l:output = []
+ let l:path = fnamemodify(bufname(a:buffer), ':p')
+
+ for l:match in ale#util#GetMatches(a:lines, '^\([^:]\+\):\(\d\+\): \(WARNING\|ERROR\): \(.\+\)$')
+ call add(l:output, {
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'text': l:match[4],
+ \ 'type': l:match[3][0],
+ \ 'filename': l:match[1],
+ \})
+ endfor
+
+ for l:match in ale#util#GetMatches(a:lines, '^\(Warning\|ERROR\): \(.\+\)$')
+ call add(l:output, {
+ \ 'lnum': 1,
+ \ 'text': l:match[2],
+ \ 'type': l:match[1][0],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('verilog', {
+\ 'name': 'yosys',
+\ 'output_stream': 'stdout',
+\ 'executable': {b -> ale#Var(b, 'verilog_yosys_executable')},
+\ 'command': function('ale_linters#verilog#yosys#GetCommand'),
+\ 'callback': 'ale_linters#verilog#yosys#Handle',
+\ 'lint_file': 1,
+\})
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 639e1833..283caf06 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -550,6 +550,7 @@ Notes:
* `verilator`
* `vlog`
* `xvlog`
+ * `yosys`
* VHDL
* `ghdl`
* `vcom`
diff --git a/doc/ale-verilog.txt b/doc/ale-verilog.txt
index 01af63c2..11e988bb 100644
--- a/doc/ale-verilog.txt
+++ b/doc/ale-verilog.txt
@@ -3,7 +3,7 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options*
===============================================================================
-ALE can use five different linters for Verilog HDL:
+ALE can use six different linters for Verilog HDL:
HDL Checker
Using `hdl_checker --lsp`
@@ -20,6 +20,9 @@ ALE can use five different linters for Verilog HDL:
Vivado
Using `xvlog`
+ Yosys
+ Using `ysoys -Q -T -p 'read_verilog'`
+
By default, both 'verilog' and 'systemverilog' filetypes are checked.
You can limit 'systemverilog' files to be checked using only 'verilator' by
@@ -115,4 +118,25 @@ g:ale_verilog_xvlog_options *g:ale_verilog_xvlog_options*
===============================================================================
+yosys *ale-verilog-yosys*
+
+g:ale_verilog_yosys_executable *g:ale_verilog_yosys_executable*
+ *b:ale_verilog_yosys_executable*
+ Type: |String|
+ Default: `'yosys'`
+
+ This variable can be changed to the path to the 'yosys' executable.
+
+
+g:ale_verilog_yosys_options *g:ale_verilog_yosys_options*
+ *b:ale_verilog_yosys_options*
+ Type: |String|
+ Default: `'-Q -T -p ''read_verilog %s'''`
+
+ This variable can be changed to modify the flags/options passed to 'yosys'.
+ By default, Yosys is an interative program. To obtain linting functionality,
+ the `'read_verilog'` command is used.
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 53dd2ea2..f2800ff0 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -3067,6 +3067,7 @@ documented in additional help files.
verilator.............................|ale-verilog-verilator|
vlog..................................|ale-verilog-vlog|
xvlog.................................|ale-verilog-xvlog|
+ yosys.................................|ale-verilog-yosys|
vhdl....................................|ale-vhdl-options|
ghdl..................................|ale-vhdl-ghdl|
hdl-checker...........................|ale-vhdl-hdl-checker|
diff --git a/supported-tools.md b/supported-tools.md
index 79d8e7df..d4e55f86 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -559,6 +559,7 @@ formatting.
* [verilator](http://www.veripool.org/projects/verilator/wiki/Intro)
* [vlog](https://www.mentor.com/products/fv/questa/)
* [xvlog](https://www.xilinx.com/products/design-tools/vivado.html)
+ * [yosys](http://www.clifford.at/yosys/)
* VHDL
* [ghdl](https://github.com/ghdl/ghdl)
* [vcom](https://www.mentor.com/products/fv/questa/)
diff --git a/test/handler/test_yosys_handler.vader b/test/handler/test_yosys_handler.vader
new file mode 100644
index 00000000..a55d0b5b
--- /dev/null
+++ b/test/handler/test_yosys_handler.vader
@@ -0,0 +1,27 @@
+Before:
+ runtime ale_linters/verilog/yosys.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The yosys handler should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'type': 'E',
+ \ 'text': 'syntax error, unexpected TOK_ID',
+ \ 'filename': 'file.v'
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': 'internal error',
+ \ },
+ \ ],
+ \ ale_linters#verilog#yosys#Handle(bufnr(''), [
+ \ '1. Executing Verilog-2005 frontend: file.v',
+ \ 'ERROR: internal error',
+ \ 'file.v:3: ERROR: syntax error, unexpected TOK_ID',
+ \ ])
+
diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader
index 419800de..563a093f 100644
--- a/test/test_filetype_linter_defaults.vader
+++ b/test/test_filetype_linter_defaults.vader
@@ -61,7 +61,7 @@ Execute(The defaults for the zsh filetype should be correct):
Execute(The defaults for the verilog filetype should be correct):
" This filetype isn't configured with default, so we can test loading all
" available linters with this.
- AssertEqual ['hdl-checker', 'iverilog', 'verilator', 'vlog', 'xvlog'], GetLinterNames('verilog')
+ AssertEqual ['hdl-checker', 'iverilog', 'verilator', 'vlog', 'xvlog', 'yosys'], GetLinterNames('verilog')
let g:ale_linters_explicit = 1