LTM通信有三种常用的 *** 作:put *** 作、get *** 作和transport *** 作。其中发起者具有的端口是PORT,接收者具有的端口是EXPORT。这三种 *** 作都有阻塞与非阻塞之分。
常用的PORT端口有:
uvm_blocking_put_port#(T); uvm_nonblocking_put_port#(T); uvm_put_port#(T); uvm_blocking_get_port#(T); uvm_nonblocking_get_port#(T); uvm_get_port#(T); uvm_blocking_peek_port#(T); uvm_nonblocking_peek_port#(T); uvm_peek_port#(T); uvm_blocking_get_peek_port#(T); uvm_nonblocking_get_peek_port#(T); uvm_get_peek_port#(T); uvm_blocking_transport_port#(REQ,RSP); uvm_nonblocking_transport_port#(REQ,RSP); uvm_transport_port#(REQ,RSP);
常用的EXPORT端口有:
uvm_blocking_put_export#(T); uvm_nonblocking_put_export#(T); uvm_put_export#(T); uvm_blocking_get_export#(T); uvm_nonblocking_get_export#(T); uvm_get_export#(T); uvm_blocking_peek_export#(T); uvm_nonblocking_peek_export#(T); uvm_peek_export#(T); uvm_blocking_get_peek_export#(T); uvm_nonblocking_get_peek_export#(T); uvm_get_peek_export#(T); uvm_blocking_transport_export#(REQ,RSP); uvm_nonblocking_transport_export#(REQ,RSP); uvm_transport_export#(REQ,RSP);
常用的IMP端口有:
uvm_blocking_put_imp#(T,IMP); uvm_nonblocking_put_imp#(T,IMP); uvm_put_imp#(T,IMP); uvm_blocking_get_imp#(T,IMP); uvm_nonblocking_get_imp#(T,IMP); uvm_get_imp#(T,IMP); uvm_blocking_peek_imp#(T,IMP); uvm_nonblocking_peek_imp#(T,IMP); uvm_peek_imp#(T,IMP); uvm_blocking_get_peek_imp#(T,IMP); uvm_nonblocking_get_peek_imp#(T,IMP); uvm_get_peek_imp#(T,IMP); uvm_blocking_transport_imp#(REQ,RSP,IMP); uvm_nonblocking_transport_imp#(REQ,RSP,IMP); uvm_transport_imp#(REQ,RSP,IMP);
PORT具有高优先级,EXPORT具有中优先级,IMP具有最低优先级,只有高优先级的端口才能向低优先级的端口发起上述三种 *** 作。
2、PORT与EXPORT的连接UVM中使用connect函数建立连接关系,如A要与B通信,这么写:A.port.connect(B.export),写成B.export.connect(A.port)是错误的,因为A是发起者,B是被动承担者,主次顺序一定要对。例子如下:
A的代码:
class A extends uvm_component; `uvm_component_utils(A); uvm_blocking_put_port#(my_transaction) A_port;//定义端口类型 endclass function void A::build_phase(uvm_phase phase); super.build_phase(phase); A_port = new("A_port",this);//例化端口 endfunction task A::main_phase(uvm_phase phase); my_transaction tr; tr = new("tr"); assert(tr.randomize()); A_port.put(tr);//发送tr数据包 endtask
B的代码:
class B extends uvm_component; `uvm_component_utils(B); uvm_blocking_put_export#(my_transaction) B_export;//定义端口类型 uvm_blocking_put_imp#(my_transaction,B) B_imp;//定义端口类型 endclass function void B::build_phase(uvm_phase phase); super.build_phase(phase); B_export = new("B_export",this); B_imp = new("B_imp",this); endfunction function void B::connect_phase(uvm_phase phase); super.build_phase(phase); B_export.connect(B_imp) ; endfunction function void B::put(my_transaction tr); tr.print(); endfunction
在env中建立起两者的连接:
class my_env extends uvm_env; A A_inst; B B_inst; endclass function void my_env::build_phase(uvm_phase phase); super.build_phase(phase); A_inst = A::type_id::create("A_inst",this); B_inst = B::type_id::create("B_inst",this); endfunction function void my_env::connect_phase(uvm_phase phase); super.connect_phase(phase); A_inst.A_port.connect(B_inst.B_export); endfunction3、特别说明
在上述连接关系中,IMP是连接的终点,也只有IMP才能作为连接的终点,PORT或EXPORT作为终点,都会报错。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)