Jump to content

Recommended Posts

Hi there

 

We want to traverse through all registers present in a UVM_REG_BLOCK based on increasing address.

We have the following pseudocode:

 

model.NTB_DB.get_registers(total_regs_ntb);

foreach (total_regs_ntb)

begin

  total_regs_btb.write(status, wdata, .parent(this));

end

 

But, the above source code does not go through the registers space based on address.

ie., When I have a 2-dimensional array of registers, array indices are chosen first(not addresses).

 

Any help to workaround this problem is appreciated.

 

Best regards

Balasubramanian G

Share this post


Link to post
Share on other sites

hi,

 

you should be 

 

1. getting all registers of a map via uvm_reg_map::get_registers()

2. get the set of addresses of each reg within that map

3, iterate over the ordered set of addresses

 

/uwe

Share this post


Link to post
Share on other sites

The register block doesn't have any knowledge of the register offsets. This is configured in the address map, so you need to call get_registers() from there. I'm not sure in what order the registers will be returned by this method. It doesn't say, so you should consider it an implementation detail and not rely on it. You can sort the output of the method yourself. Here's some code you could try (not tested):

uvm_reg_map map = model.NTB_DB.default_map;
uvm_reg sorted_regs_ntb[uvm_reg_addr_t];


// get all regs
map.get_registers(total_regs_ntb);

// loop through all of these regs and sort them by their offsets
foreach(total_regs_ntb[i]) begin
  uvm_reg_addr_t offset = total_regs_ntb[i].get_offset(map);
  
  // add it to the assoc array
  sorted_regs_ntb[offset] = total_regs_ntb[i];
end

// when you loop through the keys of the assoc array
// it should be sorted
while (1) begin
  int idx;
  if (!sorted_regs_ntb.next(idx))
    break;
  
  sorted_regs_ntb.next[idx].write(status, wdata, parent(this);
end

This is code to get you started, so you have to figure out the details. Also, I'm not sure if it works if you have a map that has submaps.

Share this post


Link to post
Share on other sites

@tudor,

 

the access should go through the map for which you have extracted the addresses. Instead of 

sorted_regs_ntb.next[idx].write(status, wdata, parent(this);

it should be

foreach(sorted_regs_ntb[idx]) sorted_regs_ntb[idx].write(status, wdata, parent(this),map(map));

Share this post


Link to post
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...