uvm_reg_field

Field abstraction class

A field represents a set of bits that behave consistently as a single entity.

A field is contained within a single register, but may have different access policies depending on the adddress map use the access the register (thus the field).

Summary
uvm_reg_field
Field abstraction class
Class Hierarchy
uvm_reg_field
Class Declaration
class uvm_reg_field extends uvm_object
valueMirrored field value.
Initialization
newCreate a new field instance
configureInstance-specific configuration
Introspection
get_nameGet the simple name
get_full_nameGet the hierarchical name
get_parentGet the parent register
get_lsb_posReturn the position of the field
get_n_bitsReturns the width, in number of bits, of the field.
get_max_sizeReturns the width, in number of bits, of the largest field.
set_accessModify the access policy of the field
define_accessDefine a new access policy value
get_accessGet the access policy of the field
is_known_accessCheck if access policy is a built-in one.
set_volatilityModify the volatility of the field to the specified one.
is_volatileIndicates if the field value is volatile
Access
setSet the desired value for this field
getReturn the desired value of the field
get_mirrored_valueReturn the mirrored value of the field
resetReset the desired/mirrored value for this field.
get_resetGet the specified reset value for this field
has_resetCheck if the field has a reset value specified
set_resetSpecify or modify the reset value for this field
needs_updateCheck if the abstract model contains different desired and mirrored values.
writeWrite the specified value in this field
readRead the current value from this field
pokeDeposit the specified value in this field
peekRead the current value from this field
mirrorRead the field and update/check its mirror value
set_compareSets the compare policy during a mirror update.
get_compareReturns the compare policy for this field.
is_indv_accessibleCheck if this field can be written individually, i.e.
predictUpdate the mirrored value for this field.
Callbacks
pre_writeCalled before field write.
post_writeCalled after field write.
pre_readCalled before field read.
post_readCalled after field read.

value

rand uvm_reg_data_t value

Mirrored field value.  This value can be sampled in a functional coverage model or constrained when randomized.

new

function new( string  name  =  "uvm_reg_field" )

Create a new field instance

This method should not be used directly.  The uvm_reg_field::type_id::create() factory method should be used instead.

configure

function void configure( uvm_reg  parent,
int  unsigned  size,
int  unsigned  lsb_pos,
string  access,
bit  volatile,
uvm_reg_data_t  reset,
bit  has_reset,
bit  is_rand,
bit  individually_accessible )

Instance-specific configuration

Specify the parent register of this field, its size in bits, the position of its least-significant bit within the register relative to the least-significant bit of the register, its access policy, volatility, “HARD” reset value, whether the field value is actually reset (the reset value is ignored if FALSE), whether the field value may be randomized and whether the field is the only one to occupy a byte lane in the register.

See set_access for a specification of the pre-defined field access policies.

If the field access policy is a pre-defined policy and NOT one of “RW”, “WRC”, “WRS”, “WO”, “W1”, or “WO1”, the value of is_rand is ignored and the rand_mode() for the field instance is turned off since it cannot be written.

get_name

Get the simple name

Return the simple object name of this field

get_full_name

virtual function string get_full_name()

Get the hierarchical name

Return the hierarchal name of this field The base of the hierarchical name is the root block.

get_parent

virtual function uvm_reg get_parent()

Get the parent register

get_lsb_pos

virtual function int unsigned get_lsb_pos()

Return the position of the field

Returns the index of the least significant bit of the field in the register that instantiates it.  An offset of 0 indicates a field that is aligned with the least-significant bit of the register.

get_n_bits

virtual function int unsigned get_n_bits()

Returns the width, in number of bits, of the field.

get_max_size

static function int unsigned get_max_size()

Returns the width, in number of bits, of the largest field.

set_access

virtual function string set_access( string  mode )

Modify the access policy of the field

Modify the access policy of the field to the specified one and return the previous access policy.

The pre-defined access policies are as follows.  The effect of a read operation are applied after the current value of the field is sampled.  The read operation will return the current value, not the value affected by the read operation (if any).

