栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

UVM之TLM通信中的PORT、EXPORT和IMP

UVM之TLM通信中的PORT、EXPORT和IMP

1、PORT、EXPORT和IMP端口简介

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);
endfunction
3、特别说明

在上述连接关系中,IMP是连接的终点,也只有IMP才能作为连接的终点,PORT或EXPORT作为终点,都会报错。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/719242.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号