Why it is better to avoid `uvm_do macro in body task ? Why using start_item() and finish_item() is good prctice? Please explain

Actually I read some where it is better to avoid `uvm_do macros in body task of sequence. In spite of using macros it is better to use start_item() and finish_item() . But I am unable to understand why??

In reply to Subhra Bera:
From my practical experience in UVM projects I think this is a religious question.
Cadence is proposing the uvm_do-macros and Menotr is rejecting them because it’ll put additional cost on the execution In my projects we used always the macros and we never saw disadvanteges

In reply to Subhra Bera:

The uvm_do macros expand out to:

create()
start_item()
randomize()
finish_item()

While this is sufficient for some use cases, there are other times when you don’t want to do this:

  • When sending a large number of transactions, the call to create() can add a significant performance penalty. Reusing the same sequence item is preferred.
  • If you want to manually set the sequence item values, it is better performance to directly assign the values than it is to call randomize() with constraints

Because of these performance issues, it’s generally better to use the individual calls for greater flexibility, code readability and consistancy.

Hi Subhra,
Yes, there are some kind of issues listed below:

  1. Macros cannot call pre_body and post_body methods
  2. Macros can be used at the uvm_sequence or its child classes only, cannot be called at the test levels.
  3. As cgales said, its better to create the object outside the start_item and finish_item when you don’t require to do multiple times and anyway the randomization will be done again so that new random values will be taken into consideration.

These are the points which comes to my mind.
Hope it is useful to you.