”RO”W: no effect, R: no effect
”RW”W: as-is, R: no effect
”RC”W: no effect, R: clears all bits
”RS”W: no effect, R: sets all bits
”WRC”W: as-is, R: clears all bits
”WRS”W: as-is, R: sets all bits
”WC”W: clears all bits, R: no effect
”WS”W: sets all bits, R: no effect
”WSRC”W: sets all bits, R: clears all bits
”WCRS”W: clears all bits, R: sets all bits
”W1C”W: 1/0 clears/no effect on matching bit, R: no effect
”W1S”W: 1/0 sets/no effect on matching bit, R: no effect
”W1T”W: 1/0 toggles/no effect on matching bit, R: no effect
”W0C”W: 1/0 no effect on/clears matching bit, R: no effect
”W0S”W: 1/0 no effect on/sets matching bit, R: no effect
”W0T”W: 1/0 no effect on/toggles matching bit, R: no effect
”W1SRC”W: 1/0 sets/no effect on matching bit, R: clears all bits
”W1CRS”W: 1/0 clears/no effect on matching bit, R: sets all bits
”W0SRC”W: 1/0 no effect on/sets matching bit, R: clears all bits
”W0CRS”W: 1/0 no effect on/clears matching bit, R: sets all bits
”WO”W: as-is, R: error
”WOC”W: clears all bits, R: error
”WOS”W: sets all bits, R: error
”W1”W: first one after HARD reset is as-is, other W have no effects, R: no effect
”WO1”W: first one after HARD reset is as-is, other W have no effects, R: error

It is important to remember that modifying the access of a field will make the register model diverge from the specification that was used to create it.

define_access

static function bit define_access( string  name )

Define a new access policy value

Because field access policies are specified using string values, there is no way for SystemVerilog to verify if a spceific access value is valid or not.  To help catch typing errors, user-defined access values must be defined using this method to avoid beign reported as an invalid access policy.

The name of field access policies are always converted to all uppercase.

Returns TRUE if the new access policy was not previously defined.  Returns FALSE otherwise but does not issue an error message.

get_access

virtual function string get_access( uvm_reg_map  map  =  null )

Get the access policy of the field

Returns the current access policy of the field when written and read through the specified address map.  If the register containing the field is mapped in multiple address map, an address map must be specified.  The access policy of a field from a specific address map may be restricted by the register’s access policy in that address map.  For example, a RW field may only be writable through one of the address maps and read-only through all of the other maps.

is_known_access

virtual function bit is_known_access( uvm_reg_map  map  =  null )

Check if access policy is a built-in one.

Returns TRUE if the current access policy of the field, when written and read through the specified address map, is a built-in access policy.

set_volatility

virtual function void set_volatility( bit  volatile )

Modify the volatility of the field to the specified one.

It is important to remember that modifying the volatility of a field will make the register model diverge from the specification that was used to create it.

is_volatile

virtual function bit is_volatile()

Indicates if the field value is volatile

UVM uses the IEEE 1685-2009 IP-XACT definition of “volatility”.  If TRUE, the value of the register is not predictable because it may change between consecutive accesses.  This typically indicates a field whose value is updated by the DUT.  The nature or cause of the change is not specified.  If FALSE, the value of the register is not modified between consecutive accesses.

set

virtual function void set( uvm_reg_data_t  value,   
string  fname  =  "",
int  lineno  =  0 )

Set the desired value for this field

It sets the desired value of the field to the specified value modified by the field access policy.  It does not actually set the value of the field in the design, only the desired value in the abstraction class.  Use the uvm_reg::update() method to update the actual register with the desired value or the uvm_reg_field::write() method to actually write the field and update its mirrored value.

The final desired value in the mirror is a function of the field access policy and the set value, just like a normal physical write operation to the corresponding bits in the hardware.  As such, this method (when eventually followed by a call to uvm_reg::update()) is a zero-time functional replacement for the uvm_reg_field::write() method.  For example, the desired value of a read-only field is not modified by this method and the desired value of a write-once field can only be set if the field has not yet been written to using a physical (for example, front-door) write operation.

Use the uvm_reg_field::predict() to modify the mirrored value of the field.

get

virtual function uvm_reg_data_t get( string  fname  =  "",
int  lineno  =  0 )

Return the desired value of the field

It does not actually read the value of the field in the design, only the desired value in the abstraction class.  Unless set to a different value using the uvm_reg_field::set(), the desired value and the mirrored value are identical.

Use the uvm_reg_field::read() or uvm_reg_field::peek() method to get the actual field value.

If the field is write-only, the desired/mirrored value is the value last written and assumed to reside in the bits implementing it.  Although a physical read operation would something different, the returned value is the actual content.

get_mirrored_value

virtual function uvm_reg_data_t get_mirrored_value( string  fname  =  "",
int  lineno  =  0 )

Return the mirrored value of the field

