Set and get value

  1. I want to declare a int variable in config db.

//configuration class
class config extends uvm_object;
`uvm_object_utils(config)

int value;
function new(string name = "config");
super.new(name);
endfunction
endclass


2.i want set this value= 3(some value) in higher components like env or test


//environment class

config cfg;

function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(int)::set(this,"*","config",cfg.value==5);
endfunction


  1. I want to get the value in lower ever components like monitor or driver.

config mfg;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db)#(int)::get(this,"","config",mfg))
`uvm_fatal("monitor","your are not getting have you set properly in environment")
endclass

task run_phase(uvm_phase phase);
forever
collect();
endtask

task collect();
$display("value =%d",mfg.value);
endtask
endclass

but I am getting value = 0.
Help me in correcting the issue.

In reply to mada saimanasa:

Your code should not have compiled. You are trying to assign in class handle to an int.

You need to set/get the handle to the config object, not its member

//environment class
 
config cfg;
 
function void build_phase(uvm_phase phase);
  super.build_phase(phase);
  cfg = new("cfg");
  cfg.value=5;
  uvm_config_db#(config)::set(this,"*","config",cfg);
endfunction
// monitor
config mfg;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db)#(config)::get(this,"","config",mfg))
`uvm_fatal("monitor","your are not getting have you set properly in environment")
endclass