How else we can use pre_body method and post_body method in a sequence apart from raising and dropping objections?

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?

In reply to 8Blades:

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.

In reply to cgales:
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

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

In reply to 8Blades:

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
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.

In reply to 8Blades:

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.

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.

In reply to cgales:

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.