如何在 emacs 中使用 exuberant ctags 时指定和使用 verilog 语言的头文件
我最近开始使用丰富的 ctags 和 emacs 来实现 verilog 和 emacs。系统verilog编码和代码浏览。我目前使用命令生成标签
ctags -e -R --tag-relative=yes --langmap=verilog:.v.vh.sv.svh
我的代码包含很多`定义宏,这些宏都是在某些扩展名为“.vh”的头文件中指定的“.svh”。例如,名为 foo.vh 的头文件具有以下代码
`define WIDTH_ADDRESS 32;
,并且文件 top.v 如下调用宏
input [`WIDTH_ADDRESS - 1 : 0] InAddress;
在浏览 top.v 时> 使用 emacs 文件,有什么方法可以直接跳转到 foo.vh 文件中的宏定义吗?
我一直在使用 Mx Tags-search
现在已经有一段时间了,但在到达 foo.vh 文件之前,它会跳转到其他文件中的许多其他 `WIDTH_ADDRESS 实例。
经过一些研究,我确实看到了一个选项,可以在标签生成期间使用 -h
选项和 ctags 来指定头文件。然而我无法让它工作,我猜我的部分存在一些语法错误。
首先,使用 -h
选项指定头文件有什么显着的好处吗?如果是这样,指定头文件的正确语法是什么?我还可以指定 emacs 在解析其他文件(扩展名为“.v”和“.sv”)之前首先查看这些头文件(扩展名为“.vh”和“.svh”的文件)
I have recently started using exuberant ctags and emacs for verilog & system verilog coding and code browsing. I currently generate the tags using the command
ctags -e -R --tag-relative=yes --langmap=verilog:.v.vh.sv.svh
My code contains a lot of `define macros which are all specified in certain header files with extension ".vh" & ".svh". For e.g. a header file named foo.vh has the following code
`define WIDTH_ADDRESS 32;
and a file top.v invokes the macro as follows
input [`WIDTH_ADDRESS - 1 : 0] InAddress;
While browsing the top.v file using emacs, is there any way by which I can jump directly to to the macro definition in the foo.vh file?
I have been using M-x tags-search <RET> WIDTH_ADDRESS <RET>
for sometime now but it jumps to quite a few other instances of `WIDTH_ADDRESS in other files before reaching the foo.vh file.
After some research I did see an option to specify header files using -h
option with ctags during tags generation. However I could not get it to work and I guess there was some syntactical error from my part.
First of all are there any notable benefits of specifying a header file using -h
option? If so, what is the correct syntax to specify header files? Also can I specify emacs to look into these header files first (files with extension ".vh" &".svh") before parsing other files (with extension ".v" & ".sv")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-h 选项的语法是
-h .vh.svh
我不确定为什么 ctags 会选择 `WIDTH_ADDRESS 宏调用。如果 WIDTH_ADDRESS 被定义多次,它应该获取所有定义,但不获取调用。可能是 Verilog 插件的问题。您可以随时编辑标签文件并删除不需要的条目。使用 sed 或 perl 脚本应该很容易做到这一点。
The syntax for the -h option is
-h .vh.svh
I'm not sure why ctags is picking up `WIDTH_ADDRESS macro invocations. If WIDTH_ADDRESS is `defined multiple times it should pick up all the definitions, but not the invocations. Maybe it's an issue with the Verilog plugin. You can always edit the tags file and delete entries you don't want. This should be easy to do with a sed or perl script.