Is there a better way to cycle through array of registers instead of accessing register by register in case statemt or so?

Hello Folks,

a. have set of registers like, DATA0, DATA1, DATA2, … DATA31.
b. I wanted to read only the explicit register based on the loop number with string format, Something like

   regs.DATASET.$psprintf("DATA%d",loop_num).peek(status, reg_value);

c. But the above is not possible.
d. Is there a better way to access them apart form using a case statme or if conditions to access one register after other ?

Share in your suggestsion !
Thx Desperado !

In reply to desperadorocks:

Would the method in the cookbook work (see p.378 “Sequence using read and write, peek and poke”)

spi_reg_block spi_rm;
...
uvm_reg spi_regs[$];
spi_rm.get_registers(spi_regs);
...
spi_regs[i].read(status, data, .parent(this));

You can use reg_block functions get_reg_by_name to get the desired register instance.