port 和 export声明时只有一个参数,imp有两个参数。
例如:
uvm_blocking_put_export #(my_transaction)B_export;
uvm_blocking_put_imp #(my_transaction, B) B_imp;
TLM不支持factory 机制,故不能用create 实例化。
例如:A_port = new("A_port",this);
i.e. component A中定义A_port(uvm_blocking_put_port),component B中定义B_export(uvm_blocking_put_export )和B_imp(uvm_blocking_put_imp)
A_port被连接到B_export,而B_export被连接到B_imp,当A.A_port.put(transaction)时,发生了什么呢?
1. A.A_port.put(transaction)会调用到与之相连的B_export的task put;
2. B_export的task put 会调用与之相连的B_imp的用户自定义的task/function put;
-----------------------------------------------------------------------------------------------------------------------
class uvm_blocking_put_export #(type T=int) extends uvm_port_base #(uvm_tlm_if_base #(T,T));
function new(string name, uvm_component parent, int min_size=0, int max_size=1);
super.new(name,parent,UVM_EXPORT,min_size,max_size);
m_if_mask = MASK;
endfunction
virtual function string get_type_name();
return NAME;
endfunction
task put(T t);
this.m_if.put(t); //m_if 是指与之相连的 export或imp,UVM中只有IMP才能作为连接关系的终点
endtask
endclass
-------------------------------------------------------------------------------------------------------------------------------
class uvm_blocking_put_imp #(type T=int, type IMP=int) extends uvm_port_base #(uvm_tlm_if_base #(T,T));
local IMP m_imp;
function new(string name, IMP imp);//在new时,一般指定当前的component 作为父节点
super.new(name, imp, UVM_IMPLEMENTION, 1, 1);
m_imp = imp;
m_if_mask = `UVM_TLM_BLOCKING_PUT_MASK;
endfunction
task put(T t);
m_imp.put(t);//用户自定义的task或function
endtask
endclass