It does not actually read the value of the field in the design, only the mirrored value in the abstraction class.

If the field is write-only, the desired/mirrored value is the value last written and assumed to reside in the bits implementing it.  Although a physical read operation would something different, the returned value is the actual content.

reset

virtual function void reset( string  kind  =  "HARD" )

Reset the desired/mirrored value for this field.

It sets the desired and mirror value of the field to the reset event specified by kind.  If the field does not have a reset value specified for the specified reset kind the field is unchanged.

It does not actually reset the value of the field in the design, only the value mirrored in the field abstraction class.

Write-once fields can be modified after a “HARD” reset operation.

get_reset

virtual function uvm_reg_data_t get_reset( string  kind  =  "HARD" )

Get the specified reset value for this field

Return the reset value for this field for the specified reset kind.  Returns the current field value is no reset value has been specified for the specified reset event.

has_reset

virtual function bit has_reset( string  kind  =  "HARD",
bit  delete  =  0 )

Check if the field has a reset value specified

Return TRUE if this field has a reset value specified for the specified reset kind.  If delete is TRUE, removes the reset value, if any.

set_reset

virtual function void set_reset( uvm_reg_data_t  value,   
string  kind  =  "HARD" )

Specify or modify the reset value for this field

Specify or modify the reset value for this field corresponding to the cause specified by kind.

needs_update

virtual function bit needs_update()

Check if the abstract model contains different desired and mirrored values.

If a desired field value has been modified in the abstraction class without actually updating the field in the DUT, the state of the DUT (more specifically what the abstraction class thinks the state of the DUT is) is outdated.  This method returns TRUE if the state of the field in the DUT needs to be updated to match the desired value.  The mirror values or actual content of DUT field are not modified.  Use the uvm_reg::update() to actually update the DUT field.

write

virtual task write ( output  uvm_status_e  status,   
input  uvm_reg_data_t  value,   
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )

Write the specified value in this field

Write value in the DUT field that corresponds to this abstraction class instance using the specified access path.  If the register containing this field is mapped in more than one address map, an address map must be specified if a physical access is used (front-door access).  If a back-door access path is used, the effect of writing the field through a physical access is mimicked.  For example, read-only bits in the field will not be written.

The mirrored value will be updated using the uvm_reg_field::predict() method.

If a front-door access is used, and if the field is the only field in a byte lane and if the physical interface corresponding to the address map used to access the field support byte-enabling, then only the field is written.  Otherwise, the entire register containing the field is written, and the mirrored values of the other fields in the same register are used in a best-effort not to modify their value.

If a backdoor access is used, a peek-modify-poke process is used. in a best-effort not to modify the value of the other fields in the register.

read

virtual task read ( output  uvm_status_e  status,   
output  uvm_reg_data_t  value,   
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )

Read the current value from this field

Read and return value from the DUT field that corresponds to this abstraction class instance using the specified access path.  If the register containing this field is mapped in more than one address map, an address map must be specified if a physical access is used (front-door access).  If a back-door access path is used, the effect of reading the field through a physical access is mimicked.  For example, clear-on-read bits in the filed will be set to zero.

The mirrored value will be updated using the uvm_reg_field::predict() method.

If a front-door access is used, and if the field is the only field in a byte lane and if the physical interface corresponding to the address map used to access the field support byte-enabling, then only the field is read.  Otherwise, the entire register containing the field is read, and the mirrored values of the other fields in the same register are updated.

If a backdoor access is used, the entire containing register is peeked and the mirrored value of the other fields in the register is updated.

poke

virtual task poke ( output  uvm_status_e  status,   
input  uvm_reg_data_t  value,   
input  string  kind  =  "",
input  uvm_sequence_base  parent  =  null,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )

Deposit the specified value in this field

Deposit the value in the DUT field corresponding to this abstraction class instance, as-is, using a back-door access.  A peek-modify-poke process is used in a best-effort not to modify the value of the other fields in the register.

The mirrored value will be updated using the uvm_reg_field::predict() method.

peek

virtual task peek ( output  uvm_status_e  status,   
output  uvm_reg_data_t  value,   
input  string  kind  =  "",
input  uvm_sequence_base  parent  =  null,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )

Read the current value from this field

Sample the value in the DUT field corresponding to this absraction class instance using a back-door access.  The field value is sampled, not modified.

Uses the HDL path for the design abstraction specified by kind.

The entire containing register is peeked and the mirrored value of the other fields in the register are updated using the uvm_reg_field::predict() method.

