$psprintf -vs- $sformatf?

Hi, All -

There are many references to $psprintf on this forum and two references in the OVM Reference Guide, even though the SystemVerilog committee rejected the standardization of $psprintf since the language already had $sformatf. A quick search shows that both are used two times each in the reference guide.

Has $psprintf become a defacto standard command in all of the simulators?

Is it treated exactly the same as $sformatf?

Regards - Cliff Cummings
Verilog & SystemVerilog Guru
Sunburst Design

1 Like

Cliff,

The reality is that once a simulator vendor implements a feature, it’s almost impossible to get them to remove it, regardless of what happens in the IEEE standard committee. The only time I see a feature removed is when you can prove that the existence of a feature causes problems for the user (e.g. conflicts with proper implementation of that feature, like generate). Apparently, having code that is not portable is not a problem for some users.

Dave

'Tis true. Still, it would be nice if the OVM/UVM documentation used just one or the other. Thanks, Dave.

Regards - Cliff

They are identical though, right?

Ray

In reply to raysalemi:

They are spelled with different sets of letters.

Why is the output different for both of these prints? I could roughly give a guess for what could be happening with the sformatf - (might be printing integer values of the string it generated) it would be better if someone could give a concrete explanation for me.
Also, simulator throws something like below. Am I missing some point for the sformatf ??
Warning-[STASKW_SFRTMATR] More arguments than required
testbench.sv, 12
Number of arguments (9) passed to place in the format string are more than
the number of format specifiers (1).


module tb;
  initial begin
    string sfrmt, psprnt;
    psprnt = $psprintf("%0s\n", "",
                  "row    : %08x\n", 5,
                  "col    : %08x\n", 6,
                  "addr   : %08x\n", 7,
                  "cmd    : %0s\n", "cmd");
    $display(psprnt);
    //output
    //row    : 00000005
    //col    : 00000006
    //addr   : 00000007
    //cmd    : cmd
    sfrmt = $sformatf("%0s\n", "",
                  "row    : %08x\n", 5,
                  "col    : %08x\n", 6,
                  "addr   : %08x\n", 7,
                  "cmd    : %0s\n", "cmd");
    $display(sfrmt);
    //output - random big numbers
    //2321025888408877083000271174924298          52016786340018993991845306433042442          
    //61975347634275872380922925474674698          7 7877442999272995673474881057546 6516068
  end
endmodule

In reply to ven@pdx.edu:

As was discussed in the previous replies in this thread, $psprintf is not in the SystemVerilog LRM. Implementation may differ between simulators and it may not even be supported in some simulators.

Per the LRM, $sformat has the following signature:

variable_format_string_output_function ::= $sformatf ( format_string [ , list_of_arguments ] )

Your code doesn’t follow this signature