I’ve created my own subclass based on uvm_report_server and am trying to change the message format based on verbosity level. Specifically, I want to print file and object information only for UVM_FATAL or UVM_DEBUG. I heard about get_report_verbosity_level but couldn’t find any examples of how to use it, so I tried the following but it does not print out the extra information when I set +UVM_VERBOSITY=UVM_DEBUG. If I take out the conditionals so that baseline and verbose_id are always set, the extra info prints out fine. What am I doing wrong?
class new_report_server extends uvm_report_server;
static string filename_cache [string];
function string compose_message( uvm_severity severity,
string name,
string id,
string message,
string filename,
int line );
string basefile;
string verbose_id;
string severity_name;
uvm_severity_type severity_type = uvm_severity_type'(severity);
//
// Attempt to retrieve verbosity level
//
uvm_report_object dummy_report = new("");
int verbosity_level = dummy_report.get_report_verbosity_level(severity, id);
//
// Print the severity for any level above UVM_INFO
//
if (severity_type > UVM_INFO) begin
severity_name = severity_type.name();
severity_name = {" ",severity_name.substr(4,severity_name.len()-1),":"};
end
if ((severity_type >= UVM_FATAL) || (verbosity_level >= UVM_DEBUG)) begin
if (filename_cache.exists(filename)) basefile = filename_cache[filename];
else begin
int i;
basefile = filename;
//
// Remove any trailing slashes
//
i = basefile.len() - 1;
while (i >= 0 && basefile.substr(i,i) == "/")
basefile = basefile.substr(0, --i);
//
// Remove middle slashes
//
for (i = basefile.len() - 1; i >= 0; i--) begin
if (basefile.substr(i,i) == "/") begin
basefile = basefile.substr(i+1,basefile.len()-1);
break;
end
end
filename_cache[filename] = basefile;
end
end
if (basefile != "")
$swrite(verbose_id, " [%0s(%0d): %0s(%0s)]", basefile, line, name, id);
return $psprintf( "[%12t] :%0s%0s %0s",
$time, severity_name, verbose_id, message );
endfunction
...
endclass