With `uvm_do_with constraining object

Hi ,

I am using `uvm_do_with with variable constraints . I am trying to assign object instance through uvm_do_with –

    class io_item extends uvm_sequence_item;

      rand i_entry entry; (object instance)
      rand o_exit exit;  (object instance)
 
      function new ()
      entry = new
      exit = new
      endfunction

    endclass

class seq extends uvm_sequence#(io_item);

rand int addr;
rand i_entry entry; (object instance)
rand o_exit exit; (object instance)

`uvm_do_with(req,{req.addr == local::addr;req.entry == local::entry;req.exit == local::exit;})

endclass

from above example -
object instance assigment req.entry == local::entry and req.exit == local::exit will not get assigned and throws randomization failure error saying conflicts of constraints.
there are no constraints present . can’t we use object instance in `uvm_do_with ?

Thanks
Akhilesh

Show us your ‘local class’ code ?
entry and exit variables of that class are X then you will see randomization failure.

i am randomizing seq from test -

class tc extends bast_test;
int res;
seq seq1;

function void build_phase();
seq1 = seq::type_id::create("seq1",this);
endfunction

task run_phase();

res = seq1.randomize() with {addr == 100;};
seq1.start(sequencer);

endtask

endclass

This is just demo code

In reply to marliwar:

Fine, where/how are you randomizing local class, after randomizing can you see (using $display, to make sure no X) that variables of local class are getting randomized ?

By using
res = seq1.randomize() with {addr == 100;};

I am randomizing whole seq class. I have display inside seq , and local varibles is getting randomizing .

Then i am using

`uvm_do_with(req,{req.addr == local::addr;req.entry == local::entry;req.exit == local::exit;})

In reply to marliwar:

In your seq, you wrote req.addr == local::addr.
now here req is your io_item and i am not able see any addr variable in io_item class.

ya i missed that ,This is just a demo code

Consider addr variable is thr in io_item. But my question is can we assign object instance in io_item to local object instance

In reply to marliwar:

use this.* instead of local::*.

I think i have already explained “this” wont work , while assigning local variable either local variable name has to be different or have to use local:: that to only for inline constraint. i am not facing any issue in variable assignment , only for object instance assignment i faced the issue .

and with the use of “this” it wont assign correct value if variable names are same in `uvm_do_with