Ovm reporting

Hi,

I seem to have some conceptual doubts on the ovm reporting.

  1. what really is the arg “string filename” to ovm_report_* meant for?
    This has nothing to do with the actual log file. Is this correct?

  2. to dump a message to a file, do I have to first configure set_report_severity_file/set_report_id_file etc.

An example would really help.

Regards

Hi,

  1. what really is the arg “string filename” to ovm_report_* meant for?

It can be used to pass the name of the file containing the source code that issued the call to ovm_report_* to the report handler. There is also an optional line argument that can be used to pass the line number to the report handler too.

  1. to dump a message to a file, do I have to first configure set_report_severity_file/set_report_id_file etc.

Yes - here is an example:

OVM_FILE fd = $fopen("env2.log");  //open log file
//setup environment to send info messages to log file
   env2.set_report_default_file_hier(fd);   
   env2.set_report_severity_action_hier(OVM_INFO,OVM_LOG);

Hope that is enough to give you the idea.

Regards,
Dave

Hi,
It can be used to pass the name of the file containing the source code that issued the call to ovm_report_* to the report handler. There is also an optional line argument that can be used to pass the line number to the report handler too.
Yes - here is an example:

OVM_FILE fd = $fopen("env2.log");  //open log file
//setup environment to send info messages to log file
env2.set_report_default_file_hier(fd);   
env2.set_report_severity_action_hier(OVM_INFO,OVM_LOG);

Hope that is enough to give you the idea.
Regards,
Dave

Thanks Dave.

Can I assume that reporting configurations I do are per ovm_component instance and not global. For example, I can set default file name for one instance as log_x and another as log_y.

Regards

Hi,

Can I assume that reporting configurations I do are per ovm_component instance and not global. For example, I can set default file name for one instance as log_x and another as log_y.

The set_report_hier methods apply to a component and all of its children. You can use set_report_file methods if you want to set the options for a single component instance.

Regards,
Dave

The other Dave here, :D

Use the compiler directives __FILE__ and LINE to pass to ovm_report_*. e.g.

ovm_report_info("CHECK","Just checking here",,`__FILE__,`__LINE);

The Questa GUI will use that information to later trace the message back to is spot the source code.

If you want a setting to be truly global, you need to do the following

_global_reporter.set_report_handler(ovm_top.get_report_handler());
ovm_top.set_report_*_hier(...);

Dave Rich

Thanks, Dave & Dave

The other Dave here, :D
If you want a setting to be truly global, you need to do the following

_global_reporter.set_report_handler(ovm_top.get_report_handler());
ovm_top.set_report_*_hier(...);

Dave Rich

Hello Dave!

Can you explain me this code.

I take attached code from this forum
http://ovmworld.org/forums/showpost.php?p=2799&postcount=7

add rewrite function build of my_testclass this way

virtual function void build;
      super.build();
      ovm_report_info("", "Called my_test::build");
      // Always use the factory instead of new
      m_env = my_env::type_id::create("m_env",this);
      // lets log to file
      fd = $fopen("log.txt");
      m_env.set_report_default_file_hier(fd);
      _global_reporter.set_report_handler(m_env.get_report_handler());
      m_env.set_report_severity_action_hier(OVM_INFO, OVM_LOG);
      m_env.set_report_severity_action_hier(OVM_ERROR, OVM_LOG);
     //set_global_timeout(1us);
    endfunction: build

but then simulation is finished, there is no m_driver1ovm_report_info message in the log file. Can you tell me there is the problem?

and one more

The set_report_*_hier methods apply to a component and all of its children.

Children in this phrase are all objects inherited from this class or all objects inserted into this class?

Thank you.

Generally, I avoid using the terms parent/child when talking about inheritance. I use parent/child when referring to a tree structure of individual objects.

You need to perform set_report_handler before issuing any other set_report functions.

Dave

In reply to sharan_basappa:

Hi,

Is there any way by which we can open a file in append mode. I observed that following line opens a file in write mode.
OVM_FILE fd = $fopen(“env2.log”); //open log file

code like
OVM_FILE fd = $fopen(“env2.log”, “w”); //open log file

doesn’t write anything in the file, in fact gives error.
Can we control modes n which files are opened? Similar code does work in simple SV environment but not OVM. Is there something I am missing.

Thanks.

In reply to Mandar_Thete:

Can you tell what error you are getting?

Do you have the LRM that explains what the second argument to $fopen should be to open the file in append mode?

In reply to dave_59:

Hi,

What I am trying to do is this -

f= $fopen(“errorlog”, “a+”); // 2nd argument gives error as mentioned below
set_report_severity_file(OVM_ERROR, f);
set_report_severity_action(OVM_ERROR, OVM_DISPLAY + OVM_LOG + OVM_COUNT);

Error : src/compatibility/urm_message.sv(494): $fdisplay : Argument 1 is an unknown file descriptor.

