使用 emacs 折叠/识别 verilog 代码中当前的 `ifdef 块
我的工作涉及浏览包含“ifdef 块”的长 verilog 代码。我的主要编辑器是 emacs。以下是一个典型示例:
module Foo(
...
...
);
// Inputs, Outputs
...
`ifdef CONDITION_1
...
...
`else // CONDITION_1
...
...
`ifdef CONDITION_2
...
...
`endif //CONDITION_2
...
...
foo <= 1'b1;
...
...
`endif // CONDITION_1
如您所见,foo <= 1'b1;
位于 ifdef CONDITION_1 的 else 块中 假设我的点位于 foo <= 1'b1;
行上,有什么方法可以直接移动到 ifdef CONDITION_1 行或折叠代码,以便我可以看条件1?我尝试使用向后增量搜索,但在这种情况下,我最终得到 ifdef CONDITION_2 我尝试使用 hide-ifdef-mode,但它识别的是 #ifdef 而不是 `ifdef。这些块不使用括号。所以使用 CMu 没有帮助
My work invovles browsing through long verilog codes which incorporates `ifdef blocks. My primary editor is emacs. Following is a typical example:
module Foo(
...
...
);
// Inputs, Outputs
...
`ifdef CONDITION_1
...
...
`else // CONDITION_1
...
...
`ifdef CONDITION_2
...
...
`endif //CONDITION_2
...
...
foo <= 1'b1;
...
...
`endif // CONDITION_1
As you can see foo <= 1'b1;
is in the else block of ifdef CONDITION_1 Assuming that my point is on the line foo <= 1'b1;
is there any way by which I could directly move to the line ifdef CONDITION_1 or fold the code so that I can see CONDITION1? I tried using backward incremental search but in that case I end up at ifdef CONDITION_2
i tried using the hide-ifdef-mode but it identifies #ifdef instead of `ifdef. These blocks do not use parenthesis. And so using C-M-u doesn't help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将做到这一点,尽管对于上面的示例,它将停止在
语句处,因为这是包含
foo
赋值的内容:This will do it, although for your example above it will stop at the
statement since that is what is enclosing the
foo
assignment:elisp 常量
hif-cpp-prefix
控制hide-ifdef-mode
使用的基本语法。我猜您可以将其定义为如下所示。 (警告,这未经测试,因为我自己不使用 verilog。)请注意,这是使用
defconst
而不是defvar
定义的,因此的编译版本hide-ifdef-mode
可能仍使用原始值。将未编译的文件加载到 Emacs 中可能会解决这个问题。The elisp constant
hif-cpp-prefix
controls the basic syntax thathide-ifdef-mode
use. I guess that you could define it to something like the following. (Warning, this is untested, as I don't use verilog myself.)Note that this is defined using
defconst
rather thandefvar
, so the compiled version ofhide-ifdef-mode
might still use the original value. Loading the uncompiled file into Emacs would probably solve this.