Jump to content

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...