How to check the register is implemented in UVM RAL with the address

Hi Everyone,
I want to identify a reg is present just by giving input any address , and it should give true or false.

one work around is to read the register using address.
if we are able to read the register, and get the values it exists.
if it gives some dead code/error it does not exist.

Wanted to know some better way to do this.
Thanks

  1. use get_addresses from a reg block , and store all address in a Queue.
  2. Now find index in that queue
    Sample code::
uvm_reg_addr_t addr_q[];
int idx_q[$];
uvm_reg_map map_tmp;
reg_blk.get_addresses(0,map_tmp,addr_q);
idx_q = addr_q.find_index with {item == ur desired Address}:
if(idx_q.size() == 0) `uvm_error("Address Not found");

Reference ::

virtual function int get_addresses(
    uvm_reg_addr_t offset = 0,
    uvm_reg_map    map = null,
ref uvm_reg_addr_t addr[]);