Usage of get_block_by_name in hierarchical register write

Hi,

I am trying below

for(int i=0;i<20;i++) top_reg_model.get_block_by_name($sformatf("grp%0d",i)).block_name.reg_name.write(status,1)

top_reg_model, grp0-grp20, block_name are of type uvm_reg_block.
I am getting compile error that block_name is not a class item.

Can someone guide with what syntax should be?

Thanks,
Kavish

In reply to shahkavish77:

get_block_by_name() returns a handle to a uvm_reg_block base class. If block_name is a member of the block you have a handle to, you would need to downcast it.