Jump to content

how do we sort the UVM_REG space based on address?

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:



foreach (total_regs_ntb)


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



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

Link to comment
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

// 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];

// 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))
  sorted_regs_ntb.next[idx].write(status, wdata, parent(this);

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.

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.

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