In reply to bensaidi:
It would have been so much easier if you had declared an array of fields
class ral_reg_CFGR1 extends uvm_reg;
rand uvm_reg_field SEC[32];
function new(string name = "RISC_RISC_SECCFGR1");
super.new(name, 32,build_coverage(UVM_CVR_REG_BITS));
if (has_coverage(UVM_CVR_REG_BITS))
cg_bits = new();
endfunction: new
virtual function void build();
foreach(SEC[field]) begin
this.SEC0 = uvm_reg_field::type_id::create($sformatf("SEC%0d",field),,get_full_name());
if (field < generic1) b
this.SEC[field].configure(this, 1, 0, "RW", 0, 1'h0, 1, 0, 0);
else
this.SEC[field].configure(this, 1, 31, "R0", 1, 1'h0, 1, 0, 0); // you can use "NO_ACCESS" for uvm1.2
end
endfunction: build
But instead you will have to replicate the code for each field.