Write to Register Model based on Physical address

I have a specific requirement where I need to write to memory or register based on physical address. I have handle to register model and need to write to physical address using register model.
I do not know register name and all I have is physical address and reg model handle.
I will get a physical address and need to write using write method in RAL.
Do I get register map and find register name from map (based on physical address) and then use register_name.write()?

Is their any easy way to handle this?

In reply to superUVM:

Hi,

You can use get the register handle first with following code and once you have handle of reg than you can perform any operations.

uvm_reg regs[$];
uvm_reg reg;
int physical_address = 'h99AE;  // This should be base address of map + register address
//get all registers stored in map
ral_model.default_map.get_registers(regs)

//checking individual register address with expected physical_address
foreach(regs[i])
begin
  if(regs[i].get_address(ral_model.default_map) == physical_address)
  begin
    reg = regs[i];
    break;
  end
end
//perform register operation with 'reg' handle
// reg.write or reg.read

Regards,
Mitesh Patel

In reply to mitesh.patel:

Cool, it is working…Thanks.