uvm_subscriber
阅读原文时间:2023年07月10日阅读:3

subscriber是消费,用户的意思

uvm_subscriber主要作为coverage的收集方式之一

uvm_subscriber的代码非常简单,继承于uvm_component,再加上一个analysis export而已。

其代码如下:

virtual class uvm_subscriber #(type T=int) extends uvm_component;
typedef uvm_subscriber #(T) this_type;

uvm_analysis_imp #(T, this_type) analysis_export;

function new (string name, uvm_component parent);
super.new (name, parent);
analysis_export = new ("analysis_imp", this);
endfunction

pure virtual function void write (T, t);
endclass

他的用法一般是,将monitor的analysis port连接到subscriber,将transaction传递过来,做function coverage。

class my_coverage extends uvm_subscriber #(bus_pkt);

covergroup cg_bus;

endgroup

virtual function void write (bus_pkt pkt);
cg_bus.sample ();
endfunction
endclass

class my_env extends uvm_env;

virtual function void connect_phase (uvm_phase phase);
super.connect_phase (phase);
my_agent.custom_ap.connect (my_cov.analysis_export);
endfunction
endclass

example:

class uvm_ip_subscriber extends uvm_subscriber;
//這裡使用FIFO通信而不是IMP,大大降低了工作量
uvm_tlm_analysis_fiof#(dma_trans) dma_monitor_to_sub_fifo[1];

extern function new(string name, uvm_component parent);
extern virtual function write(T t);
extern virtual task get_dma_trans();

extern virtual task run_phase(uvm_phase phase);

//coverage group
covergroup ostd_cfg_group;
option.per_instance = 1;
ostd: coverpoint(reg_cfg_trans.reg_wr_ostd[7:0]){
bins udb_0 = {0};
bins udb_1 = {[1:8]};
bins udb_2 = {[9:16]};
bins udb_3 = {[17:254]};
bins udb_4 = {255};
}
endgroup

endclass: uvm_ip_subscriber
function uvm_ip_subscriber::new(string name, uvm_component parent);
super.new();
dma_monitor_to_sub_fifo[0] = new("dma_monitor_to_sub_fifo_0", this);
//創建covergroup
ostd_cfg_group = new();
endfunction: new

//必須得重寫write這個純虛函數
function uvm_ip_subscriber::write(T t);
endfunction: write
task uvm_ip_subscriber::get_dma_trans();
dma_monitor_to_sub_fifo[0].get(tr);
$cast(tr_clone, tr);
reg_cfg_tr_q[0].push_back(tr_clone);

if(reg_cfg_tr_q[0].size() > 0) begin
reg_cfg_trans = reg_cfg_tr_q[0].pop_front();
//採樣
ostd_cfg_group.sample();
end
endtask: get_dma_trans

参考:

Subscriber [uvm_subscriber] (chipverify.com)

uvm_subscriber (verificationacademy.com)

uvm_subscriber | Francis's blog (francisz.cn)

[UVM]UVM Component之Subscriber_元直的博客-CSDN博客

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章