Using uvm_config_db to nitialize/pass params from the sequence to the transaction?

I have the following transaction:

typedef enum {READ = 0, WRITE = 1} direction_enum;


//Transaction

class axi_transaction extends uvm_sequence_item();
   bit id = 0;  //const
   bit [31:0] addr;
   bit [2:0]  size = 0'b100;//const
   direction_enum rw;
   bit [31:0] transfers [$];



   //factory registration
   `uvm_object_utils_begin(axi_transaction)
   `uvm_field_int(id, UVM_ALL_ON)
   `uvm_field_int(addr, UVM_ALL_ON)
   `uvm_field_int(size, UVM_ALL_ON)
   `uvm_field_enum(rw, UVM_ALL_ON)
   `uvm_field_int(transfers, UVM_ALL_ON)      
   `uvm_object_utils_end  

   //constructor
   function new(string name = "axi_transaction");
      super.new(name);
   endfunction: new

endclass: axi_transaction

I understood that I have to use uvm_config_db, so I can initializes the transaction in the sequence with arguments which initialize some of the transaction members (like addr, transfers) by, but I’m not sure how to do it.

In reply to saritr:

You don’t want to use the config_db to initialize arguments. This is because the config_db isn’t designed to handle dynamic data efficiently.

You want to set the data elements to the appropriate values when the sequence item is created/randomized:


axi_transaction m_txn;

m_txn = axi_transaction::type_id::create("m_txn");
m_txn.addr = xxxxx;
m_txn.size = xxxxx;
...