侵权投诉
订阅
纠错
加入自媒体

Emacs的verilog-mode介绍

2022-02-10 15:14
ExASIC
关注

RTL顶层自动连线听说过吗?想学吗?我们今天就来介绍自动连线的神器——emacs verilog-mode。

emacs是什么?

江湖流传版:传说中神的编辑器。

维基百科版:Emacs(Editor MACroS,宏编辑器),最初由Richard Stallman于1975年在MIT协同Guy Lewis Steele Jr.共同完成。

verilog-mode是什么

官网的介绍:

Verilog-mode.el is the extremely popular free Verilog mode for Emacs which provides context-sensitive highlighting, auto indenting, and provides macro expansion capabilities to greatly reduce Verilog coding time. It supports AUTOs and indentation in Emacs for traditional Verilog (1394-2005), the Open Verification Methodology (OVM) and SystemVerilog (1800-2005/1800-2009).
Recent versions allow you to insert AUTOS in non-AUTO designs, so IP interconnect can be easily modified. You can also expand SystemVerilog ".*" port instantiations, to see what ports will be connected by the simulators.

简单点说就是支持Verilog、SystemVerilog(包括UVM)的emacs语法高亮文件。其中提到Verilog-mode支持Autos——这就是今天的重点。

Verilog-mode是由Michael McNamara mac@verilog.com和Wilson Snyder wsnyder@wsnyder.org编写。难能可贵的是,这个verilog-mode保持着每月都有更新。

值得一提的是Wilson Snyder就是SystemVerilog开源仿真器Verilator的作者。

verilog-mode Autos有哪些功能

手动编写的verilog代码:

image.png    

由Autos处理后的Verilog代码:

image.png

image.png

大家可以看到,verilog-mode自动分析出:

· 模块的端口输入和输出

· 内部变量

· 敏感信号列表

· 提取子模块的端口定义

自动提取子模块的端口定义来连线是今天的重点中的重点。一般来讲,我们实例化模块时大部分的信号名与子模块定义的名字一致即可。如上面代码中的:

image.png

特殊连接关系的处理

但常常我们顶层连接时会换一个名字。比如module A有一个输出端口dat_o,module B有一个输入端口dat_i,这两者怎么连?定义模版AUTO_TEMPLATE,如下:

手动编写的verilog:

image.png

由Autos处理后的verilog代码:

image.png

在哪里找子模块定义?

默认规则:

· 当前文件夹下找

· 当前找不到怎么办,指定搜索路径(与verilog仿真器的参数-y一样)

使用方法:在顶层endmodule后面指定verilog-library-directories,如下:

image.png

除了写模版还需要做什么?

只需要Ctrl-C Ctrl-A,仅此而已。

如果修改了子模块或者模版,再按一次Ctrl-C Ctrl-A。

更多功能    

verilog-auto-arg          for AUTOARG module instantiations

verilog-auto-ascii-enum   for AUTOASCIIENUM enumeration decoding

verilog-auto-assign-modport for AUTOASSIGNMODPORT assignment to/from modport

verilog-auto-inout        for AUTOINOUT making hierarchy inouts

verilog-auto-inout-comp   for AUTOINOUTCOMP copy complemented i/o

verilog-auto-inout-in     for AUTOINOUTIN inputs for all i/o

verilog-auto-inout-modport  for AUTOINOUTMODPORT i/o from an interface modport

verilog-auto-inout-module for AUTOINOUTMODULE copying i/o from elsewhere

verilog-auto-inout-param  for AUTOINOUTPARAM copying params from elsewhere

verilog-auto-input        for AUTOINPUT making hierarchy inputs

verilog-auto-insert-lisp  for AUTOINSERTLISP insert code from lisp function

verilog-auto-insert-last  for AUTOINSERTLAST insert code from lisp function

verilog-auto-inst         for AUTOINST instantiation pins

verilog-auto-star         for AUTOINST .* SystemVerilog pins

verilog-auto-inst-param   for AUTOINSTPARAM instantiation params

verilog-auto-logic        for AUTOLOGIC declaring logic signals

verilog-auto-output       for AUTOOUTPUT making hierarchy outputs

verilog-auto-output-every for AUTOOUTPUTEVERY making all outputs

verilog-auto-reg          for AUTOREG registers

verilog-auto-reg-input    for AUTOREGINPUT instantiation registers

verilog-auto-reset        for AUTORESET flop resets

verilog-auto-sense        for AUTOSENSE or AS always sensitivity lists

verilog-auto-tieoff       for AUTOTIEOFF output tieoffs

verilog-auto-undef        for AUTOUNDEF =`undef of local =`defines

verilog-auto-unused       for AUTOUNUSED unused inputs/inouts

verilog-auto-wire         for AUTOWIRE instantiation wires

verilog-read-defines      for reading =`define values

verilog-read-includes     for reading =`includes

verilog-mode下载、安装

新版的GNU Emacs自带verilog-mode,如果需要最新的verilog-mode可以在官网下载

VIM用户咋办?

可以用VIM调动shell命令执行(emacs批处理模式),例如:

:!emacs --batch  <filenames.v>  -f verilog-batch-auto

是不是很简单!

       原文标题 : Emacs的verilog-mode介绍

声明: 本文由入驻维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

电子工程 猎头职位 更多
扫码关注公众号
OFweek电子工程网
获取更多精彩内容
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号