当前位置:网站首页>UVM - usage of common TLM port
UVM - usage of common TLM port
2022-07-02 10:41:00 【weixin_ forty-five million seven hundred and four thousand five】
put Pattern
producer call consumer Medium heavy duty put Method , Send data to consumer. The code example is as follows .
The code example here is monitor towards reference model send data .
monitor
class my_monitor extends uvm_monitor;
`uvm_component_utils(my_monitor);
virtual dut_interface m_vif;
uvm_blocking_put_port #(my_transaction) m2r_port;
function new(string name = "", uvm_component parent);
super.new(name, parent);
this.m2r_port = new("m2r_port", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info("TRACE", $sformatf("%m"), UVM_HIGH)
if(!uvm_config_db#(virtual dut_interface)::get(this, "", "vif", m_vif))begin
`uvm_fatal("CONFIG_FATAL", "Monitor can not get the interface !!!")
end
endfunction
virtual task run_phase(uvm_phase phase);
my_transaction tr;
...
`uvm_info("Monitor", "Now monitor send the transaction to the reference model!", UVM_MEDIUM)
this.m2r_port.put(tr);
endtask
endclass
reference model
stay reference model It's overloaded put Mission . The task is monitor In the called .
class my_reference_model extends uvm_component;
`uvm_component_utils(my_reference_model)
uvm_blocking_put_imp #(my_transaction, my_reference_model) i_m2r_imp;
function new(string name = "", uvm_component parent);
super.new(name, parent);
this.i_m2r_imp = new("i_m2r_imp", this);
endfunction
task put(my_transaction tr);
`uvm_info("REF_REPORT", {
"\n", "master agent have been sent a transaction:\n", tr.sprint()}, UVM_MEDIUM)
endtask
endclass
stay env Connect two ports in .
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
`uvm_info("ENV", "Connect the agent and reference model...", UVM_MEDIUM)
m_agent.m_a2r_export.connect(ref_model.i_m2r_imp);
endfunction
get Pattern
monitor
class my_monitor extends uvm_monitor;
`uvm_component_utils(my_monitor);
virtual dut_interface m_vif;
uvm_blocking_get_imp #(my_transaction, my_monitor) m2r_imp;
my_transaction tr_fifo[$];
function new(string name = "", uvm_component parent);
super.new(name, parent);
this.m2r_imp = new("m2r_imp", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info("TRACE", $sformatf("%m"), UVM_HIGH)
if(!uvm_config_db#(virtual dut_interface)::get(this, "", "vif", m_vif))begin
`uvm_fatal("CONFIG_FATAL", "Monitor can not get the interface !!!")
end
endfunction
virtual task run_phase(uvm_phase phase);
my_transaction tr;
...
`uvm_info("Monitor", {
"\n", "Monitor Got An Input Transaction: \n", tr.sprint()}, UVM_MEDIUM)
tr_fifo.push_back(tr);
endtask
task get(output my_transaction s_tr);
while(tr_fifo.size() == 0) @(m_vif.imonitor_cb);
s_tr = tr_fifo.pop_front();
`uvm_info("Monitor", {
"\n", "Now monitor send the transaction to the reference model: \n",s_tr.sprint()}, UVM_MEDIUM)
endtask
endclass
Here in monitor Medium and heavy load get Method , stay reference model Call in .
reference model
class my_reference_model extends uvm_component;
`uvm_component_utils(my_reference_model)
uvm_blocking_get_port #(my_transaction) i_m2r_port;
function new(string name = "", uvm_component parent);
super.new(name, parent);
this.i_m2r_port = new("i_m2r_port", this);
endfunction
virtual task run_phase(uvm_phase phase);
`uvm_info("REF_MODEL_RUN", "reference model running !", UVM_MEDIUM)
forever begin
my_transaction item;
i_m2r_port.get(item);
`uvm_info("REF_REPORT", {
"\n", "master agent have been sent a transaction:\n", item.sprint()}, UVM_MEDIUM)
end
endtask
endclass
stay reference model Call in get Method .
stay env Middle link
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
`uvm_info("ENV", "Connect the agent and reference model...", UVM_MEDIUM)
ref_model.i_m2r_port.connect(m_agent.m_a2r_export);
endfunction
FIFO Pattern
monitor Port definition and put Model as
reference model Port definition and get Model as
stay env Define a fifo, Connect the two ports .
env
class my_env extends uvm_env;
`uvm_component_utils(my_env)
master_agent m_agent;
env_config m_env_cfg;
my_reference_model ref_model;
uvm_tlm_analysis_fifo #(my_transaction) magt2ref_fifo;
function new(string name = "", uvm_component parent);
super.new(name, parent);
magt2ref_fifo = new("magt2ref_fifo", this);
endfunction
...
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
`uvm_info("ENV", "Connect the agent to fifo...", UVM_MEDIUM)
m_agent.m_a2r_export.connect(this.magt2ref_fifo.blocking_put_export);
`uvm_info("ENV", "Connect the reference model to fifo...", UVM_MEDIUM)
ref_model.i_m2r_port.connect(this.magt2ref_fifo.blocking_get_export);
endfunction
endclass
边栏推荐
- 2021-10-04
- 01 install virtual machine
- lunix重新分配root 和 home 空间内存
- [SUCTF2018]followme
- Sum the two numbers to find the target value
- [Lua] summary of common knowledge points (including common interview sites)
- Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
- 2021-09-12
- sqoop的表的导入
- 转换YV12到RGB565图像转换,附YUV转RGB测试
猜你喜欢
[SUCTF2018]followme
pytest学习--base
Introduction to MySQL 8 DBA foundation tutorial
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Message mechanism -- getting to know messages and message queues for the first time
【虚幻4】从U3D到UE4的转型之路
12.进程同步与信号量
Understand the composition of building energy-saving system
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Rapid prototyping
随机推荐
两数之和,求目标值
Network communication learning
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
Transport Optimization abstraction
Basic usage of mock server
js promise. all
01安装虚拟机
【教程】如何让VisualStudio的HelpViewer帮助文档独立运行
2021-09-12
Shutter - canvas custom graph
Pywin32打开指定窗口
《MySQL 8 DBA基础教程》简介
VLAN experiment
02-taildir source
Blender stone carving
2021-10-04
Operator-1初识Operator
MYSQL环境配置
[SUCTF2018]followme
MPLS experiment