mirror

virtual task mirror( output  uvm_status_e  status,   
input  uvm_check_e  check  =  UVM_NO_CHECK,
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )

Read the field and update/check its mirror value

Read the field and optionally compared the readback value with the current mirrored value if check is UVM_CHECK.  The mirrored value will be updated using the predict() method based on the readback value.

The path argument specifies whether to mirror using the UVM_FRONTDOOR (read) or or UVM_BACKDOOR (peek()).

If check is specified as UVM_CHECK, an error message is issued if the current mirrored value does not match the readback value, unless set_compare was used disable the check.

If the containing register is mapped in multiple address maps and physical access is used (front-door access), an address map must be specified.  For write-only fields, their content is mirrored and optionally checked only if a UVM_BACKDOOR access path is used to read the field.

set_compare

function void set_compare( uvm_check_e  check  =  UVM_CHECK )

Sets the compare policy during a mirror update.  The field value is checked against its mirror only when both the check argument in uvm_reg_block::mirror, uvm_reg::mirror, or uvm_reg_field::mirror and the compare policy for the field is UVM_CHECK.

get_compare

function uvm_check_e get_compare()

Returns the compare policy for this field.

is_indv_accessible

function bit is_indv_accessible ( uvm_path_e  path,
uvm_reg_map  local_map )

Check if this field can be written individually, i.e. without affecting other fields in the containing register.

predict

function bit predict ( uvm_reg_data_t  value,   
uvm_reg_byte_en_t  be  =  -1,
uvm_predict_e  kind  =  UVM_PREDICT_DIRECT,
uvm_path_e  path  =  UVM_FRONTDOOR,
uvm_reg_map  map  =  null,
string  fname  =  "",
int  lineno  =  0 )

Update the mirrored value for this field.

Predict the mirror value of the field based on the specified observed value on a bus using the specified address map.

If kind is specified as UVM_PREDICT_READ, the value was observed in a read transaction on the specified address map or backdoor (if path is UVM_BACKDOOR).  If kind is specified as UVM_PREDICT_WRITE, the value was observed in a write transaction on the specified address map or backdoor (if path is UVM_BACKDOOR).  If kind is specified as UVM_PREDICT_DIRECT, the value was computed and is updated as-is, without regard to any access policy.  For example, the mirrored value of a read-only field is modified by this method if kind is specified as UVM_PREDICT_DIRECT.

This method does not allow an update of the mirror when the register containing this field is busy executing a transaction because the results are unpredictable and indicative of a race condition in the testbench.

Returns TRUE if the prediction was succesful.

pre_write

virtual task pre_write ( uvm_reg_item  rw )

Called before field write.

If the specified data value, access path or address map are modified, the updated data value, access path or address map will be used to perform the register operation.  If the status is modified to anything other than UVM_IS_OK, the operation is aborted.

The field callback methods are invoked after the callback methods on the containing register.  The registered callback methods are invoked after the invocation of this method.

post_write

virtual task post_write ( uvm_reg_item  rw )

Called after field write.

If the specified status is modified, the updated status will be returned by the register operation.

The field callback methods are invoked after the callback methods on the containing register.  The registered callback methods are invoked before the invocation of this method.

pre_read

virtual task pre_read ( uvm_reg_item  rw )

Called before field read.

If the access path or address map in the rw argument are modified, the updated access path or address map will be used to perform the register operation.  If the status is modified to anything other than UVM_IS_OK, the operation is aborted.

The field callback methods are invoked after the callback methods on the containing register.  The registered callback methods are invoked after the invocation of this method.

post_read

virtual task post_read ( uvm_reg_item  rw )

Called after field read.

If the specified readback data or~status~ in the rw argument is modified, the updated readback data or status will be returned by the register operation.

The field callback methods are invoked after the callback methods on the containing register.  The registered callback methods are invoked before the invocation of this method.

