最近在项目中遇到需要改变task/function 形参类型,寻求了一种实现方法,记录一下~~
virtual class SCB_SRC#(type T=int, int BW =32);
extern static task data_cmp(string gld_file, ref T dut_q[$], bit[BW-1:0] gld_q_q[$][$], virtual tx_if vif)
endclass
task SCB_SRC::data_cmp(string gld_file,ref T dut_q[$],bit[BW-1:0]gld_q_q[$][$],virtual tx_if vif);
forever begin
@(posedge vif.tx_en);
...
end
endtask
//调用
SCB_SRC#(tx_trans,4)::data_cmp("tx_data.txt",out_data_q[0],gld_data_q_q,top_vif);
SCB_SRC#(tx_mon_trans,10)::data_cmp("tx_mon_data.txt",out_data_q[2],gld_data_q_q,top_vif);