How to poll for a DUT register field for 1 so that i can call my task

Hi. I have 2 DUT registers(R1,R2) of 16 bit size. If 16th bit of r1 is high then i should read from R2

I have written a task as below


virtual task poll();
  read_the_register(R1,r1_data); //assume the task that reads from DUT register
  if(r1_data[15]) begin
    read_the_register(R2,r2_data);
  end
  else begin
    while(~r1_data[15]) begin
      read_the_register(R1,r1_data);
      if(r1_data[15]) begin
        read_the_register(R2,r2_data);
        return;
      end
    end
  end
endtask

The above task is working good but its hanging sometimes. could you please help me in this context

Hi Prashanth,

Please try the below lines of code in your sequence.

virtual task body();
   bit temp;
   while (temp != 1)
     begin
       // --- Reading the Register 1 --- //
       `uvm_do(req,{req.<register1_address> = <value>;
                    req.<write_signal>      = <value>;});
       get_response(req);
       req.print();
       // --- Driver will send the information from DUT to Sequence --- //
       temp = req.<register1_data>[15];
     end
   // --- Then Reading the Register 2 --- //
   `uvm_do(req,{req.<register2_address> = <value>;
                req.<write_signal>      = <value>;});
    get_response(req);
    req.print();
endtask : body

Thanks,
Furry_Panda