Hierarchal Testbench Configuration Using uvm_config_db 7
2 module t b _ t o p();
3 svt _ axi _ if vif();
4 …
5 …
6 initial begin
7 uvm _ cong _ db #(virtual s v t _ a x i _ i f )::set(null, “uvm _ test _ top.env.m _
agent _ 0”, “vif”, vif);
8 end
9 endmodule
10
11 class axi _ agent extends uvm _ agent;
12 virtual svt _ axi _ if vif();
13 …
14
15 virtual function _ void build _ phase(uvm _ phase p h a s e);
16 super.build _ phase( p h a s e );
17 …
18 if(!uvm _ cong _ db#(virtual s v t _ a x i _ i f ):: get(this,””,”v i f ”, v i f ))
19 `uvm _ fatal(“AXI _ AGENT:NOVIF”, “The virtual interface get is not successful”);
20 uvm _ cong _ db#(virtual s v t _ a x i _ i f ):: set(this, “driver”,”vif”,vif);
21 uvm _ cong _ db#(virtual s v t _ a x i _ i f ):: set(this,”m o n it o r ”,” v i f ”,v i f );
22 endfunction
23 endclass
•
(
&
Object Z
uvm_event my _event _too;
uvm_config _db#(uvm _event)::get(this, “”, “my_event”, my _event _too);
Object A
uvm_event my _event;
my _event = new(“my_event”);
uvm_config _db#(uvm _event)::set(this, “agent*”, “my_event”, my _event);
Object X
uvm_event my _event;
uvm_config _db#(uvm _event)::get(this, “”, “my_event”, my _event);
Object Y
uvm_event my _event _also;
uvm_config _db#(uvm _event)::get(this, “”, “my_event”, my _event _also);
event
Event Synchronization
uvm _ cong _ db is used to make the object available for others, it does not create new copies of the object.
Figure 8 below shows how event-object created by Object A is also made available to Objects X, Y and Z through
the uvm _ cong _ db. When Object A chooses to use trigger() for the event object, others can detect
it because they have access to exactly the same object. This demonstrates how the same object “event” is
referenced from four different objects with three different instance names.
Figure 8: uvm_config_db shares handles to existing object
Some attention needs to be paid that set() is called before g et()for a specific item, otherwise get() will
fail. Values passed through uvm _ cong _ db before run _ p hase() need to take into account that
build _ phase()constructs objects from top to bottom. This is often the desired order, since settings and
configurations are usually set from higher levels to lower levels via agents. During the simulation, use of set()
and g et() need to be synchronized/timed by the normal testbench operation or by using events to create a
synchronization mechanism.
Limitations
uvm _ cong _ db can be used anywhere in the hierarchy. The first parameter of set() and g et() functions,
“cntxt”, however needs to be of type class uvm _ component (or extended from that). “cntxt” parameter
is often given value utilizing class member this. So if s et() or g et() functions are used outside uvm _
component extended object, “cntxt” parameter can be given value using uvm _ root::get(), or just
value “null”.