Inline constraints with uvm_do_on_with macro

In reply to 8Blades:

You need to make sure that you pass down the constraints properly:


class mem_sequence extends uvm_sequence #(mem_seq_item)
   `uvm_object_utils(mem_sequence)
 
    rand mem_seq_item req;
    rand int x,y;
 
task body();
  req = mem_seq_item::type_id::create("req");
  start_item(req);
  if (!req.randomize() with {x == local::x; y == local::y;})
    `uvm_error("randerr", "Error randomizing mem_seq_item");
  finish_item(req);
endtask: body
 
endclass

class base_sequence extends uvm sequence ;
 
 'uvm_object_utils(base_sequence)
 
  mem_sequence seq1;
 
  function new(string name="base_sequence");
    super.new(name);
  endfunction
 
  virtual task body;
    seq1 = mem_sequence::type_id::create("seq1");
    if !(seq1.randomize() with { 
       x inside [0,1,3,4];
       y inside [2,6];
    }) `uvm_error("randerr", "Can't randomize seq1");
    seq1.start(m_sequencer, this)
  endtask
endclass