当前位置:网站首页>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
边栏推荐
猜你喜欢

数据库字典Navicat自动生成版本

快速做出原型

Delivery mode design of Spartacus UI of SAP e-commerce cloud

13. Semaphore critical zone protection

从MediaRecord录像中读取H264参数

stm32和電機開發(上比特系統)

对话吴纲:我为什么笃信“大国品牌”的崛起?

Aiphacode is not a substitute for programmers, but a tool for developers

LeetCode+ 76 - 80 暴搜专题

Shapiro Wilk normal analysis by SPSS
随机推荐
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
SQOOP 1.4.6 INSTALL
Webui automated learning
【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh
Zlib download and use
Pytest framework implements pre post
Feature (5): how to organize information
Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
[unity3d] cannot correctly obtain the attribute value of recttransform, resulting in calculation error
618再次霸榜的秘密何在?耐克最新财报给出答案
Pywin32 opens the specified window
Merge ordered sequence
12. Process synchronization and semaphore
AI技术产业热点分析
01安装虚拟机
从MediaRecord录像中读取H264参数
How to get the password of cpolar?
面对不确定性,供应链的作用
2.hacking-lab脚本关[详细writeup]
07 data import sqoop