Register write in the RAL model

Hi,

I have to write values to a set of registers in the ral model.
How i am doing is :
I hope, i am giving all the sufficient info for the question,

/////////////// working code
///////////

uvm_reg reg_name, regs[$];
 ral_model_handel regmodel;
 string  reg_name_s;
///// getting all the registers
 regmodel.get_registers(regs);

for(int ii=0;ii<7;ii++) begin
reg_name_s = $psprintf("required_reg_%0d_i%0d",channel_num,ii);
       //// this kk loops over all the registers and write and read from required register.
		 for(int unsigned kk=0; kk<regs.size();kk++)begin 
                   $display("regs[kk].get_name = %0s",regs[kk].get_name());
		   if(reg_name_s == regs[kk].get_name()) begin
	             `uvm_info("\n writing to this register",regs[kk].get_full_name(),UVM_LOW)
                      reg_data = (vector >> vector_index) & 'hffff_ffff;
		      $display("reg_data=%0h , vector=%0h",reg_data,vector);
		      regs[kk].write(reg_status,reg_data);
                     regs[kk].read(reg_status,value_r);
                    vector_index = vector_index + 32;
		 end  //// to if
	      end  //// for kk loop, loops over all the register in model
end// for ii loop

////////////////////////////
///////////////////////
following is the doubt
////////////
The way i am trying is,

	  for(int ii=0;ii<7;ii++) begin
         reg_name_s = $psprintf("required_reg_tx_pr_enb%0d_i%0d",channel_num,ii);
         reg_data = (vector >> vector_index) & 'hffff_ffff;
         $psprintf("regmodel.%0s.write(reg_status,reg_data)",reg_name_s);  ////// this way i want to do

if i directly do regmodel.reg_name_s .write(reg_status,reg_data); it gives compilation issue saying reg_name_s is not a class item. so i am trying with $psprintf but it will only prints the reg_name_s but it wont write value to the register.

How can i do in this way replacing and executing reg_name, register write operation.

Many thanks.

In reply to cnu:

I don’t understand what you are doing with your ii-loop.
You can simply loop over all registers in your queue, peforming read/write.
With your $psprintf you are creating a string, but the register is of type uvm_reg.
Thi might be your problem.

Hi thanks, for the reply.
I have as of now total 80 registers.
At any given time i have to write 7 particular registers and they will be in sequence like
reg_name_chan0_0
reg_name_chan0_1
reg_name_chan0_2
reg_name_chan0_3
.
.
reg_name_chan0_6.

So what i want to do is, instead of looping through all the registers(in future many are going to come based on number of channels). How can i directly do write, since i will be knowing the register name with %d for channel number and %d for register number in the below command ,
like
regmodel.reg_name_chan%d_%d.write(status,data);

is it possible below way
$psformatf(“regmodel.reg_name_chan%d_%d.write(status,data)”,chan_num,reg_num)
?

In reply to cnu:

You cannot create a variable identifier by forming a string. But since the RAL model is a database of registers objects with string properties, you can lookup the registers by a string.

uvm_reg required_reg[7];
ral_model_handel regmodel;
...
foreach( required_reg[ii] )
   required_reg[ii] = regmodel.get_reg_by_name($sformatf("required_reg_%0d_i%0d",channel_num,ii));

Then whenever you need to do the write:

foreach( required_reg[ii] )
   required_reg[ii].write(status, data);

Hi
can anyone please explain the significance of RAL model
Thanks
shobhana

In reply to shobhana.swarnkar18:

Yes, there are many people that can explain the significance.

https://verificationacademy.com/sessions/setting-up-register-layer

https://www.doulos.com/knowhow/video_gallery/#anchor51

Thanks Dave