• 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. Functional Verification
  3. String concatenation

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 66
  • Views 20255
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

String concatenation

SpecMAN INFANT
SpecMAN INFANT over 16 years ago

Hi,

My requirement is to create a list of names err_00_count; err_01_count and so on till err_99_count. In order to achieve this I used the append operator  as append("err_",x,"_count"). where x was a loop variable. But the result comes out as  err_0x<actual no.>_count. Is there any way in which the 0x can be eliminated?

 

 

  • Cancel
  • StephenH
    StephenH over 16 years ago

    Try this:

    appendf("err_%02d_count", x);

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • SpecMAN INFANT
    SpecMAN INFANT over 16 years ago

     Thanx Stephen, But I want to replace '%02d' with a variable : i.e.  '%xd' which is not possible

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 16 years ago

    Have you read the manual to see the syntax of appendf()?
    If you want the number in hex, then modify my suggestion to use the %x print format instead of %d.

    The arguments for appendf() are exactly like the printf() function in C, so it should be pretty obvious how to adapt it for your needs...

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • SpecMAN INFANT
    SpecMAN INFANT over 16 years ago

     Stephen, What I meant was I want to replace with a 02 with loop variable x or y .,say(e.g. with y )  err_%yd_cnt which is not possible....!!!!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 16 years ago

    Please don't keep saying it's not possible, you just need to understand what the C printf() format string means.
    A quick Google search or looking at a C text book will tell you all you need.

    In order to help you, I have written a small demo. Here is the Specman code:

    $ cat print_demo.e
    <'
    extend sys {
      run() is also {
        for x from 0 to 5 {
          out( appendf("err_%02d_count", x) );
        };
      };
    };
    '>

    And here is the output from the demo code:

    $ specman -c "load print_demo ; test"
    Welcome to Specman Elite (08.20.003-s)  -  Linked on Thu Mar  5 17:31:56 2009

    Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
    6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
    6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

    Checking license ... OK
    Loading print_demo.e ...
    read...parse...update...patch...h code...code...clean...
    Doing setup ...
    Generating the test using seed 1...

    Starting the test ...
    Running the test ...
    err_00_count
    err_01_count
    err_02_count
    err_03_count
    err_04_count
    err_05_count
    No actual running requested.
    Checking the test ...
    Checking is complete - 0 DUT errors, 0 DUT warnings.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • SpecMAN INFANT
    SpecMAN INFANT over 16 years ago

     ThanxStephen.. misinterpretation from my side.....

    Also, I saved the above appendf o/p to a variable(loop_str) (of type string ). My requirement was to access an hdl signals with the name err_<number>_count put inside the loop. But when I try to access using the stored variable(loop_str); error meessage pops up saying hdl signal loop_str doesn't exist in the hdl sig def.   i.e. it doesn't take the replacement for loop_str. Is there any way in which this can be done?

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 16 years ago

    I see...

    If your ports are declared as a list, you're in luck, but if you copied & pasted 100 instances of the port, you're pretty much stuck.

    Loop example:

    err_count[100] : list of in simple_port of bit is instance;

    keep for each in err_count { it.hdl_path() == appendf("err_%02d_count", index); };

    That should give you a feel for what to try or look up in the docs :-)
    Good luck!

    • Cancel
    • Vote Up 0 Vote Down
    • 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