[CU]callback机制2-子类继承父类的callback机制

背景:对旧的验证平台升级,新旧验证平台基本一致,只是需要扩展my_driver的功能,从其派生出新类new_driver; 此外,旧的验证平台中大量使用了callback机制; 怎么处理才能使原来的callback函数/任务能够用于new_driver中呢?

 

 1 class new_driver extends my_driver;
 2     `uvm_component_utils(new_driver)
 3     `uvm_set_super_type(new_driver,my_driver)
 4     ...
 5 endclass
 6 
 7 task new_driver::main_phase(uvm_phase phase);
 8     ...
 9     while(1) begin
10         seq_item_port.get_next_item(req);
11         `uvm_do_callbacks(my_driver,A,pre_trans(this,req))
12         drive_one_pkt(req);
13         seq_item_port.item_done();
14     end
15 endtask
16 
17 //my_agent.sv
18 function void my_agent::build_phase(uvm_phase phase);
19         super.build_phase(phase);
20         if(is_active==UVM_ACTIVE) begin
21             sqr=my_sequencer::type_id::create("sqr",this);
22             drv=new_driver::type_id::create("drv",this);
23         end
24         mon=my_monitor::type_id::create("mon",this);
25 endfunction

 

posted on 2021-11-11 14:46  知北游。。  阅读(143)  评论(0编辑  收藏  举报

导航