-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indentation within generate construct after always block is wrong if generate/endgenerate omitted #1257
Comments
Original Redmine Comment Seems so. The indentation code is generally maintained by patches, so if you could contribute a fix that would be great, otherwise it might be a while before it is fixed. |
Original Redmine Comment I just hit this. What's really weird is if I have the same generate loop twice but have another one in the middle with generate/endgenerate, the first loop will be messed up but the 2nd, identical copy will be indented correctly! So, still no fix after a year? Wish my elisp skill was anywhere near good enough to help fix this. David
|
Original Redmine Comment Even stranger - If I just put
near the top of my module, everything after is indented correctly. Good work-around for now and maybe good clue for finding the verilog-mode problem! David |
This bug can be fixed as shown below, but I am not sure if this is correct from an architectural point of view. diff --git a/verilog-mode.el b/verilog-mode.el
index 8370d4a..248c1f5 100644
--- a/verilog-mode.el
+++ b/verilog-mode.el
@@ -4759,7 +4759,7 @@ More specifically, after a generate and before an endgenerate."
(while (and
(/= nest 0)
(verilog-re-search-backward
- "\\<\\(module\\)\\|\\(connectmodule\\)\\|\\(generate\\)\\|\\(endgenerate\\)\\>" nil 'move)
+ "\\<\\(module\\)\\|\\(connectmodule\\)\\|\\(generate\\)\\|\\(endgenerate\\)\\|\\(if\\)\\>" nil 'move)
(cond
((match-end 1) ; module - we have crawled out
(throw 'done 1))
@@ -4768,7 +4768,9 @@ More specifically, after a generate and before an endgenerate."
((match-end 3) ; generate
(setq nest (1- nest)))
((match-end 4) ; endgenerate
- (setq nest (1+ nest))))))))
+ (setq nest (1+ nest)))
+ ((match-end 5) ; if
+ (setq nest (1- nest))))))))
(= nest 0) )) ; return nest
(defun verilog-in-fork-region-p () |
I thought that might mess up some normal "if" indentation, but it seems OK. If [generate] "if" is there, then probably [generate] "case" also needs to be? Could you make a pull request including this and test cases for the if/case? |
Yes, sure. |
Seems to be fixed in 9def905 |
Author Name: Dan Hopper
Original Redmine Issue: 1257 from https://www.veripool.org
There's an interesting difference in indentation in the below example module. The assign statement after an always block within a generate construct will be correctly indented if it's within a generate region (explicit generate/endgenerate lines), and incorrectly indented if the optional generate region (generate/endgenerate) is omitted.
If you load the below snippet in and reformat, the commented assign statement will be (incorrectly) indented to column 0. If you remove the comments on the generate/endgenerate pairs, it will indent properly. According to SV 1800-2012, the generate/endgenerate pair is optional, so ideally it would treat both versions identically.
I'm not proficient in Lisp so it wasn't immediately obvious to me how to fix the .el file to eliminate.
This occurs with verilog-mode-2017-12-21-39c77b2-vpo.el and also at least as far back as verilog-mode-842.el.
Thanks,
Dan
The text was updated successfully, but these errors were encountered: