Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ endfunction

autocmd FileType bsv call BSVSetPath(expand('<afile>:p:h'))
```

# Support for linting via ALE.

Linting is done via `bsc -u <g:ale_bsv_bsc_options> <filename>`

If additional options need to be passed set `g:ale_bsv_bsc_options` e.g.

```
let g:ale_bsv_bsc_options='-p /commonlib/bo:+ -verilog'
```
18 changes: 18 additions & 0 deletions ale_linters/bsv/ale.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
" Author: Vijayvithal <jahagirdar.vs@gmail.com>
" Description: Linter for bluespec system verilog

call ale#Set('bsv_executable', 'bsc')

function! <SID>GetCommand(buffer, output) abort
let bsc_options = g:ale_bsv_bsc_options ?? ''
return 'bsc -u' . bsc_options .'%s'
endfunction

call ale#linter#Define('bsv', {
\ 'name': 'bsv',
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'bsv_executable')},
\ 'command': {function('<SID>GetCommand')
\ 'callback': 'ale#handlers#c#HandleGCCFormatWithIncludes',
\})
" 'callback': function('<SID>HandleBSCLint')
45 changes: 43 additions & 2 deletions snippets/bsv.snippets
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
snippet struct
typedef struct { ${1:Bit#};
} deriving(Bits,Eq);
snippet enum
typedef enum { ${1:Bit#};
} deriving(Bits,Eq);

snippet import
import ${1:Standard}::*;
${2}
Expand All @@ -22,8 +29,33 @@ snippet function
${3}
endfunction
snippet module
module ${1:modulename} (${2});
${3}
interface Ifc_$1;
method Action soft_reset();
method Bool reset_done();
endinterface
import StmtFSM::*;
(*synthesize*)
module mk${1:modulename} (Ifc_$1);
Reg#(Bool) rst_done <- mkRegA(False);
${2}
let reset=action
rst_done <=True;
endaction;
Stmt stmt_$1=seq
if (!rst_done)seq
reset;
endseq
endseq;
FSM fsm_$1 <- mkFSM(stmt_$1);
rule rl_$1_fsm (fsm_$1.done() && (!rst_done));
fsm_$1.start();
endrule
method Action soft_reset();
rst_done <=False;
endmethod
method Bool reset_done();
return rst_done;
endmethod
endmodule
snippet rule
rule ${1:rulename};
Expand Down Expand Up @@ -63,3 +95,12 @@ snippet package
package ${1};
${2}
endpackage
snippet fsm
import StmtFSM::*;
Stmt ${1}_stmt=seq
endseq;
FSM $1 mkFSM($1_stmt);
rule $1_rl ($1.done())
$1.start();
endrule

1 change: 1 addition & 0 deletions syntax/bsv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ syntax match bsvNiceOperator "<=" conceal cchar=⇐
highlight link bsvNiceOperator Operator
highlight! link Conceal Operator
setlocal conceallevel=1
highlight Conceal ctermfg=Green