balasubramanian.g@pmcs.com Posted September 30, 2014 Report Posted September 30, 2014 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 Quote
uwes Posted September 30, 2014 Report Posted September 30, 2014 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 Quote
tudor.timi Posted September 30, 2014 Report Posted September 30, 2014 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. karandeep963 1 Quote
uwes Posted September 30, 2014 Report Posted September 30, 2014 @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)); karandeep963 1 Quote
balasubramanian.g@pmcs.com Posted October 1, 2014 Author Report Posted October 1, 2014 Hi Uwe/Tudor I used the get_offset() method to iterate through the registers and sort it based on offset. Thanks for your timely responses. Best regards Balasubramanian G Quote
Recommended Posts
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.