• 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. parsing the arguments from command line

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 64
  • Views 19670
  • 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

parsing the arguments from command line

archive
archive over 18 years ago

Hi,

My requirement is that from the command line,  I need to pass arguments.  And in the system verilog class, I need to parse the argument and based on that I have to set some constraints.

For an example,  I have 2 different packets, pkt1 and pkt2.  Suppose if I pass the arg as pkt1_25_pkt_10, pkt1 and pkt2 should be generated in the propotion of 25:10.

vsim -c ..... +test_args=" -pkt_mode  pkt1_25_pkt2_10" ....

Could you please give some clue on this ?

Thanks.


Originally posted in cdnusers.org by knrajesh29
  • Cancel
  • archive
    archive over 18 years ago

    Hi.

    This is quite easy to do. If you have the Verilog manual, just search for "plusargs".
    Here's a small example:
    if ( $test$plusargs("verbose") )
    $display("a relly verbose message");

    Or to get a value from the arguments:

    string testname;
    TESTNAME_GIVEN : assert ( $value$plusargs("testname+%s", testname) )
    else $fatal(1,"No +testname+xyz argument passed to simulator.");
    if ( testname == "AddrTest01" ) RunAddrTest01;
    else if ( testname == "AddrTest02" ) RunAddrTest02;

    Then when calling ncsim:
    % ncsim snapshot +testname+AddrTest01 ...

    Hope this helps.

    Steve.


    Originally posted in cdnusers.org by stephenh
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    I don’t know how you will use it with vsim (modelsim) but in ncsim you can use it like shown below,

    ncsim –define pkt1=25 –define pkt2=10

    This will make the variables pkt1 and pkt2 visible in the code and and inturn you can use it like

    int packet1 = ‘pkt1;
    int packet2 = ‘pkt2;

    Now, use the packet1 with the value 25 and packet2 with value 10.

    -Vivek


    Originally posted in cdnusers.org by prasad_vc
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    If $test$plusargs isn't what you need, there's another way to pass arguements  into the simulator.  Any +arguement not recognized by nceverilog or ncsim is passed into the simulator and is available for TCL.  For instance:

    ncverilog .... ... ... +test_name+mytestname
    or
    ncsim ... ... ... +test_name+mytestname

    Then this can be extracted via TCL at the NCSim command prompt:

    set covTestName "+test_name+"
    foreach i $argv {
      if {[string match [format "%s%s" $covTestName "*"] $i]} {
        set my_test_name [string range $i [string length $covTestName ] [string length $i]]
      }
    }

    puts "Test Name: $my_test_name"


    Originally posted in cdnusers.org by tmackett
    • 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