Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing string variables to plusargs

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.

like image 319
user2347216 Avatar asked Dec 29 '25 10:12

user2347216


1 Answers

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
like image 187
toolic Avatar answered Dec 30 '25 23:12

toolic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!