Ovm Error Report Messages

I want to use the ovm_report_error function to print messages. Usually it accepts strings only. I want to print hex variables also. I am trying some thing like,

ovm_report_info(get_type_name(), $sprintf(“Data Mismatch of control registers:\n Expected=%h, Actual=%h”, reg_read_data,trans.data),OVM_LOW);

But it says that it can accept only strings.

Thanks in Advance

You can’t use $sprintf in this manner. It is a void function and it needs a string variable name as its first argument. You could just put a “p” in front of the “sprintf”. $psprintf is a function that returns a string, and would work the way you have it. $psprintf is not technically part of the SystemVerilog standard, but generally works the same in the major simulators.

Or, you could use $sprintf like this:

string msg;

$sprintf(msg, "Data Mismatch of control registers:\n Expected=%h, Actual=%h", reg_read_data,trans.data);

ovm_report_info(get_type_name(),msg,OVM_LOW);

Personally, I like $psprintf because you can use it “in-line” and does not require a separate, declared string and a separate statement.

-Kurt

Hi Kurts,
I have tried the way u suggested.

       string debug;
      $psprintf(debug,"Data Match of control registers: Expected=%h, Actual=%h", reg_read_data, trans.data);
      ovm_report_info(get_type_name(),debug,OVM_LOW);

It is showing ncelab error::::

     $psprintf(debug,"Data Match of control registers: Expected=%h, Actual=%h", reg_read_data, trans.data);
             |

ncelab: *E,NOTUTX (…/_src/_hard/_vc/nec_module_vc/sv/nec_lcdbif_reg_scoreboard.sv,76|17): function name encountered. Expecting a task name. [2.7.4(IEEE Std 1364-2001)].

As suresh says I tried $sformat inplace of %psprintf. it is working fine. But if I embed it inside the ovm_report_info it is also not working.

Thanks In Advance

Hi Siva,

I think you have misunderstood Kurt’s suggestion. You can use $psprintf within the call to ovm_report_* since its return type is a string. If you modify your original code to:

ovm_report_info(get_type_name(), 
                **$psprintf**("Data Mismatch of control registers:\n Expected=%h, Actual=%h", 
                reg_read_data,trans.data),OVM_LOW);

it should work as intended.

Regards,
Dave

Hi Kurt and dlong, Thanks. $psprintf is working fine. but how to make $sprintf to work in this situation?

Sorry, I got confused about the function names. In my reply, I meant $sformat is the stand-alone, void function.

Dave’s example should work for you.

For the sake of completeness, I’ll correct my earlier example:

string msg;

**$sformat**(msg,"Data Mismatch of control registers:\n Expected=%h, Actual=%h", reg_read_data,trans.data);

ovm_report_info(get_type_name(),msg,OVM_LOW);

I’m not familiar with $sprintf - it is not in the Verilog or SystemVerilog standard as far as I know.

-Kurt

The message macro can take the format specifier directly. message(OVM_LOW, (“Data Match of control registers: Expected=%h, Actual=%h”, reg_read_data, trans.data))

Most important side effect of `message is that the string will not be evaluated (which takes significant processing power) unless the verbosity is met. If you have $psprint as an argument in the function report_info(), $psprint will have to be executed everytime regardless message is going to be printed or not. This could poentially lead to slower regressions.

Hi pjigar,

I am sorry, but I have serious doubts concerning what you say for the `message macro.

Firstly, from looking through the code in the ovm/src/compatibility directory, it would appear that $psprintf is always called by the implementation of `message unless you are using Incisive. Even on Incisive platforms, it looks as if the implementation still calls $swrite and creates a ovm_urm_message object (which itself seems to involve a not-insignificant number of operations) which it then passes to the ovm_urm_report_server to test against the specified verbosity? I don’t really see how this is likely more efficient than using ovm_report_*. Do you have any benchmarks you can give us?

Secondly, IMHO it is good to have a single “standard” mechanism for tasks like reporting in a testbench. I realize that the `message macro gives existing URM or eRM users this capability but the OVM documentation seems to suggest that calling the ovm_report_* functions is the approach that is recommended for new users? This would also be my personal preference.

Regards,
Dave

Dave,

What you say is true today. The optimization that Jigar is talking about has not been implemented yet. It is certainly possible and desirable since doing string formatting of messages that are not likely to be used is an unnecessary overhead. But, for now that optimization is not in place.

john

Dave,
What you say is true today. The optimization that Jigar is talking about has not been implemented yet. It is certainly possible and desirable since doing string formatting of messages that are not likely to be used is an unnecessary overhead. But, for now that optimization is not in place.
john

Hi Siva,
I think you have misunderstood Kurt’s suggestion. You can use $psprintf within the call to ovm_report_* since its return type is a string. If you modify your original code to:

ovm_report_info(get_type_name(), 
**$psprintf**("Data Mismatch of control registers:\n Expected=%h, Actual=%h", 
reg_read_data,trans.data),OVM_LOW);

it should work as intended.
Regards,
Dave

The above report msg did not work for me.

I get errors with

 ovm_report_error(get_type_name(), $psprintf("\nInvalid gpmc_ncs = %0b\n", osi.gpmc_ncs[7:0]), OVM_FULL);

Only the following works. Is there way to combine both statements into one and make it work?

$sformat(temp_string, "\nInvalid gpmc_ncs = %0b\n", osi.gpmc_ncs[7:0]);
ovm_report_error(get_type_name(), temp_string, OVM_FULL);

Thx
Kal

Now the following is throwing exceptions on Cadence’s IUS 8.2 after updating some code.

$sformat(temp_string, “\nInvalid gpmc_ncs = %0b\n”, osi.gpmc_ncs[7:0]);
ovm_report_error(get_type_name(), temp_string, OVM_FULL);

========
ERROR: SYSTF OPPNDF
Property vpiSize is not available for an operation of type 33.
…/tb/gpmc_master_monitor.sv, 157: $sformat(temp_string,“\nInvalid gpmc_ncs = %0h\n”,{})
ncsim: *F,INTERR: INTERNAL ERROR
Observed simulation time : 936 NS + 10

The tool has encountered an unexpected condition and must exit.
Contact Cadence Design Systems customer support about this
problem and provide enough information to help us reproduce it,
including the logfile that contains this error message.
TOOL: ncsim 08.20-s003
HOSTNAME: x028.nethra-imaging.com
OPERATING SYSTEM: Linux 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686
MESSAGE: sv_seghandler - trapno -1

System task: $sformat
file: …/tb/gpmc_slave_monitor.sv
line: 202
***Current stack trace:
–>[Don’t Know ] 0x879aec0 <don’t know>
ncsim: *F,INTERR: INTERNAL ERROR
Observed simulation time : 936 NS + 10

The tool has encountered an unexpected condition and must exit.
Contact Cadence Design Systems customer support about this
problem and provide enough information to help us reproduce it,
including the logfile that contains this error message.
TOOL: ncsim 08.20-s003
HOSTNAME: x028.nethra-imaging.com
OPERATING SYSTEM: Linux 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686
MESSAGE: sv_seghandler - SIGSEGV while handling SIGSEGV

System task: $sformat
file: …/tb/gpmc_slave_monitor.sv
line: 202