While playing with UVM_REG we noticed that the behavior of uvm_reg_map::get_reg_by_offset() is inconsistent. Here's a code example of what I mean:
class some_block extends uvm_reg_block;
some_reg my_reg;
virtual function build();
// ...
default_map.add_reg(my_reg, 'h10);
endfunction
endclass
some_block my_block = new();
my_block.default_map.set_base_addr('h100);
offset = my_block.my_reg.get_offset(); // offset will be 'h10
my_reg = my_block.default_map.get_reg_by_offset(offset); // my_reg will be null
my_reg = my_block.default_map.get_reg_by_offset(offset + 'h100); // my reg will not be null
What I mean by inconsistent is that the meaning of 'offset' is different for 'add_reg(...)' and for 'get_reg_by_offset(...)'. By just passing the offset to it, it doesn't find the register, but by passing it the offset plus the base address it finds the register. Shouldn't get_reg_by_offset not care about the address map's base address?
The code above is just a snippet. The full code is available on EDAPlayground: http://www.edaplayground.com/x/3Z7