|
楼主 |
发表于 2013-4-23 16:38:18
|
显示全部楼层
本帖最后由 asic_wang 于 2013-4-23 16:42 编辑
module phase_test ;
typedef class A ;
class A_reset_p1_phase extends uvm_task_phase;
virtual task exec_task(uvm_component comp, uvm_phase phase);
A Acp ;
if($cast(Acp,comp))
Acp.reset_p1_phase(phase);
endtask
local static A_reset_p1_phase m_inst;
static const string type_name = "A_reset_p1_phase";
static function A_reset_p1_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
protected function new(string name="A_reset_p1_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class A_reset_p2_phase extends uvm_task_phase;
virtual task exec_task(uvm_component comp, uvm_phase phase);
A Acp ;
if($cast(Acp,comp))
Acp.reset_p2_phase(phase);
endtask
local static A_reset_p2_phase m_inst;
static const string type_name = "A_reset_p2_phase";
static function A_reset_p2_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
protected function new(string name="A_reset_p2_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class A_work_phase extends uvm_task_phase;
virtual task exec_task(uvm_component comp, uvm_phase phase);
A Acp ;
if($cast(Acp,comp))
Acp.work_phase(phase);
endtask
local static A_work_phase m_inst;
static const string type_name = "A_work_phase";
static function A_work_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
protected function new(string name="A_work_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class A_reset_main_phase extends uvm_task_phase;
virtual task exec_task(uvm_component comp, uvm_phase phase);
A Acp ;
if($cast(Acp,comp))
Acp.reset_main_phase(phase);
endtask
local static A_reset_main_phase m_inst;
static const string type_name = "A_reset_main_phase";
static function A_reset_main_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
protected function new(string name="A_reset_main_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class A_wired_phase extends uvm_task_phase;
virtual task exec_task(uvm_component comp, uvm_phase phase);
A Acp ;
if($cast(Acp,comp))
Acp.wired_phase(phase);
endtask
local static A_wired_phase m_inst;
static const string type_name = "A_wired_phase";
static function A_wired_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
protected function new(string name="A_wired_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class A extends uvm_component ;
A_reset_p1_phase rst_p1 ;
A_reset_p2_phase rst_p2 ;
A_work_phase wrk ;
A_reset_main_phase rst_main ;
A_wired_phase wired ;
uvm_domain A_domain ;
`uvm_component_utils(A)
function new(string name = "A", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
uvm_domain common_domain ;
uvm_domain uvm_dom ;
uvm_phase L_sched,M_sched,R_sched ;
super.build_phase(phase);
`uvm_info(get_name(),"build_phase",UVM_NONE)
common_domain = uvm_domain::get_common_domain();
uvm_dom = uvm_domain::get_uvm_domain();
A_domain = new("A_domain");
L_sched = new("L_sched",UVM_PHASE_SCHEDULE);
rst_p1 = A_reset_p1_phase::get();
rst_p2 = A_reset_p2_phase::get();
wrk = A_work_phase::get();
L_sched.add(wrk);
L_sched.add(rst_p2,.before_phase(wrk));
L_sched.add(rst_p1,.before_phase(rst_p2));
M_sched = new("M_sched",UVM_PHASE_SCHEDULE);
rst_main = A_reset_main_phase::get();
M_sched.add(rst_main);
R_sched = new("R_sched",UVM_PHASE_SCHEDULE);
wired = A_wired_phase::get();
R_sched.add(wired);
A_domain.add(L_sched);
common_domain.add(M_sched,.with_phase(common_domain.find_by_name("run")));
common_domain.add(R_sched,.with_phase(common_domain.find_by_name("run")));
common_domain.add(A_domain,.with_phase(common_domain.find_by_name("run")));
A_domain.sync(uvm_dom,A_domain.find_by_name("A_reset_p1_phase"),uvm_dom.find_by_name("reset"));
A_domain.sync(uvm_dom,A_domain.find_by_name("A_work_phase"),uvm_dom.find_by_name("main"));
common_domain.sync(uvm_dom,common_domain.find_by_name("A_reset_main_phase"),uvm_dom.find_by_name("reset"));
common_domain.sync(A_domain,common_domain.find_by_name("A_wired_phase"),A_domain.find_by_name("A_reset_p2_phase"));
set_domain(A_domain);
endfunction
task reset_p1_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"reset_p1_phase start",UVM_NONE)
#6ps ;
`uvm_info(get_name(),"reset_p1_phase end",UVM_NONE)
phase.drop_objection(this);
endtask
task reset_p2_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"reset_p2_phase start",UVM_NONE)
#5ps ;
`uvm_info(get_name(),"reset_p2_phase end",UVM_NONE)
phase.drop_objection(this);
endtask
task work_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"work_phase start;",UVM_NONE)
#26ps ;
`uvm_info(get_name,"work_phase end;",UVM_NONE)
phase.drop_objection(this);
endtask
task reset_main_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"reset_main_phase start;",UVM_NONE)
#30ps ;
`uvm_info(get_name,"reset_main_phase end;",UVM_NONE)
phase.drop_objection(this);
endtask
task wired_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"wired_phase start;",UVM_NONE)
#35ps ;
`uvm_info(get_name,"wired_phase end;",UVM_NONE)
phase.drop_objection(this);
endtask
function void extract_phase(uvm_phase phase);
`uvm_info(get_name(),"extract phase start;",UVM_NONE)
endfunction
endclass
typedef class U ;
class U_check_connect_phase extends uvm_bottomup_phase;
virtual function void exec_func(uvm_component comp, uvm_phase phase);
U Ucp ;
if($cast(Ucp,comp))
Ucp.check_connect_phase(phase);
endfunction
local static U_check_connect_phase m_inst;
static const string type_name = "U_check_connect_phase";
static function U_check_connect_phase get();
if(m_inst == null)
m_inst = new();
return m_inst;
endfunction
`_protected function new(string name="U_check_connect_phase");
super.new(name);
endfunction
virtual function string get_type_name();
return type_name;
endfunction
endclass
class U extends uvm_component ;
`uvm_component_utils(U)
function new(string name = "U", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
uvm_domain common_domain ;
super.build_phase(phase);
common_domain = uvm_domain::get_common_domain();
common_domain.add(U_check_connect_phase::get(),.after_phase(common_domain.find_by_name("connect")));
endfunction
function void check_connect_phase(uvm_phase phase);
`uvm_info(get_name(),"check_connect_phase start;",UVM_NONE)
endfunction
task reset_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"reset phase start;",UVM_NONE)
#10ps ;
`uvm_info(get_name,"reset phase ended;",UVM_NONE)
phase.drop_objection(this);
endtask
task main_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"main phase start;",UVM_NONE)
#20ps ;
`uvm_info(get_name,"main phase ended;",UVM_NONE)
phase.drop_objection(this);
endtask
task shutdown_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_name(),"shutdown phase start;",UVM_NONE)
#8ps ;
`uvm_info(get_name,"shutdown phase ended;",UVM_NONE)
phase.drop_objection(this);
endtask
function void extract_phase(uvm_phase phase);
uvm_component this_test ;
`uvm_info(get_name(),"extract phase start;",UVM_NONE)
endfunction
endclass
class my_test extends uvm_test ;
`uvm_component_utils(my_test)
function new(string name = "my_test", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
A a ;
U u ;
super.build_phase(phase);
a = A::type_id::create("a",this);
u = U::type_id::create("u",this);
endfunction
endclass
initial begin
run_test("my_test") ;
end
endmodule |
|