[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  Schedule::Load
  SVN::S4
  Synopsys-modes
  SystemPerl
  Verilog-Pli
  Voneline
  Vregs
General Info
  Papers

Issue #311

vppreproc corner-case comment issue

Added by Gene Sullivan over 1 year ago. Updated about 1 year ago.

Status:Closed Start date:01/06/2011
Priority:Low Due date:
Assignee:Wilson Snyder % Done:

0%

Category:-
Target version:-

Description

Consider the following Verilog code in a file I named "tb.v":

module tb;
    reg/* nasty comment */foo;
endmodule

There is a block comment between a keyword and an identifier, with no whitespace surrounding the block comment.

Using vppreproc to remove the comments produces output which is not legal Verilog syntax.

vppreproc --nocomment --noline tb.v

module tb;
    regfoo;
endmodule

The deleted block comment effectively concatenates the keyword and the identifier, leaving illegal Verilog code. I used the --noline option to simplify the output; the issue remains if --noline is not used.

The Verilog LRM (1800-2009) is not specific enough to describe what should be done in the case. However, the two simulators I used (VCS and NC-Verilog) compiled the code with the nasty comment cleanly. I also used the NC decompile utlilty (ncdc), which shows that it replaced the block comment with a single space. Running ncverilog/ncdc produces:

module tb;
    reg foo;
endmodule
For what it's worth, gcc also replaces the comment with a space:
gcc -x c -E tb.v

Ideally, I guess vppreproc should replace the block comment with a single space in this case.

Since I didn't have much luck digging through the source code to try a track down where comments are removed, I can not provide a patch.


I am using recent (2010) versions of VCS (Synopsys) and NC-Verilog (Cadence). I am using the latest version of vppreproc (3.305).

$ perl -v

This is perl, v5.8.9 built for x86_64-linux

Copyright 1987-2008, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

$ vppreproc --version
Version 3.305

$ ncverilog -version
TOOL:   ncverilog       10.20-p008

$ vcs tb.v | head -5
                         Chronologic VCS (TM)
            Version D-2010.06 -- Thu Jan  6 11:55:32 2011
               Copyright (c) 1991-2010 by Synopsys Inc.
                         ALL RIGHTS RESERVED

History

Updated by Wilson Snyder over 1 year ago

  • Status changed from New to Assigned
  • Assignee set to Wilson Snyder

Thanks for the report, I think you're right it should become a space. I'm always amazed how the preprocessor which is given so few pages in the spec, causes so many issues.

Updated by Wilson Snyder over 1 year ago

  • Status changed from Assigned to Resolved

Fixed in git for 3.306.

Give it a try; it adds spaces at every removed comment, block or line, though only block should be strictly required.

Updated by Gene Sullivan over 1 year ago

I have not been able to give it a try. I retrieved the files from git, but when I try to install, the make dies with the bison error, although I have bison version 1.875c installed.

If it works on my small contrived module, that should be good enough.

Next time, I'll try to remember to create (or patch) a test for you.

Updated by Wilson Snyder about 1 year ago

  • Status changed from Resolved to Closed

In 3.306.

Also available in: Atom