# Global define UVM\_REG\_DATA\_WIDTH

**URL:** <https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206>\
**Category:** UVM\
**Tags:** UVM, uvm\_reg, UVM\_reg\_field\
**Created:** [November 9, 2015, 4:54pm UTC](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206 "2015-11-09T16:54:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjeevs](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sanjeevs](https://verificationacademy.com/forums/u/sanjeevs)\
**Post date:** [November 9, 2015, 4:54pm UTC](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/1 "2015-11-09T16:54:52Z")

</div>

Hi,  
My block has 512b wide registers. When I create the uvm\_reg\_model for the block I have to define “+UVM\_REG\_DATA\_WIDTH=512”.

Now when the block gets reused in full chip simulation, there are other blocks have width of 32b.  
Hence the full chip has to redefine this value to the greatest width again.

This looks wasteful for memory. (beside being clumsy). Is there any workaround. Not obvious to me why it does not use templates to fix the width of uvm\_reg\_field ?

-sanjeev

---

<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:** [November 10, 2015, 9:15am UTC](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/2 "2015-11-10T09:15:47Z")

</div>

_In reply to [sanjeevs](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206):_

Using templates would be more efficient (in theory), but this usually brings along other problems. For example, the callbacks on registers are intended to work with the _uvm\_reg\_field_ and _uvm\_reg_ classes. If these were parameterized, then we’d need to propagate the parameters to the callback classes that use them. The same applies to other classes that collaborate with them (predictor, map, etc.).

---

<div class="post-metadata">

**Author:** ![sanjeevs](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sanjeevs](https://verificationacademy.com/forums/u/sanjeevs)\
**Post date:** [November 10, 2015, 8:58pm UTC](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/3 "2015-11-10T20:58:54Z")

</div>

_In reply to [Tudor Timi](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/2):_

Thanks,  
I am unable to get the uvm\_reg to generate the correct address for accessing my uvm\_mem “MEM\_winhashmem”. Details below.

Here is my code.

1. I have defined ‘+define+UVM\_REG\_DATA\_WIDTH=512’ since some register X is 512b wide.
2. I have a memory “MEM\_winhashmem” that is 16K \* 512b starting at offset 0x80000 I use a vreg to access it.  
My Model  
=========  
rand my\_uvm\_mem MEM\_winhashmem;  
rand my\_uvm\_vreg winhashmem;

virtual function void build();  
this.MEM\_winhashmem = new(“MEM\_winhashmem”, 16384, 64);  
this.MEM\_winhashmem.configure(this);  
this.winhashmem = new;  
this.winhashmem.configure(this, MEM\_winhashmem, 16384);  
this.winhashmem.build();  
this.default\_map.add\_mem(this.MEM\_winhashmem, `UVM\_REG\_ADDR\_WIDTH’h80000);

# My Sequence

task body();  
regmodel.winhashmem.write(0, status,512’hF000DCAFE); // Generates address 0x80000  
regmodel.winhashmem.write(16383, status, 512’hAA55BBCC); // Generated address 0x17ffc0  
endtask

# Problem

since the memory is only 64b wide, I expected the address of index 16383 = 0x80000 + 0x1fff8 = 0x9FF8

However I am getting 0x80000 + 0x40 \*16383 = 0x17FFC0. This is not correct.

-sanjeev

---

<div class="post-metadata">

**Author:** ![sanjeevs](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sanjeevs](https://verificationacademy.com/forums/u/sanjeevs)\
**Post date:** [November 13, 2015, 9:19pm UTC](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/4 "2015-11-13T21:19:35Z")

</div>

_In reply to [sanjeevs](https://verificationacademy.com/forums/t/global-define-uvm-reg-data-width/31206/3):_

The workaround that seems to work is create a new map for the memory. Specify the size of the map to the size of the memory. So in example above.  
function void build\_phase();  
this.default\_map = create\_map(“”, 0, 8, UVM\_LITTLE\_ENDIAN, 1);  
…  
this.default\_map.add\_mem(this.MEM0, `UVM\_REG\_ADDR\_WIDTH’0);  
end
