How can I test one random registers from each reg block?

HI ,

I have a requirement like test random one register from each register block .
So I read cookbook and I came to know that I can test a register by using uvm_single_reg_bit_bash_seq.

In my environment I have total 100 registers and 10 register block.
So I want to know that how can I test a random register from each register block?
Please help me .

It would be great for me If you can explain with an example.


In reply to Prashant Soni:
You can get a list of registers in a block, shuffle the list, and then pick the first element.

uvm_reg my_regs[$];
uvm_reg_single_bit_bash_seq my_seq;

my_seq = new($sformatf("%s_seq",my_regs[0].get_full_name());
my_seq.rg = my_regs[0];

Hi Dave,

Thank you so much for your response .
I want to get each block by get_blocks() methode but I am getting an error.
I want to pick one register from each block.
In my ral model (ral_top_block) there are total 10 blocks.
uvm_reg my_regs[]; uvm_reg_single_bit_bash_seq my_seq; uvm_reg_block my_block[];
ral_top_block ral_top;

ral_top.my_block[idx].get_registers(my_regs); → getting error → my_block is not a class item
my_seq = new($sformatf(“%s_seq”,my_regs[0].get_full_name());
my_seq.rg = my_regs[0];
I can’t use my_block variable and If I use block name like
ral_top.ch0_block.get_registers(my_regs) then Its working proparly.
But I want generic method and I don’t want to write above line 10 times .
please help me .


In reply to Prashant Soni:

If you have more than 1 register sub-blocks in your RAL you can get these subblocks by executing ‘get_blocks’.
The definition is:
virtual function void get_blocks (ref uvm_reg_block blks[$], input uvm_hier_e hier = UVM_HIER)

and you have to execute this on your register map.

Afterwards you can extract all registers belonging to the corresponding register block by executing ‘get_registers’.