目录
. TLM (transaction level modeling )通信
. TLM (transaction level modeling )通信
1.1 基本概念
TLM是一种基于事务(transaction)的通信方式,主要用作在高级抽象语言(systemc或者sv和uvm)中作为模块之间的通讯方式。
TLM通信需要两个通信的对象,发起请求的作为initiator,对应响应的作为target。
initiator只是作为通信请求的发起方,并不代表着数据就从initiator流出,同样的,target也不一定是数据的终点。数据是从producer流出,最终流向consumer。
1.2 使用原则/方法
①当两个通信的对象确定后,通信的方法在target中实现,然后initiator调用targrt里的方法,由此来实现数据通信。
②在对象里创建TLM端口,然后在更高层次里将对象例化连接。
1.3 端口类型
port类型:存在于initiator中,initiator通过port端口访问相连接的targrt中的通信方法。
imp (import)类型:存在于targrt中,只能作为port或者export连接的终点。
export类型:作为initiator和target中间层次的端口。
1.4 示例
class request extends uvm_transaction; //sv里数据类到uvm里继承uvm_transaction
..
endclass
class response extends uvm_transaction;
..
endclass
class comp1 extends uvm_agent;
uvm_blocking_get_port#(request) bg_port; //#前是uvm固定声明格式,#()内表明数据类型,
//bg_port是端口句柄
.. //省略注册和new
endclass
class comp2 extends uvm_agent;
uvm_blocking_get_port#(request) bg_port; //与comp1中的声明一样
uvm_nonblocking_put_imp#(request,comp2) nbp_imp; //imp的声明中#()要表明数据类型和
//当前数据所在component类型
//comp2里的imp是根据comp4里的port声明的
..
endclass
class comp3 extends uvm_agent;
.. //这里先略过双向通信
endclass
class comp4 extends uvm_agent;
uvm_blocking_get_imp#(request) bg_port; //与comp2中port声明相对应
uvm_nonblocking_put_port#(request) nbp_port;
..
endclass
class agent1 extends uvm_agent;
uvm_blocking_get_port#(request) bg_port;
uvm_nonblocking_put_export#(request) nbp_exp;
..
comp1 c1;
comp2 c2;
.. //省略agent1注册和new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
c1=comp1::type_id::create("c1",this);
c2=comp2::type_id::create("c2",this);
..
endfunction //在高一层次例化低一层次的组件
function void connect_phase(uvm_phase phase);
super.connect_phase(phas);
c1.bg_port.connect(this.bg_port);
c2.bg_port.connect(this.bg_port);
t