Hello,
I am using UVM from few months.
how to make rand mode of for sequence item without rand_mode inbuilt method.
i tried,
task body();
req.addr.rand_mode(0);
req.data.rand_mode(0);
`uvm_do(req)
endtask
it is showing run time error.
might be possible that req is created at time of uvm_do macro.
so tried uvm create and then rand_mode off and then uvm_rand_send. it is working fine.
So is there any other way to make this rand mode of for a sequence.
THanks in advance. :)
In reply to Dhanesh_Padia:
I guess you are getting NOA (null object error).
That’s because you haven’t created an object for the sequence.
Instead of using
`uvm_do
split that to below approach.
`uvm_create
<set rand modes>
<seq>.randomize()
`uvm_send
I think it is recommended to use .start instead of the macros.
In that case
<create sequence>
<set rand modes>
<seq>.start()
In reply to vvs3693:
We recommend never using the sequence macros so that the intent is always clear to the user and reader of the code:
task body();
req = req_type::type_id::create(...);
start_item(req);
req.addr.rand_mode(0);
req.data.rand_mode(0);
if (!req.randomize()) `uvm_fatal("INVLD_CONSTRAINT","we have a problem")
finish_item(req);
endtask
Thanks Dave and vvs. I will make a mark of this recommended thing.