3

我最近开始使用丰富的 ctags 和 emacs 进行 verilog 和系统 verilog 编码和代码浏览。我目前使用命令生成标签

ctags -e -R --tag-relative=yes --langmap=verilog:.v.vh.sv.svh 

我的代码包含很多`define 宏,这些宏都在某些扩展名为“.vh”和“.svh”的头文件中指定。例如,名为foo.vh的头文件具有以下代码

`define WIDTH_ADDRESS 32;

并且文件top.v调用宏如下

input [`WIDTH_ADDRESS - 1 : 0] InAddress;

使用 emacs浏览top.v文件时,有什么方法可以直接跳转到foo.vh文件中的宏定义?

我已经使用M-x tags-search <RET> WIDTH_ADDRESS <RET>了一段时间,但是在到达 foo.vh 文件之前,它会跳转到其他文件中的许多其他 `WIDTH_ADDRESS 实例。

-h经过一些研究,我确实看到了一个选项,可以在标签生成期间使用带有 ctags的选项来指定头文件。但是我无法让它工作,我猜我的部分存在一些语法错误。

首先,使用-h选项指定头文件有什么显着的好处吗?如果是这样,指定头文件的正确语法是什么?我也可以指定emacs在解析其他文件(扩展名为“.v”和“.sv”)之前先查看这些头文件(扩展名为“.vh”和“.svh”的文件)

4

1 回答 1

1

-h 选项的语法是-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.

于 2012-10-11T11:21:43.587 回答