Can i use uvm_create only once?

Hi All,

I want to know that is it really necessary to do uvm_create every time? Because usually we want random value so that it’s make sense that each and every time we do randomization but why always we do uvm_create?

If so really not necessary then how can we do uvm_create only once for whatever i have all sequences?

Thank you in Advance !!!

The `uvm_do macros are just prepackaged calls to the sequence API with a bit of sugar for creating items and randomizing them added on top. While they’re fine for beginners, most experts recommend using start_item() and finish_item() directly.

You needn’t do a `uvm_create every time if you already have a created object. You can just do:


// create just once
`uvm_create(trans);

// randomize and send
trans.randomize();
`uvm_send(trans);

// do procedural updates and send
trans.field1 = 4;
trans.field2 = 3;
`uvm_send(trans);

In reply to Tudor Timi:

Actually,in my current project i don’t required all stuff.This just an idea.
Say we have base sequence and all other functional sequence derived from base,in in this situation where i can have**“// create just once
`uvm_create(trans)”**so that all functional sequences can use “trans”.

You need to send a unique transaction for each one you send(). You can either create once and send a unique clone(), or create each one you send. You sending a reference to a transaction, not the contents of the transaction. If you only create one transaction, and send the same reference over and over, you that will not work because randomize will change the values of the transaction you just sent as will as the transaction you are about to send. There is also base class data that needs to be unique, the like sequence id number that is used for routing responses. That has to remain unique for reach transaction you send. See Driver/Sequence API | Verification Academy

In reply to dave_59:

I’d get that this is an issue for a pipelined protocol, but it seems overkill for a simple drive and forget protocol like APB (especially if you don’t use responses, but just update the request from the driver).

In reply to Tudor Timi:

Yes… I agree…