Is it possible to use OVM factory instance overrides to override a virtual interface? For example, I have a component low in my class hierarchy that instantiates a virtual interface. I want to use a different interface, so need to override it. I played around with defining the interface as follows:
You can’t use virtual interfaces directly with the field automation macros, but you can use them indirectly. You can create a container, derived from ovm_object, that holds a virtual interface. Then you can use register the container object and use that with the factory.
We use the do_copy hook as part of the container copy to get around the fact that the field automation macros don’t support VIFs. Now you can use the factory to get different VIF containers.
Since the factory creates new instances of objects you still are left with the issue of knowing what kind of VIF you have so you can bind it to an actual interface.
I don’t think this will help Monkey since he seems to want to replace one type of virtual interface with a different one? For that to work with a virtual interface wrapper class, the wrapper would need to be a parameterised class, e.g. along the lines of JGG’s suggestion in http://ovmworld.org/forums/showthread.php?t=245
However, to maintain flexibility, a parameterised interface wrapper would itself have to be instantiated in a parameterised class, and so on, right up to the top level environment. Unfortunately, the OVM factory does not work with parameterised classes so Monkey’s original wish to use set_inst_override won’t work!
I tried your code, and it does allow you to use the factory to override the container class, and hence point to a different interface. But you are right, you still can’t effectively use this because you still seem to need to know the container type when you retrieve the interface or container object from the configuration data base in your component. You could maybe use a factory type override, but you can’t seem to use type overrides for specific instances. They seem to be global, so this doesn’t work either.
I guess the best solution is just to not have interfaces in your base classes for components, but to kind of hard code them in the most extended component classes.