# How can I change driver type in an agent, if both are extended from uvm\_driver

**URL:** <https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484>\
**Category:** UVM\
**Tags:** UVM, override, uvm\_factory\
**Created:** [June 3, 2022, 3:08pm UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484 "2022-06-03T15:08:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhil\_dv](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@akhil\_dv](https://verificationacademy.com/forums/u/akhil_dv)\
**Post date:** [June 3, 2022, 3:08pm UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/1 "2022-06-03T15:08:13Z")

</div>

Is there any way I can change the my\_driver\_1 type to my\_driver\_2? I guess factory override can’t be used as my\_driver\_2 is not an extended class of my\_driver\_1. Is this understanding correct. Is it possible to instantiate uvm\_driver in the agent instead of my\_driver\_1

- 

class my\_driver\_1 extends uvm\_driver;  
`uvm\_component\_utils(my\_agent)  
endclass

class my\_driver\_2 extends uvm\_driver;  
`uvm\_component\_utils(my\_agent)  
endclass

class my\_agent extends uvm\_agent  
`uvm\_component\_utils(my\_agent)  
my\_driver\_1 drv;

drv = my\_driver\_1::type\_id::create(this,“my\_driver\_1”) ;

endclass\*

---

<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:** [June 8, 2022, 7:40pm UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/2 "2022-06-08T19:40:24Z")

</div>

_In reply to [akhil\_dv](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484):_

You can instantiate uvm\_driver in releases _after_ UVM 1.2 because none of the uvm\_ classes were registered with the factory prior to that.

But it would be better to create your own driver base class to handle common procedures like setting up your virtual interfaces, etc.

---

<div class="post-metadata">

**Author:** ![akhil\_dv](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@akhil\_dv](https://verificationacademy.com/forums/u/akhil_dv)\
**Post date:** [June 27, 2022, 9:37am UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/3 "2022-06-27T09:37:27Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/2):_

Thank you so much, Dave. :)

---

<div class="post-metadata">

**Author:** ![Manikanta\_Kopparapu](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/manikanta_kopparapu/32/2718_2.png) [@Manikanta\_Kopparapu](https://verificationacademy.com/forums/u/Manikanta_Kopparapu)\
**Post date:** [June 27, 2022, 12:41pm UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/4 "2022-06-27T12:41:09Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/3):_

> _In reply to [akhil\_dv](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/3):_  
> You can instantiate uvm\_driver in releases _after_ UVM 1.2 because none of the uvm\_ classes were registered with the factory prior to that.  
> But it would be better to create your own driver base class to handle common procedures like setting up your virtual interfaces, etc.

Hi Dave,  
I didn’t understand what do you mean by instantiating the uvm\_driver after UVM 1.2 . Can you please explain in more. Thanks in advance.

---

<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:** [June 27, 2022, 11:37pm UTC](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/5 "2022-06-27T23:37:31Z")

</div>

_In reply to [Manikanta Kopparapu](https://verificationacademy.com/forums/t/how-can-i-change-driver-type-in-an-agent-if-both-are-extended-from-uvm-driver/40484/4):_

In order to use the UVM factory, both the object you create by default (using the create() method), and the type you want overridden needs to be registered with the factory. In UVM 1.2, uvm\_driver is not registered with the factory.
