The UVM configuration database accessed by the class uvm_config_db is a great way to pass different objects between multiple testbench components. Read more on Using config database for a quick review. There are two primary functions used to put and retrieve items from the database which are set() and get() respectively.

static function void set (  uvm_component   cntxt,
                            string          inst_name,
                            string          field_name,
                            T               value);
static function bit get (   uvm_component  cntxt,
                            string         inst_name,
                            string         field_name,
                      inout T              value);

The best way to understand how the combination of cntxt, inst_name and field_name works is by enabling the commandline debug switch for UVM that dumps information on all the set() and get() calls within a simulation.

Case 1

Let's create a small test class with a simple empty environment, and try to pass configuration data from the test to the environment. In this case, we set the cntxt to null and the inst_name to uvm_test_top to indicate that all components in the test can access the item. To make things simple, we'll put a string item tagged as Friend1.

class base_env extends uvm_env;
  string name;
  virtual function void build_phase (uvm_phase phase);
    super.build_name ();
    // Retrieve the string set from the test in the env
    if (uvm_config_db #(string) :: get (null, "uvm_test_top", "Friend1", name))
      `uvm_info ("ENV", $sformatf ("Found %s", name), UVM_MEDIUM)
class base_test extends uvm_test;
  base_env   m_env;
  virtual function void build_phase (uvm_phase phase);
    // Set this string in the test
    uvm_config_db #(string) :: set (null, "uvm_test_top", "Friend1", "Joey");

Login to your free account to read more ...

Was this article helpful ?