modelsim 是否支持 mailbox
时间:10-02
整理:3721RD
点击:
我今天用modelsim6.5仿真发现它好像不太支持mailbox,大家仿仿这个例子,我仿真的结果是: Cannot assign an unpacked type to a packed type.
#Time: 0 nsIteration: 0Region: /progFile: 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
#Time: 0 nsIteration: 0Region: /progFile: 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
唉,人气不旺啊
我用的10.0d可以,你下个高版本的试一下!