UVM: uvm_config_db with multiple set - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

206


90
 
1
`include "uvm_macros.svh"
2
import uvm_pkg::*;
3
4
class component_A extends uvm_component;
5
  int id;
6
  `uvm_component_utils(component_A)
7
  
8
  function new(string name = "component_A", uvm_component parent = null);
9
    super.new(name, parent);
10
    id = 1;
11
  endfunction
12
  
13
  function display();
14
    `uvm_info(get_type_name(), $sformatf("inside component_A: id = %0d", id), UVM_LOW);
15
  endfunction
16
endclass
17
18
class component_B extends component_A;
19
  int receive_value;
20
  int id;
21
  
22
  `uvm_component_utils(component_B)
23
  
24
  function new(string name = "component_B", uvm_component parent = null);
25
    super.new(name, parent);
26
    id = 2;
27
  endfunction
28
  
29
  function void build_phase(uvm_phase phase);
30
    super.build_phase(phase);
31
    if(!uvm_config_db #(int)::get(this, "*", "value", receive_value))
32
      `uvm_fatal(get_type_name(), "get failed for resource in this scope");    
33
  endfunction
34
  
35
  function display();
36
    `uvm_info(get_type_name(), $sformatf("inside component_B: id = %0d, receive_value = %0d", id, receive_value), UVM_LOW);
37
  endfunction
38
endclass
39
40
class env extends uvm_env;
41
  `uvm_component_utils(env)
42
  component_A comp_A;
43
  component_B comp_B;
44
  
45
  function new(string name = "env", uvm_component parent = null);
46
    super.new(name, parent);
47
  endfunction
48
  
49
  function void build_phase(uvm_phase phase);
50
    super.build_phase(phase);
51
    comp_A = component_A ::type_id::create("comp_A", this);
52
    comp_B = component_B ::type_id::create("comp_B", this);
53
    
54
    uvm_config_db #(int)::set(this, "*", "value", 200);
55
  endfunction
56
  
57
  task run_phase(uvm_phase phase);
58
    super.run_phase(phase);
59
    void'(comp_A.display());
60
    void'(comp_B.display());
61
  endtask
62
endclass
63
64
class my_test extends uvm_test;
65
  bit control;
66
  `uvm_component_utils(my_test)
67
  env env_o;
68
  
69
  function new(string name = "my_test", uvm_component parent = null);
70
    super.new(name, parent);
71
  endfunction
72
  
73
  function void build_phase(uvm_phase phase);
74
    super.build_phase(phase);
75
    env_o = env::type_id::create("env_o", this);
76
    
77
    uvm_config_db #(int)::set(null, "*", "value", 100);
78
  endfunction
79
   
80
  function void end_of_elaboration_phase(uvm_phase phase);
81
    super.end_of_elaboration_phase(phase);
82
    uvm_top.print_topology();
83
  endfunction
84
endclass
85
86
module tb_top;
87
  initial begin
88
    run_test("my_test");
89
  end
90
endmodule
xxxxxxxxxx
1
 
1
// Code your design here
2
423 views and 0 likes     
 
Example for uvm_config_db with multiple set

Example for uvm_config_db with multiple set

160:0