[英]Align code in Emacs Verilog Mode?
I'm used to writing code in VHDL in emacs, which has the nice beautify functionality that will align signal assignments. 我习惯用emacs中的VHDL编写代码,它具有很好的美化功能,可以对齐信号分配。 Is there something similar with the Verilog Mode?
是否有与Verilog模式类似的东西?
Convert this: 转换这个:
r_Tx_Done <= 1'b1;
r_Clock_Count <= 0;
if (r_Done == 1'b1)
begin
r_SM_Main <= s_CLEANUP;
o_Tx_Active <= 1'b0;
end
To This: 对此:
r_Tx_Done <= 1'b1;
r_Clock_Count <= 0;
if (r_Done == 1'b1)
begin
r_SM_Main <= s_CLEANUP;
o_Tx_Active <= 1'b0;
end
Verilog mode does a good job keeping if
else
begin
end
aligned, but it doesn't align assignments like I want. Verilog的模式做得很好保持
if
else
begin
end
一致,但像我想它不对齐分配。 Note that inside the if statement doesn't align to <=
outside the if statement. 请注意,if语句内部未与if语句之外的
<=
对齐。 Essentially I want each begin/end block treated separately. 基本上我希望每个开始/结束块单独处理。
I use verilog mode, and I have found this works by default. 我使用verilog模式,我发现默认情况下这是有效的。
Cx h
to highlight the entire buffer. Cx h
以突出显示整个缓冲区。 TAB
to get it to beautify everything. TAB
让它美化一切。 Much easier and less tedious! Based on this answer you can try to customize align-rules-list
. 根据此答案,您可以尝试自定义
align-rules-list
。
Something like this should help: 这样的事情应该有所帮助:
(eval-after-load "align"
'(add-to-list 'align-rules-list
'(verilog-assignment
(regexp . "\\(\\s-*\\)<=")
(mode . '(verilog-mode))
(repeat . nil))))
Now Mx align
should apply the new alignment rule. 现在
Mx align
应该应用新的对齐规则。
In Verilog mode for GNU Emacs 24.3.1 you can place the cursor on the non-blocking assignment operator "<=" in any of the assignment operations. 在GNU Emacs 24.3.1的Verilog模式中,您可以将光标放在任何赋值操作中的非阻塞赋值运算符“<=”上。 For instance, in the top portion of the code:
例如,在代码的顶部:
r_Tx_Done <= 1'b1;
r_Clock_Count <= 0;
place the cursor on either of the assignment operators and type Cc =
. 将光标放在任一赋值运算符上并键入
Cc =
。 The code will now become 代码现在将成为
r_Tx_Done <= 1'b1;
r_Clock_Count <= 0;
This operation will only be performed in that section of code. 此操作仅在该部分代码中执行。 This operation will not jump into any other statements: if-else, case, always, etc. In order to perform the same operation in another statement you would have to go inside that statement click on an assignment operator and type
Cc =
again. 此操作不会跳转到任何其他语句:if-else,case,always等。为了在另一个语句中执行相同的操作,您必须进入该语句,单击赋值运算符并再次键入
Cc =
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.