A transaction is data item which is eventually or directly processed by the DUT. The packets, instructions, pixels are data items. In uvm, transactions are extended from uvm_transactions class or uvm_sequence_item class. uvm_transaction is a typedef of uvm_sequence_item.
(S)Example of a transaction:
class Packet extends uvm_transaction;
randbit [7:0] da;
randbit [7:0] sa;
randbit [7:0] length;
randbit [7:0] data[];
randbyte fcs;
endclass
Core Utilities:
uvm_transaction class is extended from uvm_object. uvm_transaction adds more features line transaction recording , transaction id and timings of the transaction.
The methods used to model, transform or operate on transactions like print, copying, cloning, comparing, recording, packing and unpacking are already defined in uvm_object.
FIG: UVM OBJECT UTILITIES
User Defined Implementations:
User should define these methods in the transaction using do_<method_name> and call them using <method_name>. Following table shows calling methods and user-defined hook do_<method_name> methods. Clone and create methods, does not use hook methods concepts.
Shorthand Macros:
Using the field automation concept of uvm, all the above defines methods can be defined automatically.
To use these field automation macros, first declare all the data fields, then place the field automation macros between the `uvm_object_utils_begin and `uvm_object_utils_end macros.
For most of the data types in systemverilog, uvm defined corresponding field automation macros. Following table shows all the field automation macros.
Each `uvm_field_* macro has at least two arguments: ARG and FLAG.
ARG is the instance name of the variable and FLAG is used to control the field usage in core utilities operation.
Following table shows uvm field automation flags:
By default, FLAG is set to UVM_ALL_ON. All these flags can be ored. Using NO_* flags, can turn of particular field usage in a paerticuler method. NO_* flags takes precedency over other flags.
(S)Example of Flags:
`uvm_field_int(da, UVM_ALL_ON|UVM_NOPACK)
The above macro will use the field "da" in all utilities methods except Packing and unpacking methods.
(S)Lets see a example:
In the following example, all the utility methods are defined using field automation macros except Packing and unpacking methods. Packing and unpacking methods are done in do_pack() amd do_unpack() method.
`include "uvm.svh"
import uvm_pkg::*;
//Define the enumerated types for packet types
typedefenum { GOOD_FCS, BAD_FCS } fcs_kind_t;
///// method to calculate the fcs /////
virtualfunctionbyte cal_fcs;
integer i;
byte result ;
result = 0;
result = result ^ da;
result = result ^ sa;
result = result ^ length;
for (i = 0;i< data.size;i++)
result = result ^ data[i];
result = fcs ^ result;
return result;
endfunction : cal_fcs
/////////////////////////////////////////////////////////
//// Test to check the packet implementation ////
/////////////////////////////////////////////////////////
module test;
Randomization Sucessesfull.----------------------------------------------------------------------Name Type Size Value----------------------------------------------------------------------pkt1 Packet - pkt1@3 da integral 8 'h1d sa integral 8 'h26 length integral 8 'h5 data da(integral) 5 - [0] integral 8 'hb1 [1] integral 8 'h3f [2] integral 8 'h9e [3] integral 8 'h38 [4] integral 8 'h8d fcs integral 8 'h9b----------------------------------------------------------------------Size of pkd bits 9----------------------------------------------------------------------Name Type Size Value----------------------------------------------------------------------pkt2 Packet - pkt2@5 da integral 8 'h1d sa integral 8 'h26 length integral 8 'h5 data da(integral) 5 - [0] integral 8 'hb1 [1] integral 8 'h3f [2] integral 8 'h9e [3] integral 8 'h38 [4] integral 8 'h8d fcs integral 8 'h9b---------------------------------------------------------------------- Packing,Unpacking and compare worked