Project

General

Profile

[logo] 
 
Home
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

auto-indent messes up when 'class' used as other than SV keyword

Added by L JEPSON over 6 years ago

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?

Replies (4)

RE: auto-indent messes up when 'class' used as other than SV keyword - Added by Wilson Snyder over 6 years ago

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.

RE: auto-indent messes up when 'class' used as other than SV keyword - Added by L JEPSON over 6 years ago

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/

RE: auto-indent messes up when 'class' used as other than SV keyword - Added by Wilson Snyder over 6 years ago

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.

RE: auto-indent messes up when 'class' used as other than SV keyword - Added by L JEPSON about 6 years ago

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.

    (1-4/4)