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 address map use the access the register (thus the field).
uvm_reg_field | ||||
Field abstraction class | ||||
Class Hierarchy | ||||
| ||||
Class Declaration | ||||
| ||||
value | Mirrored field value. | |||
Initialization | ||||
new | Create a new field instance | |||
configure | Instance-specific configuration | |||
Introspection | ||||
get_name | Get the simple name | |||
get_full_name | Get the hierarchical name | |||
get_parent | Get the parent register | |||
get_lsb_pos | Return the position of the field | |||
get_n_bits | Returns the width, in number of bits, of the field. | |||
get_max_size | Returns the width, in number of bits, of the largest field. | |||
set_access | Modify the access policy of the field | |||
define_access | Define a new access policy value | |||
get_access | Get the access policy of the field | |||
is_known_access | Check if access policy is a built-in one. | |||
set_volatility | Modify the volatility of the field to the specified one. | |||
is_volatile | Indicates if the field value is volatile | |||
Access | ||||
set | Set the desired value for this field | |||
get | Return the desired value of the field | |||
get_mirrored_value | Return the mirrored value of the field | |||
reset | Reset the desired/mirrored value for this field. | |||
get_reset | Get the specified reset value for this field | |||
has_reset | Check if the field has a reset value specified | |||
set_reset | Specify or modify the reset value for this field | |||
needs_update | Check if the abstract model contains different desired and mirrored values. | |||
write | Write the specified value in this field | |||
read | Read the current value from this field | |||
poke | Deposit the specified value in this field | |||
peek | Read the current value from this field | |||
mirror | Read the field and update/check its mirror value | |||
set_compare | Sets the compare policy during a mirror update. | |||
get_compare | Returns the compare policy for this field. | |||
is_indv_accessible | Check if this field can be written individually, i.e. | |||
predict | Update the mirrored and desired value for this field. | |||
Callbacks | ||||
pre_write | Called before field write. | |||
post_write | Called after field write. | |||
pre_read | Called before field read. | |||
post_read | Called after field read. |
rand uvm_reg_data_t value
Mirrored field value. This value can be sampled in a functional coverage model or constrained when randomized.
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.
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 the simple name
Return the simple object name of this field
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.
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.
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
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 |
”NOACCESS” | W: no effect, R: no effect |
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.
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 specific access value is valid or not. To help catch typing errors, user-defined access values must be defined using this method to avoid begin 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.
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. If the field access contradicts the map’s access value (field access of WO, and map access value of RO, etc), the method’s return value is NOACCESS.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 field 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.
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.
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 abstraction 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.
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 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.
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.
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.
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 and desired value for this field.
Predict the mirror and desired 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 (or desired) 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 successful.
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.
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.
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.
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_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
virtual class uvm_object extends uvm_void
Field abstraction class
class uvm_reg_field extends uvm_object
Mirrored field value.
rand uvm_reg_data_t value
Create a new field instance
function new( string name = "uvm_reg_field" )
Instance-specific configuration
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 )
Get the hierarchical name
virtual function string get_full_name()
Get the parent register
virtual function uvm_reg get_parent()
Return the position of the field
virtual function int unsigned get_lsb_pos()
Returns the width, in number of bits, of the field.
virtual function int unsigned get_n_bits()
Returns the width, in number of bits, of the largest field.
static function int unsigned get_max_size()
Modify the access policy of the field
virtual function string set_access( string mode )
Define a new access policy value
static function bit define_access( string name )
Get the access policy of the field
virtual function string get_access( uvm_reg_map map = null )
Check if access policy is a built-in one.
virtual function bit is_known_access( uvm_reg_map map = null )
Modify the volatility of the field to the specified one.
virtual function void set_volatility( bit volatile )
Indicates if the field value is volatile
virtual function bit is_volatile()
Set the desired value for this field
virtual function void set( uvm_reg_data_t value, string fname = "", int lineno = 0 )
Return the desired value of the field
virtual function uvm_reg_data_t get( string fname = "", int lineno = 0 )
Return the mirrored value of the field
virtual function uvm_reg_data_t get_mirrored_value( string fname = "", int lineno = 0 )
Reset the desired/mirrored value for this field.
virtual function void reset( string kind = "HARD" )
Get the specified reset value for this field
virtual function uvm_reg_data_t get_reset( string kind = "HARD" )
Check if the field has a reset value specified
virtual function bit has_reset( string kind = "HARD", bit delete = 0 )
Specify or modify the reset value for this field
virtual function void set_reset( uvm_reg_data_t value, string kind = "HARD" )
Check if the abstract model contains different desired and mirrored values.
virtual function bit needs_update()
Write the specified value in this field
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 )
Read the current value from 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 )
Deposit the specified value in 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 )
Read the current value from 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 field and update/check its mirror value
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 )
Sets the compare policy during a mirror update.
function void set_compare( uvm_check_e check = UVM_CHECK )
Returns the compare policy for this field.
function uvm_check_e get_compare()
Check if this field can be written individually, i.e.
function bit is_indv_accessible ( uvm_path_e path, uvm_reg_map local_map )
Update the mirrored and desired value for this field.
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 )
Called before field write.
virtual task pre_write ( uvm_reg_item rw )
Called after field write.
virtual task post_write ( uvm_reg_item rw )
Called before field read.
virtual task pre_read ( uvm_reg_item rw )
Called after field read.
virtual task post_read ( uvm_reg_item rw )
Updates the content of the register in the design to match the desired value
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 )
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_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
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 )