在vim上安裝配置verilog-mode
更新emasc最新verilog-mode
下載
最新版可以見 verilog-mode
安裝
window
從網上找到的教程清一色是讓在$HOME目錄下新建一個elisp目錄然後放verilog-mode.el進去,再寫個.emacs
要新建.emacs還需要用cmd窗口echo hi > .emacs
但我照做了沒有用
在emacs下, 依次輸入C-h v load-path
回車, 就可以看到下面界面
裏面並不包含$HOME目錄,所以它沒有起作用
從load-path的輸出看,第一個是emacs/26.1/site-lisp,所以可以把解壓縮後的verilog-mode.el放到這個目錄裏
同時在該目錄新建一個文件site-start.el
;; Load verilog mode only when needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
;; Any files that end in .v should be in verilog mode
(setq auto-mode-alist (cons '("\\.[v|sv]\\'" . verilog-mode) auto-mode-alist))
;; Any files in verilog mode should have their keywords colorized
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))
這樣當打開.v或.sv開頭的文件,會自動加載verilog-mode插件
Linux
新建~/.elisp目錄,把verilog-mode.el拷貝進去
在~/.emacs裏輸入
(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))
(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the directory ~/elisp for elisp files
(prepend-path "~/.elisp")
;; Load verilog mode only when needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
;; Any files that end in .v, .dv or .sv should be in verilog mode
(add-to-list 'auto-mode-alist '("\\.[ds]?v\\'" . verilog-mode))
;; Any files in verilog mode should have their keywords colorized
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))
在vim上安裝verilog-mode插件
在網上有一個插件,但它有很多問題,基於它我修改出了一個無問題版本
https://github.com/zhuzhzh/ve...
使用vim-plug或Vundle安裝的方法如下:
vim-plug
Plug 'zhuzhzh/verilog_emacsauto.vim', {'for': ['verilog', 'systemverilog'] }
Vundle
Plugin 'zhuzhzh/verilog_emacsauto.vim'
使用方法
- <Leader>a: 展開所有auto宏
- <leader>d: 移除所有uato宏
注意,默認<Leader>是, 也可以在.vimrc裏重設它
原始代碼如下:
//
// Created by : Harris Zhu
// Filename : test.sv
// Author : Harris Zhu
// Created On : 2018-07-14 22:20:59
// Last Modified : 2018-07-14 22:20:59
// Update Count : 1
// Tags :
// Description :
// Conclusion :
//
//=======================================================================
module foo(/*AUTOARG*/);
input i;
output [DWIDTH-1:0] o;
endmodule
module test (/*AUTOARG*/);
parameter DWIDTH=32;
input i;
output [DWIDTH-1:0] o;
foo u0(/*AUTOINST*/);
endmodule
按下<leader>a後, 變成如下
//
// Created by : Harris Zhu
// Filename : test.sv
// Author : Harris Zhu
// Created On : 2018-07-14 22:20:59
// Last Modified : 2018-07-14 22:20:59
// Update Count : 1
// Tags :
// Description :
// Conclusion :
//
//=======================================================================
module foo(/*AUTOARG*/
// Outputs
o,
// Inputs
i
);
input i;
output [DWIDTH-1:0] o;
endmodule
module test (/*AUTOARG*/
// Outputs
o,
// Inputs
i
);
parameter DWIDTH=32;
input i;
output [DWIDTH-1:0] o;
foo u0(/*AUTOINST*/
// Outputs
.o (o[DWIDTH-1:0]),
// Inputs
.i (i));
endmodule