UVM reg field access via name

Is anyone aware as to how we get the details of all the parent registers for a given bit field via name especially if the bit filed is spread over multiple registers … ?

In our register map … we have a bit field[ BIT_FIELD_NAME of width 10 bits] … spread over two registers 4 bits in one and remaining in another

When we try to get the following :

uvm_status_e status;
uvm_reg_data_t value;
string name1;
uvm_reg_field reg_field;
uvm_reg parent_reg;
name1 = “BIT_FIELD_NAME”;



The above only returns the first parent register … is their a way in which i can get the entire list of parent registers … ?

In reply to mayurverf:

The brute force approach is to loop over all registers and collect all of them that have the field:

uvm_reg regs[$];
uvm_reg regs_with_field[$];

foreach (regs*)
  if (regs[i].get_field_by_name(field_name) != null)

There’s a [i]get_fields(…)* function in uvm_reg_map that returns all fields in all regs. You could alternatively loop over those to find the fields with the same name and get their parents.

In reply to Tudor Timi:

Thanks Tudor,

Your suggestion should be able to give me the list … just one more question here …

is their any way i can get to know the which bits of the bit filed are present in the concerned register …

For e.g the 1st register would have bits [4:0] and the 2nd register would have bits [9:5] of the same bit field … ?

In reply to mayurverf:

All UVM REG classes provide introspection functions to be able to inspect various properties. The API docs should help you, such as this one for uvm_reg_field. You can get this information by calling get_lsb_pos() and get_n_bits() on each field object.

In reply to Tudor Timi:

Hi Tudor ,

Is there any way to set those fields by some value. I am using the same foreach loop to get all the registers.But performing some tasks in the fields of those registers.

For example : -

foreach (maps[j])
                       foreach (fields[k]) 
                             if(fields[k].get_n_bits()> 1)
                               for(int n = 0;n < fields[k].get_n_bits();n++)
                                  register_var[regidx].fields[k].set(data[n]);  //setting the desired value 

But this code is not working as the register variable do not have “fields” in them.


In reply to pk_94:

Just do:


The field already knows which register it belongs to.