3

I need to get command line options to add conditions to constraints in SystemVerilog.

I'm invoking $value$pluargs("string=%d",val) from a function call, and I need to use the parameter passed to the function as the 'string' name.

function(string name);
$value$plusargs("<name>=%d", val)
endfunction

I'm not sure how to do this. Saying $value$plusargs("%s=%d",name,val) results in a 'too many arguments' error.

2 Answers 2

5

You can use string concatenation:

module tb;
    int val = 5;

    initial begin
        $monitor("val=", val);
        foo("bar");
    end

    function void foo (string name);
        $value$plusargs({name, "=%d"}, val);
    endfunction
endmodule
Sign up to request clarification or add additional context in comments.

Comments

-1

You can use $test$plusargs to determine whether the command line switch is provided or not.

This system function searches the list of plusargs for the provided string. The plusargs present on the command line are searched in the order provided.

If all characters in the provided string, a result of 1'b1 is returned. If no plusarg from the command line matches the string provided, the result of 1'b0 is returned. I've modified the function, a little.

function void foo (string name);
    if( $test$plusargs("name") )
    begin
    // Use the below
    $value$plusargs({name, "=%d"}, val);
    end
endfunction

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.