Useful SystemVerilog System Tasks
Useful SystemVerilog System Tasks | |||||||||
---|---|---|---|---|---|---|---|---|---|
Task Name | Description | ||||||||
$sscanf(str,format,args); | $sscanf scans the string according to a template format, which is similar to the printf() function in C language |
||||||||
$sformat(str,format,args); | $sformat is the inverse function of $sscanf. Fill the string into the corresponding parameter args according to the given format |
||||||||
$display(format,args); | $display is the printf statement of Verilog, which displays the formatted string on stdout |
||||||||
$sformatf(format,args); | The task of $sformatf is similar to that of $sformat, except that it returns a string result. The string is used as the return value of $sformatf instead of being placed on the first parameter like $sformt. |
$sformat() update the string with value which you have passed to it.
1 string a; 2 $sformat(a," Hello world");
So here, "Hello world" will be stored in the string a.
It is as good as a = "Hello world";
eg:
1 $sformat(name,"slaves[%0d]",i);
SV output format:
%d and %D are output in decimal format
%b and %B are output in binary format
%o and %O are output in octal format
%h and %H are output in hexadecimal format
%e and %E output real numbers in exponential representation (real type)
%f and %F output real numbers in decimal number representation (real type)
%g and %G output real numbers in decimal or exponential representation
%s and %S are output in string format
%c and %C are output in ASCII format
%m and %M output level name
%v and %V output the strength of the net type variable
%t and %T are output in the current time format