# How else we can use pre\_body method and post\_body method in a sequence apart from raising and dropping objections?

**URL:** <https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791>\
**Category:** UVM\
**Tags:** UVM, raise\_objection-in-pre\_body, drop\_objection-in-post\_body, sequence-body\
**Created:** [January 30, 2017, 6:43am UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791 "2017-01-30T06:43:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![8Blades](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/8/4491bb/32.png) [@8Blades](https://verificationacademy.com/forums/u/8Blades)\
**Post date:** [January 30, 2017, 6:43am UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/1 "2017-01-30T06:43:12Z")

</div>

The objection raising and dropping could be done at the beginning of sequence body and at the end of the body respectively, without using the pre\_body and post\_body tasks. What are the other possible use cases of these two tasks? Could anyone please throw some light on same, if they have used it for other useful purposes?

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [January 30, 2017, 12:29pm UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/2 "2017-01-30T12:29:00Z")

</div>

_In reply to [8Blades](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791):_

Never raise objections in pre\_body() or drop objections in post\_body(). Doing this will have a significant detrimental impact on your simulation performance. Instead, only raise and lower objections at the test level.

You can use pre\_body() to do any data initialization that might be necessary for your sequence item. You can use post\_body() to do any calculations on the randomized data such as checksum and parity fields.

---

<div class="post-metadata">

**Author:** ![8Blades](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/8/4491bb/32.png) [@8Blades](https://verificationacademy.com/forums/u/8Blades)\
**Post date:** [January 30, 2017, 12:54pm UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/3 "2017-01-30T12:54:33Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/2):_  
Thanks cgales!  
In some of the examples, i have seen people comparing starting\_phase != null and then raising the objection. I didn’t get the idea here, what is in starting\_phase and what we are trying to compare with null. Could you pls elaborate on it a little.

E.g [https://verificationacademy.com/forums/uvm/how-start-sequence/s](https://verificationacademy.com/forums/uvm/how-start-sequence/s)

In this example, he’s comparing starting phase != null in the pre\_body task.

---

<div class="post-metadata">

**Author:** ![rakesh2learn](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rakesh2learn](https://verificationacademy.com/forums/u/rakesh2learn)\
**Post date:** [January 30, 2017, 1:28pm UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/4 "2017-01-30T13:28:07Z")

</div>

_In reply to [8Blades](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/3):_

> In some of the examples, i have seen people comparing starting\_phase != null and then raising the objection. I didn’t get the idea here, what is in starting\_phase and what we are trying to compare with null. Could you pls elaborate on it a little.  
> E.g [https://verificationacademy.com/forums/uvm/how-start-sequence/s](https://verificationacademy.com/forums/uvm/how-start-sequence/s)  
> In this example, he’s comparing starting phase != null in the pre\_body task.

when a sequence is started explicitly, the starting\_phase member is NULL, so the sequence will not raise or drop phase objection. So one wants to raise/drop objctions when starting\_phase is not equal to null. In this case, the sequence has the control over raising / dropping objection which can cause problems. As cgales suggested test must control raise and drop objections.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [January 30, 2017, 1:49pm UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/5 "2017-01-30T13:49:38Z")

</div>

_In reply to [8Blades](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/4):_

The variable starting\_phase is only set when the sequence is starting using the deprecated default\_sequence methodology. Sequences defined for this methodology would typically run forever, so raising an objection in the pre\_body() would result in the simulation hanging do to the objection never being dropped. At all other times, starting\_phase is null.

As I said, you want to minimize raise\_objection() and drop\_objection() calls since they can have a significant performance penalty, especially if you run a sequence thousands of times. Since your test will encapsulate all of your sequences and ensure that every sequence has completed, you should only use objections at the test level.

Also, if you read the complete thread you referenced above, you will see that every response recommends not using objections in sequences.

---

<div class="post-metadata">

**Author:** ![yuanqunnie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/y/f9ae1b/32.png) [@yuanqunnie](https://verificationacademy.com/forums/u/yuanqunnie)\
**Post date:** [January 30, 2017, 8:26pm UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/6 "2017-01-30T20:26:21Z")

</div>

There are difference between pre\_start() and pre\_body().

The pre\_body() is not called if the sequence is started in another sequence.  
So don’t use pre\_body() to do any data initialization or raising objection.

Instead pre\_start() is always called when a sequence is started.

---

<div class="post-metadata">

**Author:** ![8Blades](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/8/4491bb/32.png) [@8Blades](https://verificationacademy.com/forums/u/8Blades)\
**Post date:** [January 31, 2017, 4:30am UTC](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/7 "2017-01-31T04:30:38Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/how-else-we-can-use-pre-body-method-and-post-body-method-in-a-sequence-apart-from-raising-and-dropping-objections/32791/6):_

Thank you cgales !!

Skimming through all the replies, I have concluded that the starting\_phase != null before raising and dropping objection is deprecated and that of pre\_body and post body methods should not be used at all as they impose a performance penalty.

And Thank you all for your valuable clarifications.
