Inline constraints with uvm_do_on_with macro

In reply to Tudor Timi:

I like your solution better. I would make one change to mem_sequence to prevent a possible null object. This doesn’t follow the just-in-time randomization recommendation, but since it is being generated without constraints, it shouldn’t matter.

class mem_sequence extends uvm_sequence #(mem_seq_item)
  rand mem_seq_item req;
 
  function void pre_randomize();
    req = mem_seq_item::type_id::create("req");
  endfunction
 
  task body();
    if (req == null) begin
      req = mem_seq_item::type_id::create("reg");
      if (!req.randomize())
        `uvm_error("randerr", "Unable to randomize mem_seq_item");
    end
    start_item(req);
    finish_item(req);
  endtask: body
 
  `uvm_object_utils(mem_sequence)
endclass