Uvm Config DB
Uvm Config DB
uvm_config_db
3) It provides facility to user to customize their TB and reuse without making changes in
source code.
5) the UVM Config DB is a powerful and flexible tool, but it should be used with care to
ensure easy maintainability and readability of your testbench code.
SYNTAX:
Where,
Contx: Hierarchy point
Instance_name : Hierarchy path;
String_field_name : Act like pointer for the database what we are setting value
SET METHOD :
i) Set method used in top level
ii) Set method provide visibility to lower level components
iii) Set method returns void type
GET METHOD:
@shraddha_pawankar date : 2/8/23
ii) Get method is used to access the database which was set area
Note :
Que 2) Can you set configuration parameters for a specific instance of a component?
Que 3) How do you handle situations where multiple components want to set the same
configuration parameter?
Que 4) Can you use the UVM Config DB to set configuration parameters for sequence
items and sequences?
Yes, the UVM Config DB can be used to set configuration parameters for sequence items and
sequences as well.
No, uvm config db is used for wide range of datatype including string,integer,Boolean,user
defined datatypes.
Que 6) Can you set configuration parameters for different phases in the UVM
testbench?
Que 7) How do you initialize the UVM Config DB before using it in a testbench?
Que 8) Can you use the UVM Config DB outside of UVM components?
@shraddha_pawankar date : 2/8/23
Que 9) How do you debug issues related to the UVM Config DB?
Que 10) Can you change configuration parameters at runtime during simulation?
Yes we can change,we can modify the behavior of components during run time.
Yes, we can set default values for configuration parameters in the components themselves.
-----------------------------------------------------------------------------------------------------
Que 13) Can configuration parameters be set during the elaboration phase of the
testbench?
Que 14) How do you handle situations where a configuration parameter needs to be
set differently for different test scenarios or use cases?
Que 15) Can you set configuration parameters for a specific instance and its
descendants in one call?
Example:
Uvm_config_db#(virtual intf)::get(this,”*”,”intf”,vif);
Que 16) How can you ensure that configuration parameters are set before components
start using them during simulation?
------------------------------------------------------------------------------------------------------
Que 17) Can you set configuration parameters for virtual interfaces and channels using
the UVM Config DB?
Yes, the UVM Config DB can be used to set configuration parameters for virtual interfaces
@shraddha_pawankar date : 2/8/23
//**********SET METHOD***********//
uvm_config_db#(int)::set(null, ”*” ,”k”,10);
int = datatype
null = uvm_root
“*” = visibility to allow lower level component
“k” = key(use same key while get else will fail
10 = value(which we are setting)
//*******GET METHOD***********//
uvm_config_db#(int)::get(null,” ”, ”k” ,i)
int = datatype
null = uvm root
“ ” = for component class for object class ,get_full_name()
“k” = use same while get else will fail
----------------------------------------------------------------------------------------------------------------------
String field_name,
inout T value);
Example
`include "uvm_macros.svh" //access all uvm macros
///////////////////////////env class///////////////////////////////
Lower level component (where we are getting value)
int i;
function new(string name="",uvm_component parent);
super.new(name,parent);
endfunction
super.build_phase(phase);
if(!uvm_config_db#(int)::get(null,"","k",i))
`uvm_error(get_type_name(),$sformatf("getting value of i=%0d",i),UVM_NONE)
else
////////////////////////TEST CLASS/////////////////////////
Higher level component,whivh we are setting value
endfunction
/////////TOP//////////
module top;
initial
begin
run_test("test");//run all the phases
end
endmodule
https://www.edaplayground.com/x/8ZFz
@shraddha_pawankar date : 2/8/23
Example 2)
`include "uvm_macros.svh" //access all uvm macros
import uvm_pkg::*; //access of uvm classes
///////env class/////////
string s;
function new(string name="",uvm_component parent);
super.new(name,parent);
endfunction
if(!uvm_config_db#(string)::get(null,"","k",s))
//////test class//////
super.new(name,parent);
endfunction
endclass
/////////TOP//////////
module top;
initial
begin
run_test("test");//run all the phases
end
endmodule
`include "uvm_macros.svh"
import uvm_pkg::*;
int data;
function new(string name="",uvm_component parent);
super.new(name,parent);
endfunction
endtask
endclass
module tb();
test t;
initial
begin
t=new("TEST",null);
uvm_config_db#(int)::set(null,"*","data",12);
run_test();
end
endmodule
https://www.edaplayground.com/x/nX_K
--------------------------------------------------------------------------------------------------------------------------