• 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 Design
  3. How to execute an Ocean command from a string

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 125
  • Views 10347
  • 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

How to execute an Ocean command from a string

BobS893
BobS893 over 3 years ago

Hi,

 I would like to generate a command as a string, perhaps based on local variables or something, and then run it in Ocean _as if_ I typed the contents of the string at an Ocean prompt.  If I denote the function I am looking for as OCN_COMMAND( input_string ) then running:

 OCN_COMMAND( "vtest = 5" )

will run, and after this there will be a variable named    vtest     with a value of 5.

A better example could be:  

 sprintf( str_to_run, "vtest = %d + %d", 5, 6 )

 OCN_COMMAND( str_to_run )

after these two lines, a variable    vtest   would be created and have the value of 11.  

I have seen similar abilities to run UNIX commands with the system( ) command, but not a means to generate commands within Ocean and then have it executed

Thanks in advance!

 Bob

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    Bob,

    evalstring() will do this. In general building code by creating strings and evaluating it is not usually the right way to do anything - I've seen all sorts of odd code done that way when there is a better approach. It would be good to know precisely what you are wanting to do here - the above is a very general description rather than the high level goal.

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • BobS893
    BobS893 over 3 years ago in reply to Andrew Beckett

    Andrew,

     This is exactly what I wanted, thank you!  Clearly I did not know that this function already existed.  As a more real-world example, sometimes when I am post-processing a set of data I may want to create a waveform with a more meaningful name, such as vout_n40_0p9 (representing an output waveform at a particular temperature corner), and within the post-processing loop I can create this meaningful string name.  Thus now I could form the string then use evalstring() to execute the command, so that later I can: plot( vout_n40_0p9 ) and know exactly which corner that pertains to.

    Thanks again!

    Bob

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to BobS893

    Hi Bob,

    In that case, I would do:

    sprintf(name "..." ...) ; so that name="vout_n40_0p9"
    measurement=...
    set(stringToSymbol(name) measurement)

    That way you're just using the set() function to set the variable. That would be cleaner than building commands as strings and then evaluating them.

    Andrew

    • 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