I encounter UVM_WARININGs for race condition while doing register set/writes

Hi Team

In my UVM environment, test call a function to write 1 to register ABC[15] and requested value to register ABC[22:17] field of register ABC via backdoor.
I have written code like below…

function void change_linkwidth(int value,aux_value);
      fork
        begin
          bit status;

path.ABC.ABC[15].set('1d);
path.ABC.ABC[22:17].set(value);
path.ABC.write(status, path.ABC.get);
end
      join
    endfunction

On the first call, the function executed successfully, and the test intention was achieved. However, on the second call, I encountered a UVM_WARNING indicating that a race condition occurred. Could you kindly provide some guidance or suggest a possible workaround for this issue?

UVM_WARNING /server/cad/tools/synopsys/vcs/S-2021.09-SP2-1/etc/uvm-1.2/reg/uvm_reg_field.svh(1264) @ 363125.000ns: reporter [UVM/FLD/SET/BSY] Setting the value of field “ABC[15]” while containing register “ABC” is being accessed may result in loss of desired field value. A race condition between threads concurrently accessing the register model is the likely cause of the problem

I tried the same without fork join_none and also with task but both are not working.

Without seeing the entire environment, it is difficult to give a definitive answer.

Based on the message, it seems like you have multiple threads reading and writing registers. I would expect that there is only one thread that does register accesses. Try do determine which threads are conflicting and consolidate the accesses into one thread.

Why are you using a function call? Since register access are typically time consuming, you should be using a task, even if doing back door accesses.