RAL :: get_reg_by_offset() method

Hi all,

I am having question on get_reg_by_offset() method of reg_map. As per the code, it has two arguments, one is offset which should be the address of the register [with additional base offset] for which register handle is needed, and second one is read which is default 1.
Can anyone provide more information about read and offset? where i should pass read as “1” or “0”.

function uvm_reg uvm_reg_map::get_reg_by_offset(uvm_reg_addr_t offset,
                                                bit            read = 1);
   if (!m_parent.is_locked()) begin
      `uvm_error("RegModel", $sformatf("Cannot get register by offset: Block %s is not locked.", m_parent.get_full_name()));
      return null;
   end
   `uvm_info(get_name(), $sformatf("TEST DEBUG 1. : OFFSET %0h IS_READ :%0d REG_EXIST : %0d", offset, read, m_regs_by_offset_wo.exists(offset)), UVM_LOW)
   if (!read && m_regs_by_offset_wo.exists(offset))
     return m_regs_by_offset_wo[offset];
   
   `uvm_info(get_name(), $sformatf("TEST DEBUG 2. : OFFSET %0h IS_READ :%0d REG_EXIST : %0d", offset, read, m_regs_by_offset.exists(offset)), UVM_LOW)
   if (m_regs_by_offset.exists(offset))
     return m_regs_by_offset[offset];

   return null;
endfunction

Also, i tried one scenario on which, i configured two different register which same address on same map with “RO” and “WO” accesses. then i performed following operations.

1. uvm_reg rg = ral_block.reg_map1.get_reg_by_offset('h64);
 2. uvm_reg rg = ral_block.reg_map1.get_reg_by_offset('h64, 0);

First line returns, register handlle configured with “RO” access, and second line returns register handle configured with “WO” access.
Can anyone please tell me that how this happened?

Thanks in advance
Mitesh Patel

In reply to mitesh.patel:

Hi all,

Can anyone please help…!!

Thanks and Regards,
Mitesh Patel

In reply to mitesh.patel:

This is what the UVM Reference Manmual is saying:

virtual function uvm_reg get_reg_by_offset(uvm_reg_addr_t offset, bit read = 1)

Get register mapped at offset.

Identify the register located at the specified offset within this address map for the specified type of access. Returns null if no such register is found.

The model must be locked using uvm_reg_block::lock_model() to enable this functionality.

In reply to chr_sue:

Thanks @chr_sue for response. Can you please provide more detail about input arguments(offset and read) and the scenario which i mentioned above.

Thanks and Regards,
Mitesh Patel

In reply to mitesh.patel:

Visit the UVM Reference Manual. There you’ll find the details.