Add Proposal | Add Analysis | Edit Class, Environment, or Release |
Number | 485
|
Category | errata
|
Synopsis | Multi-line string literals?
|
State | open
|
Class | errata-discuss
|
Arrival-Date | Sep 20 2003
|
Originator | Stephen Williams <steve@icarus.com>
|
Release | 2001b
|
Environment |
|
Description |
I received a bug report recently where a user claimed that this example worked with every compiler he tried (other then Icarus Verilog, which gave him an error): $display ( "Humpty Dumpty sat on a \ wall. Humpty Dumpty had a great fall." ); Note that he is using a back-slash to cause the string to be continued on the next line. However, I see this explicit statement in IEEE1364-2001 Section 2.6 Strings: A string is a sequence of characters enclosed by double quotes ("") and *contained on a single line*. [emphasis added] If the user is user is correct that many tools accept this, then is this an error in the standard? (In this case, I hope not.) I think what is written in the standard is reasonable and I would like to tell this user that his other tools are buggy here. The \<NL> can continue a macro on the next line, but it seems unreasonable to allow it to continue strings as well. For what it's worth, He would write this in C like so: printf ( "Humpty Dumpty sat on a " "wall, Humpty Dumpty had a great fall." ); Adjacent string literals are concatenated in C. -- Steve Williams "The woods are lovely, dark and deep. steve at icarus.com But I have promises to keep, http://www.icarus.com and lines to code before I sleep, http://www.picturel.com And lines to code before I sleep." |
Fix |
|
Audit-Trail |
From: Shalom Bresticker <Shalom.Bresticker@motorola.com> To: Stephen Williams <steve@icarus.com> Cc: etf-bugs@boyd.com Subject: Re: errata/485: Multi-line string literals? Date: Sun, 21 Sep 2003 16:09:38 +0300 Verilog-XL gave me the following: Error! Literal string not terminated in text macro [Verilog-LSNTM] "qq.v", 6: Error! syntax error [Verilog] "qq.v", 7: wall. Humpty Dumpty<- Error! Literal string not terminated [Verilog-LSNT] "qq.v", 7: However, both VCS and NCV accepted it. Shalom Stephen Williams wrote: > $display > ( > "Humpty Dumpty sat on a \ > wall. Humpty Dumpty had a great fall." > ); -- Shalom Bresticker Shalom.Bresticker@motorola.com Design & Reuse Methodology Tel: +972 9 9522268 Motorola Semiconductor Israel, Ltd. Fax: +972 9 9522890 POB 2208, Herzlia 46120, ISRAEL Cell: +972 50 441478 From: Steven Sharp <sharp@cadence.com> To: etf-bugs@boyd.com, Shalom.Bresticker@motorola.com Cc: Subject: Re: errata/485: Multi-line string literals? Date: Mon, 22 Sep 2003 15:53:54 -0400 (EDT) In NC-Verilog at least, this is not a string continuation. Rather, the backslash has escaped the newline, so that it is treated as a character of the string rather than its normal role of terminating the line. The result has a newline embedded in the string. Note that this is not an important capability, since you could get the same effect by putting \n in the string. BTW, it is possible to get the desired effect using an explicit concatenation: $display ( {"Humpty Dumpty sat on a ", "wall. Humpty Dumpty had a great fall."} ) Steven Sharp sharp@cadence.com From: Stefen Boyd <stefen@boyd.com> To: etf-bugs@boyd.com Cc: Subject: Re: errata/485: Multi-line string literals? Date: Mon, 22 Sep 2003 23:04:58 -0700 >Date: Sat, 20 Sep 2003 21:41:10 -0700 >From: mail <mail@boyd.com> >Subject: Failed bug submission from Bruce LaVigne <bruce@hp.com>, bruce@hp > > >From bruce@hp.com Sat Sep 20 21:41:10 2003 >Received: from atlrel6.hp.com (atlrel6.hp.com [156.153.255.205]) > by max.boyd.com (8.11.0/8.11.0) with ESMTP id h8L4f9826567 > for <etf-bugs@boyd.com>; Sat, 20 Sep 2003 21:41:09 -0700 >Received: from rosemail.rose.hp.com (rosemail.rose.hp.com [15.96.64.26]) > by atlrel6.hp.com (Postfix) with ESMTP > id 0ECB91C01415; Sun, 21 Sep 2003 01:31:46 -0400 (EDT) >Received: from hp.com (bruce@hs180226.nsr.hp.com [15.244.180.226]) by >rosemail.rose.hp.com with SMTP (8.7.1/8.7.3 SMKit7.02) id WAA05611; Sat, >20 Sep 2003 22:31:44 -0700 (PDT) >Message-ID: <3F6D38B0.30401@hp.com> >Date: Sat, 20 Sep 2003 22:35:44 -0700 >From: Bruce LaVigne <bruce@hp.com> >User-Agent: Mozilla/5.0 (X11; U; HP-UX 9000/780; en-US; rv:1.0.1) >Gecko/20020827 Netscape/7.0 >X-Accept-Language: en-us, en >MIME-Version: 1.0 >To: Stephen Williams <steve@icarus.com> >Cc: etf-bugs@boyd.com >Subject: Re: errata/485: Multi-line string literals? >References: <3F6D30B0.50003@icarus.com> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed >Content-Transfer-Encoding: 8bit > >This is my first response to this email list, so please forgive >my naiveté'. I have not seen simulators handle the backslashed >strings, but what I *have* seen in all the simulators we use >but cannot find in the documentation for those simulators, >and would be hard pressed to do without, is syntax such as: > >$display("some stuff here with %d variables\n", foo, > "some more string here with more %x variables\n", bar); > >Since one can only count on a single $display statement from >being uninterrupted, we sometimes have 50+ lines in a single >$display - when dumping a data structure which we don't want >mixed up with other output. > >Bruce LaVigne >Hewlett-Packard > >Stephen Williams wrote: > > Precedence: bulk > > > > > > > >>Number: 485 > >>Category: errata > >>Originator: Stephen Williams <steve@icarus.com> > >>Environment: > >>Description: > > > > > > I received a bug report recently where a user claimed that > > this example worked with every compiler he tried (other then > > Icarus Verilog, which gave him an error): > > > > $display > > ( > > "Humpty Dumpty sat on a \ > > wall. Humpty Dumpty had a great fall." > > ); > > > > Note that he is using a back-slash to cause the string to be > > continued on the next line. However, I see this explicit statement > > in IEEE1364-2001 Section 2.6 Strings: > > > > A string is a sequence of characters enclosed by double quotes ("") > > and *contained on a single line*. [emphasis added] > > > > If the user is user is correct that many tools accept this, then > > is this an error in the standard? (In this case, I hope not.) > > > > I think what is written in the standard is reasonable and I would > > like to tell this user that his other tools are buggy here. The \<NL> > > can continue a macro on the next line, but it seems unreasonable to > > allow it to continue strings as well. > > > > For what it's worth, He would write this in C like so: > > > > printf > > ( > > "Humpty Dumpty sat on a " > > "wall, Humpty Dumpty had a great fall." > > ); > > > > Adjacent string literals are concatenated in C. > > From: Steven Sharp <sharp@cadence.com> To: etf-bugs@boyd.com, stefen@boyd.com Cc: Subject: Re: errata/485: Multi-line string literals? Date: Tue, 23 Sep 2003 16:06:54 -0400 (EDT) > >This is my first response to this email list, so please forgive > >my naiveté'. I have not seen simulators handle the backslashed > >strings, but what I *have* seen in all the simulators we use > >but cannot find in the documentation for those simulators, > >and would be hard pressed to do without, is syntax such as: > > > >$display("some stuff here with %d variables\n", foo, > > "some more string here with more %x variables\n", bar); Yes, this is specifically covered by the standard in 17.1.1 (2001), which allows an arbitrarily long list of arguments, and allows any of them to be format strings. For the $display situation, this is the easiest solution. If someone wants to print a long string, they can break it up into multiple shorter string arguments. They will be printed one after the other, as if concatenated. This probably covers over 90% of the need for long string constants. The $sreadmem system tasks also allow multiple string arguments (though these are still nonstandard). In other situations calling for a single excessively long string value, the concatenation approach that I suggested would work. Steven Sharp sharp@cadence.com From: Shalom Bresticker <Shalom.Bresticker@motorola.com> To: Steven Sharp <sharp@cadence.com> Cc: etf-bugs@boyd.com Subject: Re: errata/485: Multi-line string literals? Date: Thu, 25 Sep 2003 18:15:28 +0300 Steven Sharp wrote: > In NC-Verilog at least, this is not a string continuation. Rather, the > backslash has escaped the newline, so that it is treated as a character > of the string rather than its normal role of terminating the line. The > result has a newline embedded in the string. Note that this is not an > important capability, since you could get the same effect by putting \n > in the string. And VCS does the same thing. That is, you get an embedded newline, not just a continuation. This is different from what we talked about earlier, and different from the example below. Shalom > BTW, it is possible to get the desired effect using an explicit concatenation: > > $display > ( > {"Humpty Dumpty sat on a ", > "wall. Humpty Dumpty had a great fall."} > ) -- Shalom Bresticker Shalom.Bresticker@motorola.com Design & Reuse Methodology Tel: +972 9 9522268 Motorola Semiconductor Israel, Ltd. Fax: +972 9 9522890 POB 2208, Herzlia 46120, ISRAEL Cell: +972 50 441478 |
Unformatted |
|
Hosted by Boyd Technology