ljepson74

string literal spanning a newline (using a backslash) - vendor supported?

11 posts in this topic

A backslash can be used to extend a string literal onto the next line if "the new line is immediately preceded by a \ (backslash)."

    Section 5.9 of 1800-2012.pdf, the SystemVerilog LRM

 

I don't think I have ever been able to get this work and w/o looking I seem to recall it has been in Verilog/SystemVerilog for a while.

 

Can someone tell me if vendors support this and perhaps correct the code below on edaplayground?

 

example from LRM:

$display("Humpty Dumpty sat on a wall. \
Humpty Dumpty had a great fall.");

See example here (on Sept 29, urls below are updated in response to Tudor comment below.  thx.):

http://www.edaplayground.com/x/4Tyw 

https://www.edaplayground.com/x/4Tyw    //if the above does not work, try this one, with https://

Share this post


Link to post
Share on other sites

This works for me in Modelsim/Questa. Note that the newline has been escaped and the resulting string will be displayed as a single line. If you want a newline embedded in the string, you need to add \n.

Share this post


Link to post
Share on other sites

Thanks, Tudor and Dave.

*) I updated the urls, per Tudor comment.

*) Aldec and Mentor simulators were the two that I did not use.  I now tried Aldec on edaplayground and see that it works.  Unfortunately, with regards to this SV feature, I'm not using either of these simulators.  Can anyone confirm that neither Cadence nor Synopsys support this?  (Well, I guess I've figured out that they don't, now that I have witnessed at least one simulator support it.  Aldec's.)

 

 

Thanks.

Share this post


Link to post
Share on other sites

I think the problem is with EDAplayground.com appending extra characters at the end of each line. Look carefully at the error messages coming from each tool and you'll see a good explanation of the problem. I believe Aldec is incorrectly ignoring that extra character, so it appears that it is "working".

Share this post


Link to post
Share on other sites

EDAboard.com ?
Is that a typo?  You just mean my text editor, right?

I confirmed that there is no extra character at the end of the line.

 

(Note: the links above have been fixed.)

Share this post


Link to post
Share on other sites

Doulos/Victor, any thoughts?

Is your editor causing mischief and adding characters at the ends of lines?

 

Dave, I see your point now.  i.e. In edaplayground the error message seems to point to a space after the backslash.

Thanks.

Share this post


Link to post
Share on other sites

Yes, thanks Dave.  (I shouldn't assume everyone I've seen on here monitors all the threads.)

Feedback from Victor (the creator of edaplayground) on the edaplayground forum:

I've seen this before. The server uses "\r\n" DOS line endings, and some simulators don't grok these. The fix for EDA Playground would be to use "\n" line endings instead of "\r\n"
 
You can see this by using "Download files after run"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now