what is the difference between sformat & sformatf can any one explain with example
The difference is described in the free IEEE Std 1800-2012 in section 21.3.3 Formatting data to a string
$sformat is a system task whereas $sformatf is a function.
$sformat has 2 arguments(this interprets the second argument and stores formatted o/p string into the 1st argument).
$sformatf has a single argument whose result is stored into a separate variable as a return value.
module m1;
string s;
int a = 32;
initial
begin
$sformat(s, "\n formatf value of a = %0d\n", a);
$display("%s", s);
end
initial
begin
s = $sformatf("\n sformatf value of a = %0d \n", a);
//$sformatf("\n sformatf value of a = %0d \n", a);
$display("%s",s);
end
endmodule
Basically these are used for formatting data into a string.