The uvm_void class is the base class for all UVM classes.
virtual class uvm_object extends uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
class uvm_reg_field extends uvm_object
Field abstraction class
rand uvm_reg_data_t value
Mirrored field value.
function new( string  name  =  "uvm_reg_field" )
Create a new field instance
function void configure( uvm_reg  parent,
int  unsigned  size,
int  unsigned  lsb_pos,
string  access,
bit  volatile,
uvm_reg_data_t  reset,
bit  has_reset,
bit  is_rand,
bit  individually_accessible )
Instance-specific configuration
virtual function string get_full_name()
Get the hierarchical name
virtual function uvm_reg get_parent()
Get the parent register
virtual function int unsigned get_lsb_pos()
Return the position of the field
virtual function int unsigned get_n_bits()
Returns the width, in number of bits, of the field.
static function int unsigned get_max_size()
Returns the width, in number of bits, of the largest field.
virtual function string set_access( string  mode )
Modify the access policy of the field
static function bit define_access( string  name )
Define a new access policy value
virtual function string get_access( uvm_reg_map  map  =  null )
Get the access policy of the field
virtual function bit is_known_access( uvm_reg_map  map  =  null )
Check if access policy is a built-in one.
virtual function void set_volatility( bit  volatile )
Modify the volatility of the field to the specified one.
virtual function bit is_volatile()
Indicates if the field value is volatile
virtual function void set( uvm_reg_data_t  value,   
string  fname  =  "",
int  lineno  =  0 )
Set the desired value for this field
virtual function uvm_reg_data_t get( string  fname  =  "",
int  lineno  =  0 )
Return the desired value of the field
virtual function uvm_reg_data_t get_mirrored_value( string  fname  =  "",
int  lineno  =  0 )
Return the mirrored value of the field
virtual function void reset( string  kind  =  "HARD" )
Reset the desired/mirrored value for this field.
virtual function uvm_reg_data_t get_reset( string  kind  =  "HARD" )
Get the specified reset value for this field
virtual function bit has_reset( string  kind  =  "HARD",
bit  delete  =  0 )
Check if the field has a reset value specified
virtual function void set_reset( uvm_reg_data_t  value,   
string  kind  =  "HARD" )
Specify or modify the reset value for this field
virtual function bit needs_update()
Check if the abstract model contains different desired and mirrored values.
virtual task write ( output  uvm_status_e  status,   
input  uvm_reg_data_t  value,   
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Write the specified value in this field
virtual task read ( output  uvm_status_e  status,   
output  uvm_reg_data_t  value,   
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Read the current value from this field
virtual task poke ( output  uvm_status_e  status,   
input  uvm_reg_data_t  value,   
input  string  kind  =  "",
input  uvm_sequence_base  parent  =  null,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Deposit the specified value in this field
virtual task peek ( output  uvm_status_e  status,   
output  uvm_reg_data_t  value,   
input  string  kind  =  "",
input  uvm_sequence_base  parent  =  null,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Read the current value from this field
virtual task mirror( output  uvm_status_e  status,   
input  uvm_check_e  check  =  UVM_NO_CHECK,
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Read the field and update/check its mirror value
function void set_compare( uvm_check_e  check  =  UVM_CHECK )
Sets the compare policy during a mirror update.
function uvm_check_e get_compare()
Returns the compare policy for this field.
function bit is_indv_accessible ( uvm_path_e  path,
uvm_reg_map  local_map )
Check if this field can be written individually, i.e.
function bit predict ( uvm_reg_data_t  value,   
uvm_reg_byte_en_t  be  =  -1,
uvm_predict_e  kind  =  UVM_PREDICT_DIRECT,
uvm_path_e  path  =  UVM_FRONTDOOR,
uvm_reg_map  map  =  null,
string  fname  =  "",
int  lineno  =  0 )
Update the mirrored value for this field.
virtual task pre_write ( uvm_reg_item  rw )
Called before field write.
virtual task post_write ( uvm_reg_item  rw )
Called after field write.
virtual task pre_read ( uvm_reg_item  rw )
Called before field read.
virtual task post_read ( uvm_reg_item  rw )
Called after field read.
virtual task update( output  uvm_status_e  status,   
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Updates the content of the register in the design to match the desired value
Read and check
Use the front door
Use the back door
virtual task mirror( output  uvm_status_e  status,   
input  uvm_check_e  check  =  UVM_NO_CHECK,
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Update the mirrored values
virtual task mirror( output  uvm_status_e  status,   
input  uvm_check_e  check  =  UVM_NO_CHECK,
input  uvm_path_e  path  =  UVM_DEFAULT_PATH,
input  uvm_reg_map  map  =  null,
input  uvm_sequence_base  parent  =  null,
input  int  prior  =  -1,
input  uvm_object  extension  =  null,
input  string  fname  =  "",
input  int  lineno  =  0 )
Read the register and update/check its mirror value
Predict based on the specified value having been read
Predict based on the specified value having been written
Predicted value is as-is
Operation completed successfully