Jump to content
Sign in to follow this  
tudor.timi

uvm_reg_map get_reg_by_offset() is misleading

Recommended Posts

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×