写入systemverilog邮箱失败 [英] Failing to write in systemverilog mailbox
问题描述
我在 UVM SV 测试台中使用邮箱,并在尝试在邮箱中写入时遇到一些问题.我的代码如下所示:
I'm using mailbox in a UVM SV test bench and facing some issue while trying to write in mailbox. My code looks like bellow:
class my_seqyuence extends uvm_sequence;
mailbox data;
some_user_defined_type mydata;
function new(string name = "my_sequence");
super.new(name);
data=new();
endfunction
task body();
forever begin
// blocking-get. program is blocked here... not why get is not returning...!
data.get(mydata);
decode_mydata_and_do_something_here;
end
endtask
function void writetrans(some_user_defined_type trans);
// I used print statements with mailbox size and i can see that valid trans is arriving here and successfully writing to mailbox.
data.try_put(trans)
endfunction
endclass
我不太确定出了什么问题...数据一直到达 writetrans(*) 函数,最终即使邮箱中有空间也无法写入.
I'm not quite sure what went wrong... Data is arriving all the way to writetrans(*) function and eventually it's failing to write even though there is space in mailbox.
推荐答案
你的代码有几个问题,但如果不知道你是如何协调函数和任务的调用,就很难知道可能是什么问题问题.
A couple of issues with your code, but without knowing exactly how you have coordinating the calling of the functions and tasks, it is difficult to know what might be the problem.
您应该始终测试 try_put()
和 try_get()
的结果,看看它们是否成功.
You should always test the result of try_put()
and try_get()
to see if they were successful.
您应该始终使用参数化邮箱以进行更安全的类型检查
You should always use parametrized mailboxes for safer type checking
mailbox #(some_user_defined_type) data;
这篇关于写入systemverilog邮箱失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!