$ sformat是否有相同的功能?

Vic*_*sky 3 verilog system-verilog

我正在编写SystemVerilog代码,我注意到$ sformat是一个系统任务,而不是一个函数.是否有一个等同于$ sformat的函数?

我想在函数内执行以下操作:

assert(my_dto_h.a == 10) else begin
  `ovm_error("component", $sformat("my_dto_h.a should be 10, not %0d", my_dto_h.a))
end
Run Code Online (Sandbox Code Playgroud)

不幸的是,我从QuestaSim 10.2获得了以下运行时错误:

** Error: (vsim-PLI-3029) component.sv(105): Expected a system function, not system task '$sformat'.

dwi*_*kle 9

是, $sformatf

来自LRM:

系统函数的$sformatf行为类似于$sformat除了字符串结果作为函数结果值传回$sformatf,而不是放在第一个参数中$sformat.因此$sformatf可以在字符串值有效的地方使用.

variable_format_string_output_function ::=
   $sformatf ( format_string [ , list_of_arguments ] )
Run Code Online (Sandbox Code Playgroud)

例:

string s;
s = $sformatf("Value = %0d", value);
Run Code Online (Sandbox Code Playgroud)