Home > Community > Forums > Functional Verification > parsing the arguments from command line

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 parsing the arguments from command line 

Last post Thu, Apr 26 2007 2:18 AM by archive. 3 replies.
Started by archive 26 Apr 2007 02:18 AM. Topic has 3 replies and 2324 views
Page 1 of 1 (4 items)
Sort Posts:
  • Thu, Apr 26 2007 2:18 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    parsing the arguments from command line Reply

    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
    • Post Points: 0
  • Thu, Apr 26 2007 2:29 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: parsing the arguments from command line Reply

    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
    • Post Points: 0
  • Thu, Apr 26 2007 2:49 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: parsing the arguments from command line Reply

    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
    • Post Points: 0
  • Fri, Apr 27 2007 10:05 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: parsing the arguments from command line Reply

    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
    • Post Points: 0
Page 1 of 1 (4 items)
Sort Posts:
Started by archive at 26 Apr 2007 02:18 AM. Topic has 3 replies.