-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuvm_factory_override.sv
135 lines (91 loc) · 3.52 KB
/
uvm_factory_override.sv
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//===============================================================
// UVM Factory override methods
//===============================================================
`include "uvm_macros.svh"
import uvm_pkg::*;
//---------------------------------
// Define base_agent
//---------------------------------
class base_agent extends uvm_agent;
string m_name;
`uvm_component_utils(base_agent)
function new(string name= "base_agent",uvm_component parent=null);
super.new(name,parent);
name=m_name;
endfunction
virtual function void build_phase (uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_type_name,"[base_agent build ] ",UVM_LOW)
endfunction
endclass
//---------------------------------
// Define child_agent
//---------------------------------
class child_agent extends base_agent;
string m_name;
`uvm_component_utils(child_agent)
function new(string name= "child_agent",uvm_component parent=null);
super.new(name,parent);
name=m_name;
endfunction
virtual function void build_phase (uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_type_name,"[child_agent build ] ",UVM_LOW)
endfunction
endclass
//---------------------------------
// Define base_env
//---------------------------------
class base_env extends uvm_env;
base_agent m_agent;
`uvm_component_utils(base_env)
function new(string name= "base_env",uvm_component parent=null);
super.new(name,parent);
// name=m_name;
endfunction
virtual function void build_phase (uvm_phase phase);
super.build_phase(phase);
m_agent =base_agent::type_id::create("m_agent",this);
`uvm_info(get_type_name,"[base_env build ] ",UVM_LOW)
`uvm_info("AGENT",$sformatf("Factory retured of agent type type=%s path=%s",m_agent.get_type_name(),m_agent.get_full_name()),UVM_MEDIUM)
endfunction
// virtual task run_phase(uvm_phase phase);
// #100 global_stop_request();
// endfunction
endclass
//---------------------------------
// Define base_test
//---------------------------------
class base_test extends uvm_test;
`uvm_component_utils(base_test)
base_env m_env;
function new(string name ,uvm_component parent);
super.new(name,parent);
endfunction
virtual function void build_phase (uvm_phase phase);
uvm_factory factory =uvm_factory::get();
super.build_phase(phase);
//1.
set_type_override_by_type(base_agent::get_type(), child_agent::get_type());
//2 .using inst_overide observe path of tb_hiee in logs
// set_inst_override_by_type("m_env.*",base_agent::get_type(), child_agent::get_type());
//3.
//factory.set_type_override_by_name("base_agent","child_agent",{get_full_name(),".m_env.*"});
// 4. Override a particular instance by its name
//factory.set_inst_override_by_name("base_agent", "child_agent", {get_full_name(), ".m_env.*"});
factory.print();
m_env =base_env::type_id::create("m_env",this);
//`uvm_info(get_type_name,"[base test build ] ",UVM_LOW)
//`uvm_info("AGENT",$sformatf("Factory retured of agent type type=%s path=%s",m_agent.get_type_name(),m_agent.get_full_name()),UVM_MEDIUM)
endfunction
virtual function void end_of_elaboration_phase(uvm_phase phase);
uvm_top.print_topology();
endfunction
endclass
//---------------------------------------------------
// run_test();
//----------------------------------------------------
module tb;
initial
run_test("base_test");
endmodule