How to set the config_db multiple times?

Hi,
I am facing this problem with config_db::set method . I am setting a variable from seq_lib and getting this value in virtual sequencer. The problem is that when i set it for the second time , and reading it for the second time , i am not getting updated value instead of it i am getting the value which i have set in first time.

I am not clear about how to update the config_db??

Plz reply ASAP, thanks in advance

regards
Rishabh

Is this in a loop and you are doing the set/get from the exact same line of code with the exact same arguments, other than the value?

In reply to dave_59:

yes i am doing the exact set/get method from the exact same line of code.

Hi dave, i have written a top module where i set the uvm_config_db and i want to get the config db in assertion module which is instantiated in the top module. is it possible to get the config db from the top to the assertion module

Yes, you can use the uvm_config_db Independently of any UVM testbench. The instance path is just a string and you can use whatever mechanism you want to create a path name. Here I’ve used "%m".

module top;
  import uvm_pkg::uvm_config_db;
  initial begin
    uvm_config_db#(int)::set(null,"top.b1","setting1",1);
    uvm_config_db#(int)::set(null,"top.b2","setting1",2);
    uvm_config_db#(int)::set(null,"*",     "setting2",3);
  end
  
  bot b1();
  bot b2();

endmodule

module bot;
  import uvm_pkg::*;
  int setting1, setting2;
  initial begin
    uvm_wait_for_nba_region(); // make sure get() happens after set()
    if ( uvm_config_db#(int)::get(null, $sformatf("%m"), "setting1", setting1))
      $display("%m setting1 is %0d",setting1);
    else
      $error("%m setting1 not found");
    if ( uvm_config_db#(int)::get(null, $sformatf("%m"), "setting2", setting2))
      $display("%m setting2 is %0d",setting2);
    else
      $error("%m setting2 not found");
  end
endmodule

thank you it’s working.

Hi dave ,is there any way to get the config class in preponed region.I am trying to use config class in the assertions (property) where the signals are sampled in the preponed region.so its throwing error in compliation like illegal reference to class h_device_cfg( config class handle)

You cannot reference non-static members of a class inside a property. You can declare a separate variable and set that from the config class member.

Thank you it’s working