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