Why do we need pre_body and post_body in a sequence

why do we need pre_body and post_body in a UVM sequence?

we have pre and post randomize to control anything related to randomization , so outside of it why do we even need any thing else outside body as we can break down the sequence steps using start_item, finish_item for any customization without using uvm_do macros.

Please help in throwing any info on what these pre post body are and any examples on when we would need them in a sequence.

In reply to hsam:

Hi,hsam

I think the pre_body and post_body are like an entrance for user,it can help to transplant and customize the user‘s verfication environment. Whether to use them depends on the user, but when the user wants to use something to change the “body” , these two tasks provide a good entrance.

Best regards,
Mike

In reply to mike_wang:

Can you share an example scenario?

In reply to hsam:

You don’t need to use pre_/post_body. If you don’t understand the situations when they are or are not called, they can be disastrous. You are much better off taking advantage of OOP and the factory overrides and explicitly wrapping your code around a call to super.body().

class my_base_sequence extends uvm_sequence#(my_item);
  task body;
    // normal sequence body code
  endtask
endclass
class my_extended_sequence extends my_base_sequence;
  task body;
    // pre_body code here
    super.body();
   // post_body code here.
  endtask
endclass

In reply to dave_59:

Thanks Dave for the simple yet detailed explanation.