topic
overview
不建议的方法:假如没有TLM
TLM
TLM 1.0
整个TLM机制下,底层逻辑离不开动作发起者和被动接受者这个底层的模型基础,但实际上,在验证环境中,任何一个组件,都有可能成为动作的发起者,都有可能主动发起命令,且只有掌握主动权,才能更灵活的控制数据的流通,因此TLM机制下,实际用的最多的组件,也就是基于FIFO的数据通信。
端对端的fifo模式
主要的连接图如上:
monitor里面声明put port端口。
reference model 里面声明get port端口。
monitor在agent里面,将agent的export端口与monitor的put port端口连接。
在env里,将agent 的export与fifo相连接,将reference model的port与fifo相连接。
class my_monitor extends uvm_component;
`uvm_component_utils(my_monitor)
uvm_blocking_put_port #(my_transaction, my_monitor) m2r_port;//monitor里面声明put port端口
function new(string name = "",uvm_component parent);
super.name(name, parent)
this.m2r_port = new("m2r_port",this);
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
repeat(10) begin
req = seq_item::type_id::create("req");
assert(req.randomize());
m2r_port.put(req);
`uvm_info(get_name(), $sformatf("Send value = %0h", req.value), UVM_NONE);
#5;
end
endtask
endclass
class my_reference_model extends uvm_component;
`uvm_component_utils(my_reference_model)
uvm_blocking_get_port #(my_transaction) m2r_port;//reference model 里面声明get port端口
function new(string name = "",uvm_component parent);
super.name(name, parent)
this.m2r_port = new("m2r_port",this);
endfunction
virtual task run_phase (my_transaction tr);
`uvm_info(get_name(), "begin to get data from monitor",UVM_LOW)
forever begin
m2r_port.get(item);
`uvm_info(get_name(),("master agent have been sent a transaction:\n",item.sprint()),UVM_LOW)
end
endtask
endclass
class master_agent extends uvm_agent;//monitor在agent里面,将agent的export端口与monitor的put port端口连接
`uvm_component_utils(master_agent)
uvm_blocking_put_export #(my_transaction) m_a2r_export;
my_monitor my_mon;
function new(string name = "",uvm_component parent);
super.name(name, parent)
this.m_a2r_export = new("m_a2r_export",this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
my_mon = my_monitor::type_id::create("my_monitor", this);
endfunction: build_phase
virtual function void connect_phase (uvm_phase phase);
if(is_active = UVM_ACTIVE);
my_mon.m2r_port.connect(this.m_a2r_export);
`uvm_info(get_name(), "Monitor has been connect with agent",UVM_LOW)
endfunction
endclass
class my_env extends uvm_env;//在env里,将agent 的export与fifo相连接,将reference model的port与fifo相连接
`uvm_component_utils(my_env)
my_reference_model my_model;
master_agent my_agent;
uvm_tlm_analysis_fifo # (my_transaction) agt2ref_mod_fifo
function new(string name = "",uvm_component parent);
super.name(name, parent)
this.agt2ref_mod_fifo = new("agt2ref_mod_fifo",this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
my_model = my_reference_model::type_id::create("my_model", this);
my_agent = master_agent::type_id::create("my_agent", this);
endfunction: build_phase
virtual function void connect_phase (uvm_phase phase);
my_agent.m_a2r_export.connect(agt2ref_mod_fifo.uvm_blocking_put_export);
my_model.m2r_port.connect(agt2ref_mod_fifo.uvm_blocking_get_export);
endfunction
endclass
参考文献
原文链接:https://blog.csdn.net/JamesBond619/article/details/137541659
原文链接:https://blog.csdn.net/qq_36955425/article/details/130631383