UVM Sequence item
The sequence-item is written by extending the uvm_sequence_item, uvm_sequence_item inherits from the uvm_object via the uvm_transaction class. therefore uvm_sequence_item is of an object type.
Before moving to uvm_sequence_item will look into uvm_object concepts required to write uvm_sequence_item, The uvm_object has a number of virtual methods that are used to implement common data object functions (copy, clone, compare, print, transaction, and recording) and these should be implemented to make the sequence_item more general purpose.also, uvm_object has macros defined in it, mainly Utility Macros and Field Macros.
一、UVM Utility Macros
The utility macros provide implementations of the create method (needed for cloning) and the get_type_name method (needed for debugging), etc.
1、objects with no field macros,
`uvm_object_utils(TYPE)
2、objects with field macros,
`uvm_object_utils_begin(TYPE)
`uvm_field_*(FIELD, FLAG)
`uvm_object_utils_end
二、UVM Field Macros
The `uvm_field_* macros are invoked inside of the `uvm_*_utils_begin and `uvm_*_utils_end, for the implementations of the methods: copy, compare, pack, unpack, record, print, and etc.
Each `uvm_field_* macro is named to correspond to a particular data type: integrals, strings, objects, queues, enum, etc., and each has at least two arguments: FIELD and FLAG.
`uvm_field_*(FIELD, FLAG);
FLAG | Description |
---|---|
UVM_ALL_ON | Set all operations on (default) |
UVM_DEFAULT | Use the default flag settings |
UVM_NOCOPY | Do not copy this field |
UVM_NOCOMPARE | Do not compare this field |
UVM_NOPRINT | Do not print this field |
UVM_NODEFPRINT | Do not print the field if it is the same as its |
UVM_NOPACK | Do not pack or unpack this field |
UVM_PHYSICAL | Treat as a physical field. Use physical setting in policy class for this field |
UVM_ABSTRACT | Treat as an abstract field. Use the abstract setting in the policy class for this field |
UVM_READONLY | Do not allow the setting of this field from the set_*_local methods |
A radix for printing and recording can be specified by OR’ing one of the following constants in the FLAG argument | |
UVM_BIN | Print/record the field in binary (base-2) |
UVM_DEC | Print/record the field in decimal (base-10) |
UVM_UNSIGNED | Print/record the field in unsigned decimal (base-10) |
UVM_OCT | Print/record the field in octal (base-8). |
UVM_HEX | Print/record the field in hexadecimal (base-16) |
UVM_STRING | Print/record the field in string format |
UVM_TIME | Print/record the field in time format |
1、Sequence item:
The sequence-item consist of data fields required for generating the stimulus.In order to generate the stimulus, the sequence items are randomized in sequences. Therefore data properties in sequence items should generally be declared as rand and can have constraints defined.Data fields represent the following types of information,
- Control Information – a type of transfer, transfer size, etc
- Payload Information – data content of the transfer
- Configuration Information – mode of operation, error behavior, etc
- Analysis Information – fields used to capture information from DUT, ex: read data, response, etc
As analysis information fields will be used for capturing response, except these fields the other fields can be declared as rand and can have constraints associated with it.
2、Sequence item example
class mem_seq_item extends uvm_sequence_item;
//Control Information
rand bit [3:0] addr;
rand bit wr_en;
rand bit rd_en;
//Payload Information
rand bit [7:0] wdata;
//Analysis Information
bit [7:0] rdata;
//Utility and Field macros,
`uvm_object_utils_begin(mem_seq_item)
`uvm_field_int(addr,UVM_ALL_ON)
`uvm_field_int(wr_en,UVM_ALL_ON)
`uvm_field_int(rd_en,UVM_ALL_ON)
`uvm_field_int(wdata,UVM_ALL_ON)
`uvm_object_utils_end
//Constructor
function new(string name = "mem_seq_item");
super.new(name);
endfunction
//constaint, to generate any one among write and read
constraint wr_rd_c {
wr_en != rd_en;
};
endclass