• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How to interpret a single backslash from an input file?

Stats

  • Replies 4
  • Subscribers 147
  • Views 693
  • Members are here 0

How to interpret a single backslash from an input file?

MM202511045434
MM202511045434 26 days ago

I am trying to read a net name from an input file which looks like this: "DUT.XPLL_ANA_TOP\|CLKN\\<2\\>"

I am using gets() function to read net name, since I want to read the file one line at a time. I am entering the net name in the input file as: DUT.XPLL_ANA_TOP\|CLKN\<2\>

But gets() interprets it as "DUT.XPLL_ANA_TOP\\|CLKN\\<2\\>", i.e., it automatically converts the single backslash to double backslash. The last 2 double backslashes in the net name are fine, since I want them to be there, but I do not want \| to be converted into \\|. 

I also used pcre* function in order to replace \| with \\|.

cs=pcreCompile("[\\|]")
mystr2=pcreReplace(cs mystring "\|" 1)

But that's not working, that interprets mystr2 still as "DUT.XPLL_ANA_TOP\\|CLKN\\<2\\>".

So, how can I interpret \| in a net name correctly?

  • Cancel
  • Sign in to reply
Parents
  • Andrew Beckett
    Andrew Beckett 26 days ago

    You’re misinterpreting what the characters actually are. When you look at the value of a string variable, it shows it using the print representation, which is valid syntax for representing the string as input. Since \ is an escape character within strings, an actual \ has to be escaped to show it in the print representation and hence it would appear as \\.

    If you are expecting it to be read as in the first line, you should enter it exactly as you described in the first place - ie with \| first and then \\<2\\> later. The print representation shows that as \\| and \\\\<2\\\\> at the end. This is correct.

    Assuming that you have the string read by gets in a variable called netName, try just doing:

    printf(“%s\n” netName)

    (apologies if the quotes are wrong - I’m typing this in a bus in Germany!). It will print correctly.

    To convince you, try using parseString(netName “”) - this will split into individual characters. You will see some “\\” amongst those because it has to escape the backslash. It’s still a a single character though - if you do strlen(“\\”) it will return 1.

    Hope that helps!

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MM202511045434
    MM202511045434 24 days ago in reply to Andrew Beckett

    Thanks for the reply, Andrew.

    If you use the net name as it is: DUT.XPLL_ANA_TOP\|CLKN\\<2\\> then you are true that printf() will give you the correct name but when you try to interpret the netName (I named it as clkNetName) in xterm that will show up like this: "DUT.XPLL_ANA_TOP\\|CLKN\\\\<2\\\\>". I want this to show up like: "DUT.XPLL_ANA_TOP\|CLKN\\<2\\>"

    I don't just want to print the clkNetName but want to evaluate certain expressions using that. So, the problem with incorrect interpretation of clkNetName is that xterm gives me warning saying the following:

    WARNING (OCN-6054): The output 'DUT.XPLL_ANA_TOP\|CLKN\\<2\\>' you selected does not exist. Type outputs() to see the list
    of available outputs or type help('v) for more information on the 'v' command.

    Attaching a ss for above warning (I hope it's readable):

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 24 days ago in reply to MM202511045434

    This is nothing to do with whether it's printed or not. Whilst it might show as "\\" the string actually only contains a single "\" and so any usage of it when passed to a function would only see that single "\".

    The problem is almost certainly that the signal is not called what you think it is within the result database. What does outputs() show (that's what the message suggests you use). If outputs() produces a lot of info, try:

    pcreMatchList("^DUT\\.XPLL_ANA_TOP" outputs())

    which will give you any output that begins with DUT.XPLL_ANA_TOP (note, the double backslash here is to provide a single regular expression backslash to escape the dot to prevent it meaning the regex "any character").

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett 24 days ago in reply to MM202511045434

    This is nothing to do with whether it's printed or not. Whilst it might show as "\\" the string actually only contains a single "\" and so any usage of it when passed to a function would only see that single "\".

    The problem is almost certainly that the signal is not called what you think it is within the result database. What does outputs() show (that's what the message suggests you use). If outputs() produces a lot of info, try:

    pcreMatchList("^DUT\\.XPLL_ANA_TOP" outputs())

    which will give you any output that begins with DUT.XPLL_ANA_TOP (note, the double backslash here is to provide a single regular expression backslash to escape the dot to prevent it meaning the regex "any character").

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • MM202511045434
    MM202511045434 21 days ago in reply to Andrew Beckett

    Yes Andrew, that's correct. The signal name in the result database looked different from what I have been entering so far. Now, I am able to do evaluations on the nets.

    Thank you so muchSlight smile

    Monika

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information