I’m trying to understand the practical advantages of convert2string() in UVM.
In plain SystemVerilog, I often create a transaction class with a custom display method:
class transaction;
int addr;
int data;
function void display();
$display("addr=%0h data=%0h", addr, data);
endfunction
endclass
Then I can call:
tr.display();
from the driver, monitor, scoreboard, or anywhere else.
In UVM, many engineers recommend implementing:
function string convert2string();
return $sformatf("addr=%0h data=%0h", addr, data);
endfunction
instead.
My questions are:
-
What practical benefits does
convert2string()provide over a normaldisplay()method? -
Why return a string using
$sformatf()instead of directly using$display()? -
In real projects, do engineers typically use only
convert2string(), onlydisplay(), or both? -
Can you share situations where
convert2string()becomes significantly more useful than a custom display method?
Looking for real-world verification/UVM perspectives rather than textbook definitions.