|
发表于 2014-6-8 16:41:37
|
显示全部楼层
你需要在一个顶层中将mailbox_A和mailbox_B连接起来,你这么做了吗?
下面是我提出来的一些代码,你看看吧。
在生成器gen.sv中定义mailbox,其中gen是类,所以在构造函数中将其端口连接
mailbox gen2mas;
function new(mailbox gen2mas, );
this.gen2mas = gen2mas; //将外部的mailbox和class中的mailbox连接
endfunction
task put;
gen2mas.put(my_tr);
endtask
//由于程序要求,有用到interface,你不用管它。
在master.sv中使用mailbox //class
mailbox apb_mbox();
function new (virtual apb_if.Master apb,mailbox apb_mbox);
this.apb = apb;
this.apb_mbox = apb_mbox; //将外部的mailbox和class中的mailbox连接
endfunction
task get();
apb_mbox.get(tr);
endtask
在顶层Test.sv中将mailbox连接起来。
program automatic test(apb_if.Master apb);
apb_gen gen;
apb_master mst;
apb_mbox = new();
gen = new(apb_mbox);
mst = new(apb, apb_mbox);
endprogram |
|