# Main\_phase and run\_phases in uvm TB

**URL:** <https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487>\
**Category:** UVM\
**Tags:** UVM, UVM-phase-methods, UVM-phases\
**Created:** [September 3, 2019, 11:53am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487 "2019-09-03T11:53:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sv-hustler](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sv-hustler/32/3821_2.png) [@Sv-hustler](https://verificationacademy.com/forums/u/Sv-hustler)\
**Post date:** [September 3, 2019, 11:53am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/1 "2019-09-03T11:53:45Z")

</div>

Can we have an UVM tb with one component say test with main\_phase declared and other components run\_phase declared? How will main\_phase run wrt to other components run\_phase and is it legal to declare main\_phase without declaring run\_phase?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [September 3, 2019, 2:47pm UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/2 "2019-09-03T14:47:12Z")

</div>

_In reply to [Sv-hustler](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487):_

Using main\_phase and run\_phase in the same UVM testbench together is a bad coding style and might cause problems.  
In parallel to run\_phase sub-phases are executed, starting with the pre\_reset\_phase and finishing with the post\_shutdown\_phase. run\_phase starts with the pre\_reset\_phase and finishes with the post\_shutdown\_phase.  
See the details here [Phasing | Verification Academy](https://verificationacademy.com/cookbook/phasing)

---

<div class="post-metadata">

**Author:** ![rgarcia07](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/a87d85/32.png) [@rgarcia07](https://verificationacademy.com/forums/u/rgarcia07)\
**Post date:** [September 12, 2019, 1:33am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/3 "2019-09-12T01:33:00Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/2):_

> _In reply to [Sv-hustler](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/2):_  
> Using main\_phase and run\_phase in the same UVM testbench together is a bad coding style and might cause problems.

Could you please elaborate on the previous quote, why is this a bad coding style? And what concrete problems or situations can be produced?

Thanks,  
-R

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [September 14, 2019, 7:41am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/4 "2019-09-14T07:41:45Z")

</div>

_In reply to [rgarcia07](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/3):_

main\_phase is a sub-phase which runs during the run\_phase. But there are more sub-phases running prior or after the main\_phase. For details see the phasing article of the cookbook from my post above.

---

<div class="post-metadata">

**Author:** ![cuonghle](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/cuonghle/32/3231_2.png) [@cuonghle](https://verificationacademy.com/forums/u/cuonghle)\
**Post date:** [September 14, 2019, 8:37am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/5 "2019-09-14T08:37:01Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/4):_

> _In reply to [Sv-hustler](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/4):_  
> Using main\_phase and run\_phase in the same UVM testbench together is a bad coding style and might cause problems.  
> In parallel to run\_phase sub-phases are executed, starting with the pre\_reset\_phase and finishing with the post\_shutdown\_phase. run\_phase starts with the pre\_reset\_phase and finishes with the post\_shutdown\_phase.  
> See the details here [Phasing | UVM Cookbook](https://verificationacademy.com/cookbook/phasing)

Why using main\_phase and run\_phase is a problem?  
Can you provide any example, artical for that problem?

Subphases are normally used to handle particular traffic to DUT such as:

- Handle reset in reset\_phase
- Handle configuration (register) in configure\_phase
- Handle stimulus in main\_phase

While run\_phase is useful specially in driver, monitor, scoreboard where we need to handle every type of traffic from pre\_reset to post\_shutdown.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [September 14, 2019, 9:02am UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/6 "2019-09-14T09:02:29Z")

</div>

_In reply to [chris90](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/5):_

This is not really true, because what you are saying you can implement using corresponding sequences like rest\_seq, config\_seq, operations\_seq etc.  
There are specific relationships between the sub\_phases and this might generate problems. I did not say and mean using a mixture of main\_phase and run\_phase results in all cases in confusion.

---

<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:** [September 14, 2019, 9:50pm UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/7 "2019-09-14T21:50:25Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/6):_

The biggest problem is when people start using the main\_phase as a synonym for the run\_phase. That only works until some else add time-consuming phases before or after the main\_phase and the main\_phase no longer starts at time 0 or ends at the same time as the run\_phase.

---

<div class="post-metadata">

**Author:** ![rgarcia07](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/a87d85/32.png) [@rgarcia07](https://verificationacademy.com/forums/u/rgarcia07)\
**Post date:** [September 14, 2019, 10:59pm UTC](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/8 "2019-09-14T22:59:21Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/main-phase-and-run-phases-in-uvm-tb/36487/7):_

Thank you very much for your inputs, now is clear to me.
