Skip to content

Instantly share code, notes, and snippets.

@sckzw
Created February 16, 2014 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sckzw/9040121 to your computer and use it in GitHub Desktop.
Save sckzw/9040121 to your computer and use it in GitHub Desktop.
Emacsのverilog-modeのためのflymake設定 ref: http://qiita.com/shuichinet/items/5a5e1b5c571fc2a17bd5
module foo( /*AUTOARG*/ );
/*AUTOINPUT*/
/*AUTOOUTPUT*/
/*AUTOWIRE*/
bar bar( /*AUTOINST*/ );
baz baz( /*AUTOINST*/ );
endmodule
// Local Variables:
// verilog-library-files:("bar.v" "baz.v")
// End:
;;; flymake
(require 'flymake)
;; チェック後にエラーしても終了しないようにする
(defadvice flymake-post-syntax-check
(before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
;; Verilog HDL用のflymake初期化関数
(defun flymake-verilog-init()
(let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
(main-file (file-relative-name temp-file (file-name-directory buffer-file-name)))
(sub-files (flymake-verilog-get-files)))
(list "verilator_bin" (append (list "--lint-only" main-file) sub-files))))
;; verilog-modeのverilog-library-files設定からサブモジュールのファイルリストを取得する
(defun flymake-verilog-get-files()
(save-excursion
(goto-char (point-min))
(if (re-search-forward "verilog-library-files:( *\"\\([^)]+\\)\" *)" nil t)
(split-string (match-string-no-properties 1) "\" *\"") (list))))
;; Verilog HDLのファイル拡張子と初期化関数を登録する
(push '(".+\\.s?v$" flymake-verilog-init) flymake-allowed-file-name-masks)
;; エラーメッセージのパターンを登録する
(push '("^%.+: \\(.+\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns)
;; verilog-modeでflymakeを有効にする
(add-hook 'verilog-mode-hook '(lambda () (flymake-mode t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment