Specman UVM: What is the difference between accessing a register directly and using read_reg_val ()?
I am working with vr_ad package for e. I have defined the case my_reg
in vr_ad_reg_file my_reg_file
:
reg_def MY_REG MY_REG_FILE 20'h00018 {
reg_fld my_reg_field : uint (bits : 32) : RW : 0x0;
};
I would like to access the register value. What is the difference (if any) between accessing the register directly:
some_var = my_reg_file.my_reg.my_reg_field;
and accessing the register with read_reg_val()
:
some_var = my_reg_file.my_reg.read_reg_val();
Thank you for your help.
source to share
In your case, since your register only has one field, it doesn't. But to understand a little deeper, consider a case where your register was defined like this:
reg_def MY_REG MY_REG_FILE 20'h00018 {
reg_fld my_reg_field : uint (bits : 32) : W : 0x0;
};
Note that I made the field write-only. Let's say your field is updated with a value 0x1010_1010
.
The call my_reg.my_reg_field
returns this value 0x1010_1010
.
The method read_reg_val()
returns the value that you get when you perform read access to this register. In this case, since the field is not readable, you will get 0x0000_0000
(this value is configurable, but it defaults to reset).
There is also a method read_reg_rawval()
that returns a value that is stored in a register (i.e. ignores field access policies). In our case, it will return the value stored in the field 0x1010_1010
.
read_reg_val()
and read_reg_rawval()
are useful when you have multiple fields declared in a register because these methods will box the values โโof all of them and return a scalar value (of type vr_ad_data_t
).
source to share