# How to support multiple register maps in a SOC system for a block with only one register map?

**URL:** <https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934>\
**Category:** UVM\
**Tags:** UVM, uvm\_reg, UVM-reuse\
**Created:** [August 7, 2015, 4:56am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934 "2015-08-07T04:56:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinegreen](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/58956e/32.png) [@pinegreen](https://verificationacademy.com/forums/u/pinegreen)\
**Post date:** [August 7, 2015, 4:56am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/1 "2015-08-07T04:56:55Z")

</div>

I have a question of how to reuse a block reg\_block to a multi-processor SOC system level.  
Usually a block has only one configuration interface(AHB, for example), so in the block level environment, it will instantiate its UVM register block(block register model) which only has one UVM register map.

But when the block is reused to the system, especially for a multi-processor system, there should be multiple register maps, and different register map is for different processor. How can we reuse the block register model to the system level and incorporate multiple register maps?

A graceful(also natural) way in my mind is that we should create a top reg\_block for the system level with multiple register maps which has a reference to the block register model, and call add\_submap() API to add the UVM register map defined in the block register model into different register maps in system level, but it seems to me that the current UVM can’t support adding one UVM register map into multiple parent register maps. (i.e. UVM reg\_map can’t support multiple parents, see below code snippets for details)

Can anyone give some suggestions on how to handle that? Thanks a lot!

P.S the relevant UVM source code snippets are as below:

function void uvm\_reg\_map::add\_submap (uvm\_reg\_map child\_map,  
957 uvm\_reg\_addr\_t offset);  
958 uvm\_reg\_map parent\_map;  
959  
960 if (child\_map == null) begin  
961 `uvm_error("RegModel", {"Attempting to add NULL map to map '",get_full_name(),"'"}) 962 return; 963 end 964 965 parent_map = child_map.get_parent_map(); 966 **967 // Can not have more than one parent (currently) 968 if (parent_map != null) begin 969 `uvm\_error(“RegModel”, {“Map '”, child\_map.get\_full\_name(),  
970 “’ is already a child of map '”,  
971 parent\_map.get\_full\_name(),  
972 “'. Cannot also be a child of map '”,  
973 get\_full\_name(),  
974 “'”})\_\_  
975 return;  
976 end\*\*  
977  
978 begin : parent\_block\_check  
979 uvm\_reg\_block child\_blk = child\_map.get\_parent();  
980 if (child\_blk == null) begin  
981 `uvm_error("RegModel", {"Cannot add submap '",child_map.get_full_name(), 982 "' because it does not have a parent block"}) 983 return; 984 end 985 if (get_parent() != child_blk.get_parent()) begin 986 `uvm\_error(“RegModel”,  
987 {“Submap '”,child\_map.get\_full\_name(),“’ may not be added to this “,  
988 “address map, '”, get\_full\_name(),”', as the submap’s parent block, '”,  
989 child\_blk.get\_full\_name(),“', is not a child of this map’s parent block, '”,  
990 m\_parent.get\_full\_name(),“'”})  
991 return;  
992 end  
993 end  
994  
995 begin : n\_bytes\_match\_check  
996 if (m\_n\_bytes \> child\_map.get\_n\_bytes(UVM\_NO\_HIER)) begin  
997 `uvm\_warning(“RegModel”,  
998 $sformatf(“Adding %0d-byte submap ‘%s’ to %0d-byte parent map ‘%s’”,  
999 child\_map.get\_n\_bytes(UVM\_NO\_HIER), child\_map.get\_full\_name(),  
1000 m\_n\_bytes, get\_full\_name()));  
1001 end  
1002 end  
1003  
1004 child\_map.add\_parent\_map(this,offset);  
1005  
1006 set\_submap\_offset(child\_map, offset);  
1007  
1008 endfunction: add\_submap

---

<div class="post-metadata">

**Author:** ![Tudor\_Timi](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tudor_timi/32/1897_2.png) [@Tudor\_Timi](https://verificationacademy.com/forums/u/Tudor_Timi)\
**Post date:** [August 7, 2015, 7:21am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/2 "2015-08-07T07:21:38Z")

</div>

_In reply to [pinegreen](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934):_

I remember trying this out too. The documentation was out of sync, stating that this should be possible, but the BCL gave the nice error message. You could go the long way of mapping all registers/memories into the top level maps and forget the map defined in the module register block:

```verilog

class module_reg_block extends uvm_reg_block;
  // ...
  
  virtual function void build();
    default_map.add_mem(...);
    some_reg_file.map(default_map, ...);
  endfunction
endclass

```

Since we can’t add default map to multiple other maps, we’ll just have to remap:

```verilog

class system_reg_block extends uvm_reg_block;
  module_reg_block module_block;

  // ...
  
  virtual function void build();
    master0_map.add_mem(module_block.mem, ...);
    module_block.some_reg_file.map(master0_map, ...);
    
    master1_map.add_mem(module_block.mem, ...);
    module_block.some_reg_file.map(master1_map, ...);
  endfunction
endclass

```

You could also refactor mapping register elements into a single function that takes the map as an argument to avoid duplication.

---

<div class="post-metadata">

**Author:** ![pinegreen](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/58956e/32.png) [@pinegreen](https://verificationacademy.com/forums/u/pinegreen)\
**Post date:** [August 10, 2015, 3:26am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/3 "2015-08-10T03:26:43Z")

</div>

_In reply to [Tudor Timi](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/2):_

Thank you Tudor.  
It seems that some\_reg\_file.map($reg\_map, …) is not a pre-defined method for uvm\_reg\_block, right?

Do you mean we can create a “map($reg\_map, …)” method inside a $reg\_block which takes $reg\_map as a argument and calls $reg\_map.add\_reg(…) to add all registers to that $reg\_block, and in system level, that $reg\_block.map($sys\_reg\_map, …) method can be called to map all registers in the block $reg\_block to different reg\_maps?

But It seems to me that the following code defined in uvm\_reg\_map requires that the uvm\_reg\_map and the uvm\_reg have the same parent.  
So it seems that the multiple reg\_maps needed to be defined and instantiated in each block $reg\_block, but it is not good since multiple reg\_maps should be invisible in block level from block reuse perspective.

```verilog
function void uvm_reg_map::add_reg(uvm_reg rg, 
                                   uvm_reg_addr_t offset,
                                   string rights = "RW",
                                   bit unmapped=0,
                                   uvm_reg_frontdoor frontdoor=null);

   if (m_regs_info.exists(rg)) begin
      `uvm_error("RegModel", {"Register '",rg.get_name(),
                 "' has already been added to map '",get_name(),"'"})
      return;
   end

   if (rg.get_parent() != get_parent()) begin
      `uvm_error("RegModel",
         {"Register '",rg.get_full_name(),"' may not be added to address map '",
          get_full_name(),"' : they are not in the same block"})
      return;
   end
   
   rg.add_map(this);

   begin
   uvm_reg_map_info info = new;
   info.offset = offset;
   info.rights = rights;
   info.unmapped = unmapped;
   info.frontdoor = frontdoor;
   m_regs_info[rg] = info;
   end
endfunction

```

---

<div class="post-metadata">

**Author:** ![Tudor\_Timi](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tudor_timi/32/1897_2.png) [@Tudor\_Timi](https://verificationacademy.com/forums/u/Tudor_Timi)\
**Post date:** [August 10, 2015, 8:45am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/4 "2015-08-10T08:45:06Z")

</div>

_In reply to [pinegreen](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/3):_

The trick with the _map(…)_ function I “borrowed” from the UVM user guide.

I didn’t know there was this crazy limitation to only add regs from the same block to a reg map. I guess you could work around it by declaring the system maps inside the system reg block and then pass the module reg blocks as parent arguments:

```verilog

class system_reg_block extends uvm_reg_block;
  module_reg_block module_block;
  uvm_reg_map system_map;

  virtual function void build();
    system_map = uvm_reg_map::type_id::create("system_map", , module_block.get_full_name());
    system_map.configure(module_block, ...);
  endclass
endclass

```

It’s kind of like adding the system map inside the module level block, but this way you don’t touch the code for the module register block. You’ll have to see if there are any other repercussions of doing it like this.

---

<div class="post-metadata">

**Author:** ![pinegreen](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/58956e/32.png) [@pinegreen](https://verificationacademy.com/forums/u/pinegreen)\
**Post date:** [August 11, 2015, 2:41am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/5 "2015-08-11T02:41:00Z")

</div>

_In reply to [Tudor Timi](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/4):_

Thank you Tudor for your kindly response. And I summarize your steps to resolve the multiple maps issues and also retain the independence of block level as below:

1. In block level, map($reg\_map, …) function for each block $reg\_block class should be defined, which can map all the registers inside that $reg\_block to the $reg\_map, and take $reg\_map as one of the input arguments.

2. In system level, multiple block reg\_maps need to be defined and created for each block, and block $reg\_block references should be used as the parent of the block reg\_maps, and call $reg\_block.map($block\_reg\_map, …) of each $reg\_block to map all internal registers of the $reg\_block to that $block\_reg\_map.

3. Also in system level, multiple system reg\_maps need to be defined and created for system level, and each $block\_reg\_map need to be added to its corresponding system $system\_reg\_map using add\_submap() function calls.

You workaround seems to work for me, but I still doubt why UVM can’t provide an easier way to support multiple reg\_maps, which seems common in a SOC system.  
For example, if it can support adding one reg\_map to multiple parent reg\_maps, things can become much easier.

---

<div class="post-metadata">

**Author:** ![Tudor\_Timi](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tudor_timi/32/1897_2.png) [@Tudor\_Timi](https://verificationacademy.com/forums/u/Tudor_Timi)\
**Post date:** [August 11, 2015, 8:11am UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/6 "2015-08-11T08:11:48Z")

</div>

_In reply to [pinegreen](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/5):_

I think you can skip step 3 and just use the maps you created in step 2 directly.

Unfortunately, a lot of things are left unfinished in the BCL, which make it necessary to use workarounds.

---

<div class="post-metadata">

**Author:** ![SalemTlse](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@SalemTlse](https://verificationacademy.com/forums/u/SalemTlse)\
**Post date:** [November 1, 2016, 2:55pm UTC](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/7 "2016-11-01T14:55:33Z")

</div>

_In reply to [pinegreen](https://verificationacademy.com/forums/t/how-to-support-multiple-register-maps-in-a-soc-system-for-a-block-with-only-one-register-map/30934/6):_

Hello,  
Could you share an example of your case?  
Thank you  
Salem
