# Ovm reporting

**URL:** <https://verificationacademy.com/forums/t/ovm-reporting/25709>\
**Category:** OVM\
**Tags:** OVM\
**Created:** [August 6, 2008, 12:10pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709 "2008-08-06T12:10:04Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![verif\_learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@verif\_learner1](https://verificationacademy.com/forums/u/verif_learner1)\
**Post date:** [August 6, 2008, 12:10pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/1 "2008-08-06T12:10:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dlong](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dlong](https://verificationacademy.com/forums/u/dlong)\
**Post date:** [August 6, 2008, 1:45pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/2 "2008-08-06T13:45:50Z")

</div>

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:

```auto
OVM_FILE fd = $fopen("env2.log"); //open log file

```

```auto
//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

---

<div class="post-metadata">

**Author:** ![verif\_learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@verif\_learner1](https://verificationacademy.com/forums/u/verif_learner1)\
**Post date:** [August 6, 2008, 2:12pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/3 "2008-08-06T14:12:19Z")

</div>

> 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:

```auto
OVM_FILE fd = $fopen("env2.log"); //open log file

```

```auto
//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

---

<div class="post-metadata">

**Author:** ![dlong](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/ed8c4c/32.png) [@dlong](https://verificationacademy.com/forums/u/dlong)\
**Post date:** [August 6, 2008, 2:44pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/4 "2008-08-06T14:44:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [August 6, 2008, 2:58pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/5 "2008-08-06T14:58:17Z")

</div>

The other Dave here, :D

Use the compiler directives ` __FILE__ and ` **LINE** to pass to ovm\_report\_\*. e.g.

```auto
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

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

```

Dave Rich

---

<div class="post-metadata">

**Author:** ![verif\_learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@verif\_learner1](https://verificationacademy.com/forums/u/verif_learner1)\
**Post date:** [August 6, 2008, 3:03pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/6 "2008-08-06T15:03:20Z")

</div>

Thanks, Dave & Dave

---

<div class="post-metadata">

**Author:** ![des00](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/dec6dc/32.png) [@des00](https://verificationacademy.com/forums/u/des00)\
**Post date:** [February 9, 2009, 11:03am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/7 "2009-02-09T11:03:33Z")

</div>

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

```auto
_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](http://ovmworld.org/forums/showpost.php?p=2799&postcount=7)

add rewrite function **build** of **my\_test** class this way

```auto
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\_driver1** ovm\_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.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 9, 2009, 3:50pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/8 "2009-02-09T15:50:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mandar\_Thete](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@Mandar\_Thete](https://verificationacademy.com/forums/u/Mandar_Thete)\
**Post date:** [February 26, 2013, 4:13am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/9 "2013-02-26T04:13:45Z")

</div>

_In reply to [sharan\_basappa](https://verificationacademy.com/forums/t/ovm-reporting/25709/8):_

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.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 26, 2013, 6:17am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/10 "2013-02-26T06:17:01Z")

</div>

_In reply to [Mandar\_Thete](https://verificationacademy.com/forums/t/ovm-reporting/25709/9):_

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?

---

<div class="post-metadata">

**Author:** ![Mandar\_Thete](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@Mandar\_Thete](https://verificationacademy.com/forums/u/Mandar_Thete)\
**Post date:** [March 5, 2013, 10:00am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/11 "2013-03-05T10:00:00Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/ovm-reporting/25709/10):_

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.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [March 5, 2013, 4:54pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/12 "2013-03-05T16:54:14Z")

</div>

_In reply to [Mandar\_Thete](https://verificationacademy.com/forums/t/ovm-reporting/25709/11):_

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.

---

<div class="post-metadata">

**Author:** ![Ajeetha\_Kumari\_CVC](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ajeetha\_Kumari\_CVC](https://verificationacademy.com/forums/u/Ajeetha_Kumari_CVC)\
**Post date:** [March 5, 2013, 6:28pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/13 "2013-03-05T18:28:47Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/ovm-reporting/25709/12):_

> 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

> **[Verification Course Blog | VeriLog Courses | CVC](https://www.cvcblr.com/blog/)**
>
> Read our verification course blog to find out more about what CVC can offer, if you are looking for online courses contact us today.

---

<div class="post-metadata">

**Author:** ![Mandar\_Thete](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@Mandar\_Thete](https://verificationacademy.com/forums/u/Mandar_Thete)\
**Post date:** [March 6, 2013, 10:55am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/14 "2013-03-06T10:55:48Z")

</div>

_In reply to [ajeetha](https://verificationacademy.com/forums/t/ovm-reporting/25709/13):_

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.

---

<div class="post-metadata">

**Author:** ![Ajeetha\_Kumari\_CVC](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ajeetha\_Kumari\_CVC](https://verificationacademy.com/forums/u/Ajeetha_Kumari_CVC)\
**Post date:** [March 6, 2013, 1:10pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/15 "2013-03-06T13:10:03Z")

</div>

_In reply to [Mandar\_Thete](https://verificationacademy.com/forums/t/ovm-reporting/25709/14):_

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:

```verilog

// 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](mailto:training@cvcblr.com)). Alternatively contact your EDA vendor with a testcase.

Good Luck  
Ajeetha, CVC

> **[Verification Course Blog | VeriLog Courses | CVC](https://www.cvcblr.com/blog/)**
>
> Read our verification course blog to find out more about what CVC can offer, if you are looking for online courses contact us today.

---

<div class="post-metadata">

**Author:** ![Mandar\_Thete](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@Mandar\_Thete](https://verificationacademy.com/forums/u/Mandar_Thete)\
**Post date:** [March 7, 2013, 4:23am UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/16 "2013-03-07T04:23:09Z")

</div>

_In reply to [ajeetha](https://verificationacademy.com/forums/t/ovm-reporting/25709/15):_

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

---

<div class="post-metadata">

**Author:** ![xloving](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/x/76d3ee/32.png) [@xloving](https://verificationacademy.com/forums/u/xloving)\
**Post date:** [July 23, 2013, 1:50pm UTC](https://verificationacademy.com/forums/t/ovm-reporting/25709/17 "2013-07-23T13:50:58Z")

</div>

_In reply to [Mandar\_Thete](https://verificationacademy.com/forums/t/ovm-reporting/25709/16):_

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](https://verificationacademy.com/cookbook/OVM2UVM) 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
