How to deal with the virtual interface in OVM TB?

Dear all,
As we know,OVM use factory to make TB structure flexible.
In top,you will use run_test(“test_name”);
That means you will use a factory to create a test_name(class)'s object.
And more factory can not pass argument except of name and parent.(Is it right?)
So How can we pass the virtual interface which is at the top level to test and next step: from test to TB env?
If we use a fixed virtual interface,then means it will not able to change as wish.
Thank you very much!

Hi ahan,

There are several options to accomplish the connection of the actual interface to the virtual one in a reusable way. Some ways have already been discussed here in the forums.

One other way is use a object wrapper around the virtual interface and use set/get_config_object. This was discussed in this thread: http://www.ovmworld.org/forums/showt…?p=316#post316

Another, simpler way is to just declare the virtual interface in a package and assign to it directly and treat is as a global variable.

And yet another, interesting way is to forego the use of interfaces completely, and use a class-based approach. Dave Rich has described this approach in a paper, and has provided a link to the paper and an example in this thread:

http://www.ovmworld.org/forums/showthread.php?t=100

-Kurt

Hi ahan,

A common approach in OVM is to create a wrapper class for a virtual interface that is derived from ovm_object and which is referenced by the driver. This can be created before calling run_test and its virtual interface set to the actual interface required. The advantage of using a wrapper class to access the virtual interface in the driver is that the wrapper reference can be configured before the factory is run. There have been various questions on this topic asked on this forum, e.g. see http://ovmworld.org/forums/showthread.php?t=177&highlight=virtual+interface. You can use the search feature on this forum to find the others.

An alternative approach that is used in the xbus example is to add a function to the driver that can set its virtual interface once the hierarchy has been built.

Regards,
Dave

Thank you,kurts and dave.
I will have a look at those links.

Sorry, I copied the links above from an earlier post, and the text was truncated so the links don’t work

Here are the forum links:

Using get/set config:
http://www.ovmworld.org/forums/showthread.php?p=316#post316

Dave Rich’s class-based approach:
http://www.ovmworld.org/forums/showthread.php?t=100

-Kurt