Query on passing a variable from Module to Class sequence using uvm_config_db

Hi,
I am setting the following in TB top (module)

module top;
bit a;
initial
  uvm_config_db#(bit)::set(uvm_root::get(),"","CONFIG_1",a);
endmodule

And doing a get of the variable in sequence (Class)

class sequence extends uvm_sequence;
bit a

virtual task body();
if(! uvm_config_db #(bit)::get(null, "", "CONFIG_1", a)) 
      `uvm_fatal(get_type_name(), "Can't Get A")
endtask

endclass

I am not getting any fatal error here, at the same time the actual value of “a” is not got in the sequence and always shows as ‘0’. Is there any limitation here in passing variable between Module->class and only interfaces can be passed?

In reply to verif_user:

uvm_config_db::set is only copying the value of the the variable as you call it, not setting up a link to the variable.

If you want to have a probe to the current value of another variable, see my DVCon Paper: The Missing Link: The Testbench to DUT Connection..

In reply to verif_user:

you can pass the variable to the sequencer, then in you sequence call get_sequencer() to retrieve the sequencer handle to probe the value.

Alternative, put the variable into a config object, use uvm_event_pool to get a global event, call uvm_event::trigger(config_obj) to pass the object into the event, then in your sequence get the global event call uvm_evnet::wait_trigger_data(config_obj) to retrieve the object.

In reply to qkuang:

Or just put ‘a’ in a config object and put the handle in the DB. I’ve made ‘a’ an int to pass more info.


module top;
  import uvm_pkg::*;
  `include "uvm_macros.svh"
class ACFG extends uvm_object;
  int a;
endclass

ACFG acfg;
initial begin
  acfg = ACFG::type_id::create("acfg");
  uvm_config_db#(ACFG)::set(null,"CONFIG", "acfg", acfg);
  acfg.a = 42;
end
endmodule

Here is the sequence.

class sequence extends uvm_sequence;
  ACFG acfg;
  int a;
  
  virtual task body();
    if(! uvm_config_db #(ACFG)::get(null, "CONFIG", "acfg", acfg)) 
      `uvm_fatal(get_type_name(), "Can't Get ACFG")
    a = acfg.a;
  endtask
endclass

You have to put the ACFG in a package that is imported into the module, and into the scope where the sequence class is defined.

In reply to verif_user:

Thanks Dave, Chris and Qkuang for your suggestions.