I am trying to pull all the error messages in this newly opened file. (I should have been clearer earlier while posting question). Why is $fdisplay function not able to find the FD?

Code works if we do not pass any ‘mode’ argument while opening file.

In reply to Mandar_Thete:

How did you declare f?

Also, do you have any `message macros or any other legacy code calling URM? It should not be invoking the compatibility layer unless you have that.

In reply to dave_59:

Code works if we do not pass any ‘mode’ argument while opening file.

That seems to suggest that $fopen with MCD (Multi-Channel Descriptor) works fine in your tool, but not with a “fd” (Recall V2K added the FD concept with type as the 2nd argument to $fopen).

Maybe there is a +v2k switch needed in your tool? Which tool do you use? Also try few things:

  1. Use $ferror after the $fopen to see the “fd” is returned properly
  2. Use plain $fdisplay and see if that works
  3. Try “w” mode first to see if that works.

File IO has been a pain with some tools, but not this bad I suppose.

Good Luck
Ajeetha, CVC

In reply to ajeetha:

Hi,

I have declared f as int.

I have tried using $ferror and $fdisplay. These work perfectly fine - File gets appended with custom ($fdisplay) messages.(While doing so I comment set_report_severity_file(OVM_ERROR, f) and set_report_severity_action(OVM_ERROR, OVM_DISPLAY + OVM_LOG + OVM_COUNT))

Issue appears only when I use set_report_severity_file and set_report_severity_action. As far as know I am passing required argument to them.

I am using ovm_report_error(“error_id”, “error_msg”) command to raise errors.

Note : As mentioned before, code works when I use $fopen(“filename”); But for every test case file gets overwritten. When I use append mode, I throws errors.

Does that mean, set_report_severity_file and set_report_severity_action do not support append mode?

I believe ovm_report_error is causing this error PROVIDED I have opened file in append mode.

In reply to Mandar_Thete:

Mandar,
Spoke to Srini, our CTO on this involved issue as he vaguely recalls it from a customer engagement. He pointed me to the compatibility layer, specifically the code:


// src/compatibility/urm_message.sv 
  if ( msg.m_action & OVM_DISPLAY ) msg.m_destination |= 1;

Perhaps the above code assumed MCD than the modern FD. Can you try removing OVM_DISPLAY in your action to see if that helps?

If you need further assistance, consider creating a simple testcase and share/send across (training@cvcblr.com). Alternatively contact your EDA vendor with a testcase.

Good Luck
Ajeetha, CVC

In reply to ajeetha:

Thanks Ajeetha and Dave,

When I remove OVM_DISPLAY, functionality does work (of course we have to give up on messages to be displayed on terminal).

Thanks for the solution. However, I will still go ahead and send the test case to EDA vendor to see if I can get some better picture(will try send to mentioned email as well asap). I will update the outcome of it here as well.

-Mandar

In reply to Mandar_Thete:

Hi all,
Please find a working example ready to run, given below…
the same can be ported to uvm using ovm2uvm.pl

refer OVM2UVM | Verification Academy for the details.
tested on ovm 2.1.2 and uvm 1.1d using the above method.

Feel free to provide your valuable feedbacks.

import ovm_pkg::*;

module display;
initial begin
run_test(“my_test”);
end

initial #100 ovm_top.stop_request();

endmodule:display

class my_test extends ovm_test;
`ovm_component_utils(my_test)

int fh,fh1;

function new (string name , ovm_component parent);
super.new(name, parent);
endfunction:new

virtual task run();
fh = $fopen (“my_test_fh.log”,“w”); // opening two text files
fh1= $fopen (“my_test_fh1.log”,“w”);

set_report_default_file(fh1); // setting default write file as fh1

`ovm_info(get_name(),“Hello world”,OVM_LOW) // this will be printed only to terminal/ simulation log
// since ‘set_report_severity_action’ is not yet set

$fdisplay(fh,“fdisplay - Hello world”); // will be written irrespective of ‘set_report_*’ setting

set_report_severity_action(OVM_INFO, OVM_LOG); // redirecting `ovm_info ony to text file

ovm_info(get_name(),"My world",OVM_LOW) // will be in text file my_test_fh1.log $fdisplay(fh,"fdisplay - My world"); set_report_default_file(fh); // setting default to fh, here after all ovm_info woll be
// directed to fh
// instead of fh1

set_report_severity_action(OVM_INFO, OVM_LOG | OVM_DISPLAY ); // setting `ovm_info to be directed to my_test_fh.log
// and to terminal/ simulation log

$fdisplay(fh1,“fdisplay1 - My world”);
`ovm_info(get_name(),"My last world :-) ",OVM_LOW) // will be in text file my_test_fh.log
// and in terminal/ simulation log

$fclose(fh);
$fclose(fh1);
endtask:run
endclass:my_test

regards,
Sachin Scaria