|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我今天用modelsim6.5仿真发现它好像不太支持mailbox,大家仿仿这个例子,我仿真的结果是: Cannot assign an unpacked type to a packed type.
# Time: 0 ns Iteration: 0 Region: /prog File: test_mailbox.sv
在线等
program test_mailbox();
class transaction;
rand bit a;
rand bit b;
endclass
class sender;
mailbox mbx_s2r;
transaction tr;
function new(mailbox mbx_s2r);
this.mbx_s2r = mbx_s2r;
endfunction: new
task run();
tr=new();
mbx_s2r.put(tr);
$display("send transaction: tr.a=%d,tr.b=%d",tr.a,tr.b);
endtask
endclass
class receiver;
transaction tr;
mailbox mbx_s2r;
function new(mailbox mbx_s2r);
this.mbx_s2r = mbx_s2r;
endfunction: new
task run();
mbx_s2r.get(tr);
$display("get transaction: tr.a=%d,tr.b=%d",tr.a,tr.b);
endtask
endclass
// Top level environment
mailbox mbx_s2r;
initial begin
sender sender;
receiver receiver;
mbx_s2r =new();
sender =new(mbx_s2r);
receiver=new(mbx_s2r);
fork
sender.run();
receiver.run();
join
$finish;
end
endprogram |
|