|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
如下的代码是报错的,找不到成员变量在$display("value a is %0d", this.env.a);。但是确实是重载了,因为去掉这个display可以打印base1_test。但是如果需要引用这个变量,该怎么办啊
module aaa ();
import uvm_pkg::*;
class base_env extends uvm_env;
`uvm_component_utils(base_env)
function new(string name="base_env", uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
$display("base_env");
endfunction: build_phase
function void connect_phase(uvm_phase phase); endfunction: connect_phase
endclass: base_env
class base1_env extends base_env;
`uvm_component_utils(base1_env)
int a=10;
function new(string name="base1_env", uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
$display("base1_env");
$display("a is %0d",a);
endfunction: build_phase
function void connect_phase(uvm_phase phase);
endfunction: connect_phase
endclass: base1_env
class base_test extends uvm_test;
`uvm_component_utils(base_test)
base_env env;
function new(string name="base_test", uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
env = base_env::type_id::create("env", this);
endfunction: build_phase
endclass: base_test
class base1_test extends base_test;
`uvm_component_utils(base1_test)
function new(string name="base1_test", uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
// set_inst_override_by_type("env", base_env::get_type(), base1_env::get_type());
set_type_override_by_type(base_env::get_type(), base1_env::get_type());
super.build_phase(phase);
endfunction: build_phase
function void connect_phase(uvm_phase phase);
$display("value a is %0d", this.env.a);
endfunction: connect_phase
endclass: base1_test
initial begin
run_test("base1_test");
end
endmodule
|
|