VIM tags file builder for Verilog & SystemVerilog

1,717 views
Skip to first unread message

googler

unread,
Jul 30, 2008, 3:08:24 PM7/30/08
to vim_use
I use Verilog and SystemVerilog as languages for coding and vim as
text editor. I am wondering if there is any tags file builder that
works for both Verilog and SystemVerilog files and cover not just
modules, but also functions, classes etc. I came across a couple of
such scripts on searching (haven't tried them yet), but they seem to
be written only for Verilog. Does anybody know about the kind of
program/script I am looking for? Thanks.

Dominique Pelle

unread,
Jul 30, 2008, 4:40:48 PM7/30/08
to vim...@googlegroups.com


I have not used Verilog or SystemVerilog myself, but doing
"ctags --list-languages" it appears that Exuberant ctags
supports at least Verilog:

$ ctags --version
Exuberant Ctags 5.7, Copyright (C) 1996-2007 Darren Hiebert
Compiled: Mar 12 2008, 08:23:02
Addresses: <dhie...@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex

$ ctags --list-languages
Asm
Asp
Awk
Basic
BETA
C
C++
C#
Cobol
Eiffel
Erlang
Fortran
HTML
Java
JavaScript
Lisp
Lua
Make
Pascal
Perl
PHP
Python
REXX
Ruby
Scheme
Sh
SLang
SML
SQL
Tcl
Vera
Verilog <---
Vim
YACC

-- Dominique

ssmi...@gmail.com

unread,
Jul 31, 2008, 4:19:09 AM7/31/08
to vim_use
I have been looking for something similar for a long time.

On Jul 30, 9:40 pm, "Dominique Pelle" <dominique.pe...@gmail.com>
wrote:
> On Wed, Jul 30, 2008 at 9:08 PM, googler <pinaki_...@yahoo.com> wrote:
> > I use Verilog and SystemVerilog as languages for coding and vim as
> > text editor. I am wondering if there is any tags file builder that
> > works for both Verilog and SystemVerilog files and cover not just
> > modules, but also functions, classes etc. I came across a couple of
> > such scripts on searching (haven't tried them yet), but they seem to
> > be written only for Verilog. Does anybody know about the kind of
> > program/script I am looking for? Thanks.
>
> I have not used Verilog or SystemVerilog myself, but doing
> "ctags --list-languages" it appears that Exuberant ctags
> supports at least Verilog:
>
> $ ctags --version
> Exuberant Ctags 5.7, Copyright (C) 1996-2007 Darren Hiebert
> Compiled: Mar 12 2008, 08:23:02
> Addresses: <dhieb...@users.sourceforge.net>,http://ctags.sourceforge.net

Tony Mechelynck

unread,
Jul 31, 2008, 2:10:51 PM7/31/08
to vim...@googlegroups.com
On 31/07/08 10:19, ssmi...@gmail.com wrote:
> I have been looking for something similar for a long time.
>
> On Jul 30, 9:40 pm, "Dominique Pelle"<dominique.pe...@gmail.com>
> wrote:
>> On Wed, Jul 30, 2008 at 9:08 PM, googler<pinaki_...@yahoo.com> wrote:
>>> I use Verilog and SystemVerilog as languages for coding and vim as
>>> text editor. I am wondering if there is any tags file builder that
>>> works for both Verilog and SystemVerilog files and cover not just
[...]

When looking for a program to build tag files, always check Exuberant
Ctags first. It's almost unbelievable how many languages it supports,
and, to boot, even if your language isn't supported out of the box, you
can (if you're clever enough) add, once and for all, configuration
statements to define how to support it.


Best regards,
Tony.
--
It has been said that man is a rational animal. All my life I have
been searching for evidence which could support this.
-- Bertrand Russell

Abhishek

unread,
Jul 31, 2008, 11:49:27 PM7/31/08
to vim_use
I tried using tags for verilog but got stuck with ctags. Maybe its a
minor issue somewher. I haven't spent time looking for the problem
yet. Can anyone upload/point to a link with a tutorial on how to make
a verilog tag system work?
Regards,
Abhishek

On Jul 31, 11:10 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> On 31/07/08 10:19, ssmit...@gmail.com wrote:> I have been looking for something similar for a long time.

Tony Mechelynck

unread,
Aug 1, 2008, 12:27:13 AM8/1/08
to vim...@googlegroups.com
On 01/08/08 05:49, Abhishek wrote:
> I tried using tags for verilog but got stuck with ctags. Maybe its a
> minor issue somewher. I haven't spent time looking for the problem
> yet. Can anyone upload/point to a link with a tutorial on how to make
> a verilog tag system work?
> Regards,
> Abhishek
>
The "canonical" docs (not a tutorial) are at "man ctags" and/or "info
ctags" -- if you got them, which may depend on your system.

Does the reply to "ctags --version" include "Exuberant Ctags"?


Best regards,
Tony.
--
Cynic, n.:
A blackguard whose faulty vision sees things as they are, not
as they ought to be. Hence the custom among the Scythians of plucking
out a cynic's eyes to improve his vision.
-- Ambrose Bierce, "The Devil's Dictionary"

googler

unread,
Aug 1, 2008, 6:02:35 PM8/1/08
to vim_use


On Jul 31, 11:27 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
I just tried using ctags on my Verilog files (but not SystemVerilog).
It works fine for the most part. However, I found one issue. There are
two different files, say A and B, and each have a function defined
within it with the same name. Each calls its respective function. But
pressing CTRL-] on the function call in file A, takes me to the
definition in file B.

Is there a way I can go to the definition of a tag and it opens up in
a new tab (especially useful if the definition is in a different
file)? If I do CTRl-W CTRL-] it opens up in a new split window.

Tony Mechelynck

unread,
Aug 1, 2008, 6:17:49 PM8/1/08
to vim...@googlegroups.com

see
:help :tselect
:help :stselect

>
> Is there a way I can go to the definition of a tag and it opens up in
> a new tab (especially useful if the definition is in a different
> file)? If I do CTRl-W CTRL-] it opens up in a new split window.

