Functions in UVM info gotcha

Be aware when you call a function inside a `uvm_info macro to print its return value – if the message to be printed has a verbosity level higher than the one selected by the simulation run command, the function will not be called because the info will be skipped.This can cause unexpected behavior, especially when calling this function affects anything else outside of the `uvm_info (e.g. any method that can modify a queue). The following example illustrates this gotcha:

Vtool_UVM_info_gotcha

Class example contains a random queue of integers between 1 and 100. The intent of the test module’s initial block is to pop all elements of this queue one by one. In each iteration of the while loop, the whole queue is printed in a uvm_info with low verbosity, while the value returned by the pop_front function is with high verbosity. This will work in case the simulation is started with setting the verbosity level to UVM_HIGH or higher:

However, when verbosity is set to anything lower than UVM_HIGH, the second uvm_info will be skipped, the pop_front in string formatting task will never be called and finally, the while loop will be stuck:

Vtool_UVM_info_gotcha_