Built in methods to check if there are any register files in RAL


I have created a RAL model with the registers inside a register file as i wanted them to be replicated.
May i know the details of the built in methods in RAL to check if RAL has register files and if so what are the registers defined inside the register files, their names and offset addresses ?

Thanks in Advance

In reply to Prashanthp436:

Starting with the register model handle, you can get a queue of all registers with get_registers(). From there, call get_regfile() to get a handle to the regfile, if any.

Let me give some more info on this. I have generated the RAL .sv files.
In top uvm_reg_block, it contains another uvm_reg_block which in turn contains register file(and registers with in register file).
When i tried the get_registers() method, i did not get any registers with in the register file. And get_regfile() as well could not find the register file with in the block.

Any other suggestions to find the register file and registers with in register file and their offset addresses ?

Thanks and Regards,

In reply to Prashanthp436:

Read those links in my original reply. For example, get_regfile() is a method for uvm_reg, not uvm_reg_block.

Assume you have the handle top_rm for the top block, of the type uvm_reg_block. Note that this does not have a get_regfile() method - that is for uvm_reg.

Here is an outline of the code - you need to fill in the details including declarations.

top_rm.get_blocks(q); // Get child blocks
foreach (block_q[i]) begin
  block_q[i].get_registers(reg_q); // Get all registers in child block
  foreach (reg_q[i]) begin
    reg_file = reg_q[i].get_regfile();

Write this code one loop at a time, and run it in debug. You should be able to see the data types returned by each step, and then build the code incrementally. You will get a better understanding of these methods than if someone else writes it.

Hi Chris,

I have tried similar code but no use. Let me share the pseudo code that i have written.
class my_test extends uvm_test;

//factory registration ignored
//new constructor for class ignored here

uvm_reg_block reg_model;

virtual task body();
    uvm_reg_block blks[$];
    uvm_reg regs[$];
    reg_model = my_env_inst.ral_model;
    reg_model.get_blocks(blks); //returns the child reg block which has register file instance in it
    foreach(blks) begin
        blks[i].get_registers(regs); // regs queue is empty


→ get_registers() a method of uvm_reg class. but it is not picking the registers which are defined inside the register file.

Confirmed the IPXACT xml file with Accellera forum and it is correct.
=> TOP reg_block contains → child_reg_block contains → Register file contains → Registers

Not sure as to why it is not picking the registers inside register file and register file inside the child reg block

Help me with this.


In reply to Prashanthp436:

What do you see when you run this in a debugger? Look at the properties of each object and follow them manually. Also, add a register that is not in a regfile, and a memory, and explore the objects.

A less interactive approach is to add a call to top_block.print() and look at the actual register hierarchy. What does that show?

Hi Chris,

I have checked the hierarchy using top_blk_inst.print().
It gave top_blk_inst contains → child_blk_inst contains → Reg_file_inst[0],reg_file_inst[1]

It is not picking the registers inside the register file instances.

In reply to Prashanthp436:

Could you please check your regmodel for ‘uvm_reg_file’ to be sure there is a regfile implementation


I could see the register file instance inside the child block.
It was implemented properly.

class reg1 extends uvm_reg;
// all properties and methods

class reg2 extends uvm_reg;
// all properties and methods

class reg3 extends uvm_reg;
// all properties and methods

class reg_file extends uvm_reg_file;
reg1 r1;
reg2 r2;
reg3 r3;
// properties
class child_block extends uvm_reg_block;
reg_file RF[3]; // Register file instance. 3 sets of registers

class top_block extends uvm_reg_block;
child_block ch_blk_inst;
//other properties

In reply to Prashanthp436:

Sorry, I don’t have an example with a regfile, only individual registers. Where did you get your example code?

Perhaps your hierarchy is wrong. The class uvm_reg_block does not have any references to uvm_reg_file, only uvm_reg. Maybe the block should have the registers below it. They can be grouped into a reg_file, but there is no direct link between a block and regfile.