标签:10 name get 示例 component uvm trans UVM
在调用 trans_in.try_get() 方法之前,comp_b 通过调用 trans_in.can_get() 方法检查 comp_a 状态。
在调用 trans_in.can_get() 时,如果 comp_a 准备好发送事物数据包,则返回 1,否则返回 0。
1.在comp_b中调用try_get方法前,调用can_get()方法检查comp_a状态
class component_b extends uvm_component;
transaction trans;
uvm_nonblocking_get_port#(transaction) trans_in;
`uvm_component_utils(component_b)
//---------------------------------------
// Constructor
//---------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
trans_in = new("trans_in", this);
endfunction : new
//---------------------------------------
// run_phase
//---------------------------------------
virtual task run_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info(get_type_name(),$sformatf(" Checking component_a status to get the transaction"),UVM_LOW)
if(trans_in.can_get) begin //{
`uvm_info(get_type_name(),$sformatf(" component_a can send the transaction"),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Requesting transaction."),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Before calling port get method"),UVM_LOW)
if(trans_in.try_get(trans)) begin //{
`uvm_info(get_type_name(),$sformatf(" recived transaction from get method"),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Printing trans, \n %s",trans.sprint()),UVM_LOW)
end //}
else begin //{
`uvm_info(get_type_name(),$sformatf(" Not recived transaction from get method"),UVM_LOW)
end //}
`uvm_info(get_type_name(),$sformatf(" After calling port get method"),UVM_LOW)
end //}
else begin //{
`uvm_info(get_type_name(),$sformatf(" component_a is not ready to send the transaction"),UVM_LOW)
end //}
phase.drop_objection(this);
endtask : run_phase
endclass : component_b
2.在comp_a中实现can_get()方法
class component_a extends uvm_component;
uvm_nonblocking_get_imp#(transaction,component_a) trans_out;
`uvm_component_utils(component_a)
//---------------------------------------
// Constructor
//---------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
trans_out = new("trans_out", this);
endfunction : new
//---------------------------------------
// Imp port try_get method
//---------------------------------------
virtual function bit try_get(output transaction trans);
`uvm_info(get_type_name(),$sformatf(" Recived transaction imp port get request"),UVM_LOW)
trans = transaction::type_id::create("trans", this);
void'(trans.randomize());
`uvm_info(get_type_name(),$sformatf(" tranaction randomized"),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Printing trans, \n %s",trans.sprint()),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Sendting trans packet"),UVM_LOW)
return 1;
endfunction
//---------------------------------------
// Imp port can_get method
//---------------------------------------
virtual function bit can_get();
`uvm_info(get_type_name(),$sformatf(" component_b requested for status"),UVM_LOW)
return 0;
endfunction
endclass : component_a
仿真结果:
UVM_INFO @ 0: reporter [RNTST] Running test basic_test...
------------------------------------------------------
Name Type Size Value
------------------------------------------------------
uvm_test_top basic_test - @336
env environment - @349
comp_a component_a - @358
trans_out uvm_nonblocking_get_imp - @367
comp_b component_b - @377
trans_in uvm_nonblocking_get_port - @386
------------------------------------------------------
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.env.comp_b [component_b] Checking component_a status to get the transaction
UVM_INFO component_a.sv(40) @ 0: uvm_test_top.env.comp_a [component_a] component_b requested for status
UVM_INFO component_b.sv(45) @ 0: uvm_test_top.env.comp_b [component_b] component_a is not ready to send the transaction
标签:10,name,get,示例,component,uvm,trans,UVM 来源: https://www.cnblogs.com/fuqiangblog/p/16677857.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。