Randomization with uvm_do_with

Hi,
I was trying to randomize the the order of read and write through uvm_do_with. In the following code
1.class ahb_wr_rd_seqs extends ahb_base_seq;
2. `uvm_object_utils(ahb_wr_rd_seqs)
3. function new(string name=“”);
4. super.new(name);
5. endfunction

  1. task body();
  2. repeat(5) begin
  3. `uvm_do_with(req, {req.wr_rd ==1;})
  4. `uvm_do_with(req, {req.wr_rd ==0;})
  5. end
  6. endtask

12.endclass

The order of execution will be 5 write followed by 5 read. Is there any way of randomizing the order of execution here itself?

Regards

In reply to pankajpattel:

You do not randomize the access write/read. You are setting corresponding constraints.
It should start with a write followed by a read 5 times.
If you want to randomize the access use simply

task body();
 repeat(10) begin
 `uvm_do(req)
 end
endtask

Thanks chr_sue. It helped.

Regards