Jump to content

bug in uvm_reg_file::get_full_name() ?


Recommended Posts

When printing the full name of a register that is within a child class of uvm_reg_file, the hierarchical path is incorrect. The path should be something like this:

block_name.reg_file[0].register_name.field_name

but what is printed to the screen is:

reg_file[0].register_name.field_name

Digging into it I found that the get_full_name() function in the uvm_reg_file class does something questionable. Here's the code:

function string uvm_reg_file::get_full_name();
   uvm_reg_block blk;

   get_full_name = this.get_name();

   // Do not include top-level name in full name
   if (m_rf != null)
      return {m_rf.get_full_name(), ".", get_full_name};

   // Do not include top-level name in full name
   blk = this.get_block();
   if (blk == null)
      return get_full_name;
   if (blk.get_parent() == null)
      return get_full_name;
   get_full_name = {this.parent.get_full_name(), ".", get_full_name};
endfunction: get_full_name

If you look at the get_block() function, you see that it returns the parent. So the "blk" variable contains a reference to the parent block. Then the next conditional checks if the parent has a parent (i.e. a grandparent). If it doesn't (which it normally won't) then it just returns the block name instead of the full path. This clearly seems wrong. Unless there's something I'm missing, the function should be rewritten like this:

function string uvm_reg_file::get_full_name();
   uvm_reg_block blk;

   get_full_name = this.get_name();

   // Do not include top-level name in full name
   if (m_rf != null)
      return {m_rf.get_full_name(), ".", get_full_name};

   // Do not include top-level name in full name
   if (parent == null)
      return get_full_name;
   get_full_name = {this.parent.get_full_name(), ".", get_full_name};
endfunction: get_full_name
Edited by DavidLarson
Fixed a typo
Link to comment
Share on other sites

  • 2 weeks later...

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...