Skip to content
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

Question: auto-indent messes up when 'class' used as other than SV keyword #783

Closed
veripoolbot opened this issue Jun 17, 2014 · 4 comments
Closed
Labels

Comments

@veripoolbot
Copy link
Collaborator


Author Name: L JEPSON
Original Redmine Message: 1372 from https://www.veripool.org


Emacs auto-indent for verilog-mode messes up when 'class' is used other than as an SV keyword.
 
begin
    xyz.field1 = 1;
    xyz.field2 = 2;
    xyz.class =  3;
       xyz.field3 = 4;
end

Because the property name of an object (with instance name xyz above) is named "class", it screws up indentation.


From my .emacs file:
;;;;;;;;;;;;;;;;;;;;;;
;; Mac's Verilog Mode
;;;;;;;;;;;;;;;;;;;;;;
(defun prepend-path ( my-path )
  (setq load-path (cons (expand-file-name my-path) load-path)))
(defun append-path ( my-path )
  (setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the elisp directory which is ...
(prepend-path "~/elisp")
;; Load verilog mode only when needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
;; Any files that end in .__ should be in verilog mode ...
(setq auto-mode-alist (cons  '("\\.v\\'"    . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons  '("\\.vh\\'"   . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons  '("\\.hv\\'"   . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons  '("\\.sv\\'"   . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons  '("\\.svh\\'"   . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons  '("\\.lib\\'"  . verilog-mode) auto-mode-alist))
;; Any files in verilog mode should have their keywords colorized
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))


;; User customization for Verilog mode
(setq verilog-indent-level                3
       verilog-indent-level-module         3
       verilog-indent-level-declaration    3
       verilog-indent-level-behavioral     3
       verilog-case-indent                 2
       verilog-auto-newline                0
       verilog-auto-indent-on-newline      t
       verilog-tab-always-indent           t
       verilog-auto-endcomments            t
       verilog-minimum-comment-distance    0
       verilog-indent-begin-after-if       t
       verilog-auto-lineup                 '(all))


Does anyone have a fix for this?

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2014-06-18T00:17:56Z


This is not going to be fixed. Using keywords other than as keywords besides being a bad idea and not supported by many other tools, is too hard to support.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: L JEPSON
Original Date: 2014-06-20T16:44:06Z


In posting this example code, I retyped the issue as a simpler example w/o compiling/simulating it. In doing so, I changed CLASS to class.

I discovered from SV Spec 1800-2012.pdf section 5.6.2, Keywords: "All keywords are defined in lowercase only."
Our problem arose b/c the offending code was generated code, originating from non-SystemVerilog (or just plain text) in another file.

While I think our team should not use keywords with different capitalization, is there any chance you'll specify keywords to only be lowercase in your code?

Either way, your tool is great.

Thanks for the quick feedback.
ljepson74

Also on: http://forums.accellera.org/topic/1908-emacs-auto-indent-for-verilog-mode-messes-up-when-class-used-as-other-than-sv-keyword/

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2014-06-21T01:28:26Z


You can "(setq case-fold-search nil)" which should work around this, either in your .emacs or a verilog-mode-hook. It will have the side effect you probably won't like of making search by default case sensitive. The fix to verilog mode is similar, it's just that there are a LOT of entry points into the code to fix.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: L JEPSON
Original Date: 2014-07-01T16:45:53Z


If you do have a chance to address this, another area where verilog-mode might be changed is when I forward typedef a class (as in sec 6.18 of SV spec 1800-2012).

ex:
typedef class type_identifier;

I have a few of these on adjacent lines and the first one has no indent (as if I were starting a class) and the following ones are all indented, as if they were inside the class of the first one.

Just an fyi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant