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

Integration with the speedbar #1025

Closed
veripoolbot opened this issue Jan 20, 2016 · 14 comments
Closed

Integration with the speedbar #1025

veripoolbot opened this issue Jan 20, 2016 · 14 comments
Assignees

Comments

@veripoolbot
Copy link
Collaborator


Author Name: David Shleifman
Original Redmine Issue: 1025 from https://www.veripool.org
Original Date: 2016-01-20
Original Assignee: Wilson Snyder (@wsnyder)


Introduction

emacs is packaged with the speedbar. Currently, modules are displayed in the speedbar.
But classes are not displayed.

How to reproduce

Note that user should add the following 3 lines to ~/.emacs:

  ;; Add verilog mode to the speedbar
  (require 'speedbar)
  (speedbar-add-supported-extension '(".v" ".sv" ".svh" ))

in order to enable SystemVerilog support in the speedbar.

Enhancement Request

It would be nice to improve the

    Verilog-mode  <==> speedbar

integration so that the classes are shown in the speedbar.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Shleifman
Original Date: 2016-01-20T08:07:44Z


The enhancement can be achieved by changing verilog-imenu-generic-expression, as follows:

(defvar verilog-imenu-generic-expression
  '((nil "^\\s-*\\(?:m\\(?:odule\\|acromodule\\)\\|p\\(?:rimitive\\|rogram\\|ackage\\)\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 1)
     ("*Vars*" "^\\s-*\\(reg\\|wire\\|logic\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)
     ("*Types*" "^\\s-*\\(?:virtual\\s-\\)?\\s-*class\\s-+\\([a-zA-Z_0-9]+\\)" 1)
     ("*Tasks*" "^\\s-*\\(?:virtual\\s-\\)?\\s-*task\\s-+\\([a-zA-Z_0-9:]+\\)\\s-*[(;]" 1)
     ("*Funct*" "^\\s-*\\(?:virtual\\s-\\)?\\s-*function\\s-+\\([a-zA-Z_0-9:]+\\)\\s-*[(;]" 1)
     ("*Interfaces*" "^\\s-*interface\\s-+\\([a-zA-Z_0-9]+\\)" 1)
     ("*Typedefs*" "^\\s-*typedef\\s-+.*\\s-+\\([a-zA-Z_0-9]+\\)\\s-*;" 1))
  "Imenu expression for Verilog mode.  See `imenu-generic-expression'.")

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-01-21T00:32:58Z


  1. I think adding this to verilog-mode will work, please try it.

(defun verilog-speedbar-install-variables ()
(speedbar-add-supported-extension '(".v" ".sv" ".svh")))
(if (featurep 'speedbar)
(verilog-speedbar-install-variables)
(add-hook 'speedbar-load-hook 'verilog-speedbar-install-variables))

  1. Can you/should we merge tasks and functions in verilog-imenu-generic-expression? I think in most use cases people may not be sure which one they want.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Simon Robidas
Original Date: 2016-01-21T19:42:49Z


I believe most people using SystemVerilog develop verification environments, which are usually class-based. These projects usually have lots of classes in various files and directories.

I think classes, interfaces, tasks, functions, typedefs and macros are the basic elements of these environments and should be visible by default, with an option to selectively disable them in the speedbar.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Kaushal Modi
Original Date: 2016-01-22T18:05:46Z


I am in favor of adding classes, tasks, functions, etc to @verilog-imenu-generic-expression@. Currently, I have added the below to the default imenu expression. I do not use speedbar, but I use imenu.

         ("*Classes*"
          "^\\s-*\\(\\(static\\|local\\|virtual\\|protected\\)\\b\\s-+\\)*class\\s-+\\(?1:[A-Za-z_][A-Za-z0-9_]+\\)" 1)
         ("*Tasks*"
          "^\\s-*\\(\\(static\\|local\\|virtual\\|protected\\)\\b\\s-+\\)*task\\s-+\\(\\(static\\|automatic\\)\\s-+\\)*\\(?1:[A-Za-z_][A-Za-z0-9_:]+\\)" 1)
         ("*Functions*"
          "^\\s-*\\(\\(static\\|local\\|virtual\\|protected\\)\\b\\s-+\\)*function\\s-+\\([a-z_]+\\s-+\\)*\\(?1:[A-Za-z_][A-Za-z0-9_:]+\\)" 1)

"My config":https://github.com/kaushalmodi/.emacs.d/blob/c4f8b9120c58142d7a1a10ea65d4f06fcf3f2c04/setup-files/setup-verilog.el#L361

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Bhaumik Darji
Original Date: 2016-02-02T05:27:33Z


Dear all,

I am grateful to all of you. Thanks a lot for sharing this.

I didn't have idea about iMenu and speedbar before. But I will try them. Thanks again.

Cheers,
Bhaumik

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-02-09T00:41:08Z


If someone could provide a specific patch against verilog-mode.el, I'll consider it. Note my question above about if we should consider tasks/functions as separate name spaces, or combine them into one.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Kaushal Modi
Original Date: 2016-02-10T02:47:13Z


Can you/should we merge tasks and functions in verilog-imenu-generic-expression?

I would personally like to keep tasks and functions separate.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Shleifman
Original Date: 2016-02-19T14:01:29Z


One of my honourable colleagues pointed out that:

??This function does not get picked up:?? ```function void qsb2_prd_cnsm_base_seq::map_template_data ();


> ??This one gets tagged wrong:?? ```function qsb2_prd_cnsm_base_seq::new(string name="qsb2_prd_cnsm_base_seq");

??The tag comes up missing the qsb2_ prefix.: @prd_cnsm_base_seq::new@??

Here is a fixed version. It turns out that the user doesn't need to modify +verilog-mode.el+. Instead, he/she may put the following code into +.emacs+ file:

;; Set imenu patterns
(setq verilog-imenu-generic-expression 
  '((nil "^\\s-*\\(?:m\\(?:odule\\|acromodule\\)\\|p\\(?:rimitive\\|rogram\\|ackage\\)\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 1)
     ("*Vars*" "^\\s-*\\(reg\\|wire\\|logic\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)
     ("*Classes*" "^\\s-*\\(?:virtual\\s-+\\)?class\\s-+\\([a-zA-Z_0-9]+\\)" 1)
     ("*Tasks*" "^\\s-*\\(?:virtual\\s-+\\)?task\\s-+\\([a-zA-Z_0-9:]+\\)\\s-*[(;]" 1)
     ("*Funct*" "^\\s-*\\(?:virtual\\s-+\\)?function\\s-+\\(?:\\w+\\s-+\\)?\\([a-zA-Z_0-9:]+\\)\\s-*[(;]" 1)
     ("*Interfaces*" "^\\s-*interface\\s-+\\([a-zA-Z_0-9]+\\)" 1)
     ("*Types*" "^\\s-*typedef\\s-+.*\\s-+\\([a-zA-Z_0-9]+\\)\\s-*;" 1)))

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Shleifman
Original Date: 2016-02-19T17:00:19Z


Enhancement Request

Currently, verilog-mode defines 2 categories for the +imenu+: Modules and Vars.

It is proposed to add more categories: Classes, Tasks, Funct, Interfaces, Types.

Side effects

User specific configuration

User still remains in full control of the +imenu+ categories: he/she may override the categories which are set by the verilog-mode. For example

;; Add this setting to ~/.emacs
;; Set one imenu category
(setq verilog-imenu-generic-expression 
  '((nil "^\\s-*\\(?:m\\(?:odule\\|acromodule\\)\\|p\\(?:rimitive\\|rogram\\|ackage\\)\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 1)))

Keep in mind that in general, it is easier to reduce the number of categories then to increase it. Indeed, I copied the original definition and erased all but two lines.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-02-22T03:27:47Z


If you think there should be a fix to verilog-mode.el itself for this, please provide a patch that shows the desired code in a reasonable place in the file, thanks.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Shleifman
Original Date: 2016-02-23T17:23:28Z


I am submitting the @verilog-mode.v840.patch@ (attached).

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-02-23T19:27:46Z


Ah, thanks, thought there was more needed.

Anyhow, fixed in git and released as verilog-mode-2016-02-23-61c1bd2-vpo.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Shleifman
Original Date: 2016-03-02T21:26:03Z


I am submitting the @verilog-mode-2016-02-24-3bb6198-vpo.patch@ (attached).

README

  1. Major Problem: imenu categories (defined for the verilog-mode) do not appear in the speedbar. Solution: fixed by implemeting the idea mentioned in the issue1025-2 (post Auto-comment and indentation improvements #2).

  2. Problem: the following elements do not appear in the imenu: Solution: fixed.

interface class
virtual protected task 
virtual protected function
function automatic

  1. Minor Problem: imenu supports the following elements:
static class
local class
protected class

in spite the fact that they do not conform to the SystemVerilog LRM. Solution: retired support for these elements.

HOW-TO apply the patch

It is assumed that @verilog-mode.el@ lives in @~/elisp@.

cd ~
1. download verilog-mode-2016-02-24-3bb6198-vpo.patch to this directory
cp -r elisp elisp.new
cd elisp.new
patch -c -p 1 -i ../verilog-mode-2016-02-24-3bb6198-vpo.patch
1. expected output
patching file verilog-mode.el

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-03-03T00:37:34Z


If you have additional patches please file a new bug as this one is closed. Also the patch as provided should probably also support the rand, randc, and pure qualifiers so that the parsing satisfies the language. Furthermore, you cannot generally define functions in verilog-mode that are not part of the verilog- scope, e.g. you can't create a alist-keys (and I suspect anyways there's a more general function so this isn't needed.)

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

No branches or pull requests

2 participants