Any ex-command which opens a new window can be made to open a new tab
instead, by prefixing it with ":tab". So ":tab tsel something" will open
a new tab for the file containing "something", after showing you all
occurrences of that tag and prompting you which one you want.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
92. It takes you two hours to check all 14 of your mailboxes.

googler

unread,
Aug 1, 2008, 9:11:15 PM8/1/08
to vim_use


On Aug 1, 5:17 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> On 02/08/08 00:02, googler wrote:
>
> > I just tried using ctags on my Verilog files (but not SystemVerilog).
> > It works fine for the most part. However, I found one issue. There are
> > two different files, say A and B, and each have a function defined
> > within it with the same name. Each calls its respective function. But
> > pressing CTRL-] on the function call in file A, takes me to the
> > definition in file B.
>
> see
>         :help :tselect
>         :help :stselect
>
Thanks Tony. On using tselect command, I found that it is giving me
only one option (the definition in file B) for the problem I had
described earlier. So it seems that ctags didn't build the tags file
correctly for some reason.

>
> > Is there a way I can go to the definition of a tag and it opens up in
> > a new tab (especially useful if the definition is in a different
> > file)? If I do CTRl-W CTRL-] it opens up in a new split window.
>
> Any ex-command which opens a new window can be made to open a new tab
> instead, by prefixing it with ":tab". So ":tab tsel something" will open
> a new tab for the file containing "something", after showing you all
> occurrences of that tag and prompting you which one you want.
>

Okay, this is cool.. I can now prefix my command with 'tab'. So say I
want to go to the definition of 'something' directly, I type ':tab tag
something'. This worked fine, but I need to type the word 'something',
as opposed to simply pressing CTRL-] in the other case. Is there a way
I can avoid typing the full word? I was wishing that there might be
some register for this (hmm.. maybe that's a stupid thought as
registers get their values from operations), but seems like there
isn't.

Ben Schmidt

unread,
Aug 1, 2008, 9:37:02 PM8/1/08
to vim...@googlegroups.com
> Okay, this is cool.. I can now prefix my command with 'tab'. So say I
> want to go to the definition of 'something' directly, I type ':tab tag
> something'. This worked fine, but I need to type the word 'something',
> as opposed to simply pressing CTRL-] in the other case. Is there a way
> I can avoid typing the full word? I was wishing that there might be
> some register for this (hmm.. maybe that's a stupid thought as
> registers get their values from operations), but seems like there
> isn't.

:help <cword>

though it's awkard and you need to use exec as well. Perhaps a mapping
like this would do the trick for you:

:map <C-]> :exec "tab tag ".expand('<lt>cword>')<CR>

You'll get a lot of tabs very quickly though! Perhaps mapping <C-w><C-]>
would be smarter so you can get a new tab only when you want one. I find
usually <C-]> along with <C-t> or <C-o> is better than <C-w><C-]>.

Ben.


Ben Schmidt

unread,
Aug 1, 2008, 9:41:18 PM8/1/08
to vim...@googlegroups.com
> Okay, this is cool.. I can now prefix my command with 'tab'. So say I
> want to go to the definition of 'something' directly, I type ':tab tag
> something'. This worked fine, but I need to type the word 'something',
> as opposed to simply pressing CTRL-] in the other case. Is there a way
> I can avoid typing the full word? I was wishing that there might be
> some register for this (hmm.. maybe that's a stupid thought as
> registers get their values from operations), but seems like there
> isn't.

O, and in addition to my previous post, there kinda is a register for
this...well, you access it like a register! See

:help c_CTRL-R_CTRL-F

So an alternative to the mapping I wrote in my last post would be

:map <C-]> :tab tag <C-R><C-W><CR>

The comments in my last post about it still apply, of course.

Ben.


Reply all
Reply to author
Forward
0 new messages