# Why is the build() phase in UVM executed in a Top - Down fashion and the other phases in Bottom - Up fashion?

**URL:** <https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173>\
**Category:** UVM\
**Tags:** UVM\
**Created:** [February 19, 2014, 5:39am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173 "2014-02-19T05:39:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![srikanth7](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@srikanth7](https://verificationacademy.com/forums/u/srikanth7)\
**Post date:** [February 19, 2014, 5:39am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/1 "2014-02-19T05:39:32Z")

</div>

Hello,  
While going through UVM phases it is mentioned that Build phase is top down phase and other phases are bottom up phases.  
So What is the reason for build phase is executing in top down fashion and other phases working in bottom up fashion?

Thanks in Advance.  
Regards

---

<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:** [February 19, 2014, 5:57am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/2 "2014-02-19T05:57:49Z")

</div>

It is very simple. The build phase has to be that way because the parent component’s build\_phase constructs the child components. You couldn’t call the child’s build\_phase before the parent’s build\_phase because they the child objects haven’t been constructed yet. An you need a constructed object to call its method.

The ordering within the other phases should not matter, except you might want know that the top level’s report\_phase comes last.

---

<div class="post-metadata">

**Author:** ![srbeeram](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@srbeeram](https://verificationacademy.com/forums/u/srbeeram)\
**Post date:** [January 8, 2015, 2:52pm UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/3 "2015-01-08T14:52:36Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/2):_

Hi dave,

could you please provide the following clarifications.

as the parent component is not aware of derived components properties that belong to only derived component. how it would be possible for parent class to construct the derived component.

as super.build is already present in build function of child , as per your inputs it has to be called by the object , is it done by the parent object.

I am new to the uvm. could you please provide clarifications.

---

<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:** [January 8, 2015, 6:08pm UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/4 "2015-01-08T18:08:49Z")

</div>

_In reply to [srbeeram](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/3):_

Generally, I avoid using the terms parent/child when talking about inheritance. I use parent/child when referring to a tree structure of individual objects. The uvm\_component hierarchy is such a tree structure. It is separate from the inheritance hierarchy of classes.

---

<div class="post-metadata">

**Author:** ![srbeeram](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@srbeeram](https://verificationacademy.com/forums/u/srbeeram)\
**Post date:** [January 9, 2015, 11:23am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/5 "2015-01-09T11:23:54Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/4):_

Thanks dave. I got clarity now.

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 7, 2015, 10:26pm UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/6 "2015-04-07T22:26:08Z")

</div>

_In reply to [srbeeram](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/5):_

Hi Dave,

If I have a uvm\_config\_db #(abc)::set in the build\_phase in the env, and later on, I have another uvm\_config\_db #(abc)::set with different values in the build phase in the test case, would the latter(test case) override the one in the env?

Thanks!

---

<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:** [April 8, 2015, 3:28am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/7 "2015-04-08T03:28:00Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/6):_

I think last write wins at the same component hierarchy level.

You should be able to write a small testcase to verify.

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 12, 2015, 6:47am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/8 "2015-04-12T06:47:26Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/7):_

Hi Dave,

I wrote some tests to try to understand the order. I added printed messages in both build\_phases in the test case and the test env respectively. The one in the test case printed the message first, which makes sense as the test case is actually instantiate the test env (so top down for the build\_phase). So my intention is if the test case has already had the m\_abc set by config\_db, then the test\_env should not set m\_abc any more. Therefore, I have the code something like this:

in the test case:  
uvm\_config\_db#(int)::set(this, “m\_env.m\_uvc.m\_virtual\_sequencer”, “m\_abc”, 123);

in the test env (ie. m\_uvc):  
if (!(uvm\_config\_db#(int)::get(this, “”,“m\_virtual\_sequencer”, m\_abc))) begin  
uvm\_config\_db#(int)::set(this, “m\_virtual\_sequencer”, “m\_abc”, 456); —\> however, this code is still being executed  
end

However, looks like the set in the test env is still getting executed, do you see what’s the problem here?

Thanks!

---

<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:** [April 13, 2015, 2:53am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/9 "2015-04-13T02:53:16Z")

</div>

_In reply to [nickbayshore](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/8):_

How about showing a complete self-contained simple example of exactly what you are trying to do. Just showing 3 classes should be enough: test, env, and virtual sequencer.

---

<div class="post-metadata">

**Author:** ![lilyding](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@lilyding](https://verificationacademy.com/forums/u/lilyding)\
**Post date:** [April 13, 2015, 4:40am UTC](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/10 "2015-04-13T04:40:10Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/why-is-the-build-phase-in-uvm-executed-in-a-top-down-fashion-and-the-other-phases-in-bottom-up-fashion/29173/9):_

I don’t really have much to show. The whole intention is just to use a config\_db to pass down a setting that can take precedence from a test case (i.e. uvm\_test where instantiates the uvm\_env), otherwise use the one in the uvm\_env.

Thanks!
