# How to execute a recursive factory override?

**URL:** <https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715>\
**Category:** UVM\
**Tags:** uvm-factory, UVM\
**Created:** [August 6, 2022, 5:55am UTC](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715 "2022-08-06T05:55:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![UVM\_LOVE](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/uvm_love/32/1684_2.png) [@UVM\_LOVE](https://verificationacademy.com/forums/u/UVM_LOVE)\
**Post date:** [August 6, 2022, 5:55am UTC](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715/1 "2022-08-06T05:55:46Z")

</div>

Hi,

I’m trying to execute a simple UVM factory example.  
When I try a recursive override, I got the error message

```verilog
UVM_ERROR @ 0: reporter [OVRDLOOP] Recursive loop detected while finding override.

```

If I want to execute a factory overriding in recursive factory override. What am I supposed to do?

```verilog

 virtual function void build_phase(uvm_phase phase);
   ...
   ...
   set_type_override_by_type(base_agent::get_type(), child_agent::get_type());
   ...   
   set_type_override_by_type(child_agent::get_type(), base_agent::get_type());
   ...   
 endfunction

```

---

<div class="post-metadata">

**Author:** ![logie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@logie](https://verificationacademy.com/forums/u/logie)\
**Post date:** [August 6, 2022, 6:40am UTC](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715/2 "2022-08-06T06:40:49Z")

</div>

_In reply to [UVM\_LOVE](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715):_  
Not sure I understand what you are trying to accomplish. Are you trying to undo the factory override and revert back to the base\_agent?

---

<div class="post-metadata">

**Author:** ![ABD\_91](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/c77e96/32.png) [@ABD\_91](https://verificationacademy.com/forums/u/ABD_91)\
**Post date:** [August 6, 2022, 9:20am UTC](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715/3 "2022-08-06T09:20:50Z")

</div>

_In reply to [UVM\_LOVE](https://verificationacademy.com/forums/t/how-to-execute-a-recursive-factory-override/40715/2):_

> If I want to execute a factory overriding in recursive factory override

Don’t register the 1st override in that case ( based on configuration / run-time switch )  
You won’t need to override a previous override that way.
